Proguard的问题进行mupdf库 [英] Proguard issue for mupdf library
问题描述
我的应用程序运行顺利,直到我试图建立的发行版。我得到了以下错误消息:
My application is running well until I'm trying to build the release version. I got the following error message:
java.lang.NoSuchFieldError:与名称的字段='全局'签名='J' 在课堂上LCOM / ARTIFEX / mupdfdemo / MuPDFCore;
java.lang.NoSuchFieldError: no field with name='globals' signature='J' in class Lcom/artifex/mupdfdemo/MuPDFCore;
显然,问题出在我的mupdf库。我建这个库的AAR文件,而无需使用ProGuard的。这是我的build.gradle的mupdf库:
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.** {*;}
解决了这个问题。
solved the problem.
我一直觉得对问题的解决方案后,我贴到计算器的问题。反正它可以帮助别人。
I always find the solution for the problem after I posted the questions to stackoverflow. Anyway it may help somebody else.
这篇关于Proguard的问题进行mupdf库的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!