mupdf 库的 Proguard 问题 [英] Proguard issue for mupdf library

查看:19
本文介绍了mupdf 库的 Proguard 问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我尝试构建发布版本之前,我的应用程序运行良好.我收到以下错误消息:

My application is running well until I'm trying to build the release version. I got the following error message:

java.lang.NoSuchFieldError: no field with name='globals' signature='J'在类 Lcom/artifex/mupdfdemo/MuPDFCore;

java.lang.NoSuchFieldError: no field with name='globals' signature='J' in class Lcom/artifex/mupdfdemo/MuPDFCore;

显然问题出在我的 mupdf 库中.我在不使用 proguard 的情况下将此库构建为 aar 文件.这是我的 mupdf 库的 build.gradle:

Apparently the problem is in my mupdf library. I built this library to an aar file without using proguard. Here is my build.gradle for mupdf library:

apply plugin: 'android-library'

android {
    compileSdkVersion 19
    buildToolsVersion "19.0.0"

    defaultConfig {
        minSdkVersion 8
        targetSdkVersion 19
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            runProguard false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
        }
    }
}

如您所见,runProguard 是错误的.

As you see, the runProguard is false.

然后是我的应用程序的 build.gradle 文件:

Then here comes the build.gradle file of my application:

apply plugin: 'android'

android {
    compileSdkVersion 19
    buildToolsVersion '19.0.0'

    defaultConfig {
        minSdkVersion 9
        targetSdkVersion 19
        versionCode 6
        versionName "2.0"
    }

    signingConfigs {

    }

    buildTypes {
        release {
            runProguard true
            proguardFile file('key/proguard-android.txt')
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:+'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.artifex.mupdfdemo:mupdfreader-lib:1.0.0@aar'
}

这里是 proguard-android.txt 文件:

And here is the proguard-android.txt file:

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose
-dontoptimize
-dontpreverify

-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclassmembers public class * extends android.view.View {
   void set*(***);
   *** get*();
}

-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

-keepclassmembers class **.R$* {
    public static <fields>;
}

-dontwarn android.support.**    
-dontwarn android.support.v4.** -keep class android.support.v4.** { *; }
-dontwarn android.support.v7.** -keep class android.support.v7.** { *; }

-keep public class com.artifex.mupdfdemo.MuPDFActivity
-keep public class com.artifex.mupdfdemo.MuPDFCore

如您所见,MuPDFCore 已添加到我的 proguard 文件中.任何人都可以帮助说出问题是什么?非常感谢.

As you see, the MuPDFCore is added to my proguard file. Can anybody help to tell what the problem is ? Thank you so much.

推荐答案

通过添加这一行

-keep class com.artifex.mupdfdemo.** {*;}

解决了这个问题.

在我将问题发布到 stackoverflow 后,我总能找到问题的解决方案.无论如何它可能会帮助其他人.

I always find the solution for the problem after I posted the questions to stackoverflow. Anyway it may help somebody else.

这篇关于mupdf 库的 Proguard 问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆