我有一个使用外部引用库的应用程序(也就是说,库的目录与应用程序处于同一级别 - 它不会复制到应用程序的文件夹中).该库由应用程序引用,库和应用程序都包含proguard文件.在构建应用程序之前,一切正常.当我构建应用程序时,找不到引用库中定义的类的所有内容 - 我在所有库类导入中找到'找不到符号类...)错误.正如我发现的那样,这是因为在重建应用程序时,proguard会混淆所有类和变量,因此应用程序无法引用它们.我已将以下内容添加到build.gradle文件中,
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
debug {
minifyEnabled false
}
}
Run Code Online (Sandbox Code Playgroud)
但似乎在构建应用程序时,不考虑上述内容(或者在发布模式下完成构建).如果我将以上内容更改为以下内容(即,在发布模式下禁用proguard),
buildTypes {
release {
**minifyEnabled false**
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
debug {
minifyEnabled false
}
}
Run Code Online (Sandbox Code Playgroud)
申请编译好.
这个问题有方法解决吗?我是否只能在创建签名应用程序时启用proguard?
这是库proguard文件:
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-optimizations !method/marking/static
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends …Run Code Online (Sandbox Code Playgroud)