我的应用程序运行良好,直到我试图构建版本.我收到以下错误消息:
java.lang.NoSuchFieldError: no field with name=’globals’ signature=’J’
in class Lcom/artifex/mupdfdemo/MuPDFCore;
显然问题在我的mupdf库中.我建立这个图书馆到aar文件,而不用proguard.这是我的build.gradle for mupdf库:
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是false.
那么这里是我的应用程序的build.gradle文件:
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文件:
-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