我们正在从Android Gradle插件2.3.3迁移到Gradle插件3.0.1。我们的应用程序包括一个应用程序模块和一个库模块。多个依赖项是可传递的(使用"serilog:properties...
关键字进行连接),但即使使用api
使它们不可传递也无济于事。将所有implementation
- 类型依赖项更改为新的依赖项后,调试版本运行良好。然而,使用Proguard的发布版本显示了成千上万的警告(在2.3.3一切顺利)
特别是,我不知道为什么我们有这样的问题,当来自库的Android类依赖于来自程序的Android类时(这里只是几个例子):
compile
总体而言,Gradle插件2.3.3上没有出现下一类警告(因此,已经配置了Proguard):
Warning: library class android.app.ActionBar$LayoutParams extends or implements program class android.view.ViewGroup$MarginLayoutParams
Warning: library class android.app.ActivityManager$TaskDescription extends or implements program class android.os.Parcelable
Warning: library class android.widget.Toolbar depends on program class android.view.ViewGroup$LayoutParams
以下是依赖项列表(Warning: there were 72 unresolved references to classes or interfaces.
You may need to add missing library jars or update their versions.
If your code works fine without the missing classes, you can suppress
the warnings with '-dontwarn' options.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning: there were 1373 instances of library classes depending on program classes.
You must avoid such dependencies, since the program classes will
be processed, while the library classes will remain unchanged.
(http://proguard.sourceforge.net/manual/troubleshooting.html#dependency)
Warning: there were 1056 unresolved references to program class members.
Your input classes appear to be inconsistent.
You may need to recompile the code.
(http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedprogramclassmember)
FAILURE: Build failed with an exception.
):
gradle -q app:dependencies --configuration developmentDebugRuntimeClasspath
答案 0 :(得分:3)
-dontwarn android.**
无法解决您的问题。您需要查看依赖关系树并找到导致问题的库。
例如在我的情况下它是
+--- com.foursquare:foursquare-android-oauth:1.0.3
| \--- com.google.android:android:4.1.1.4
| +--- commons-logging:commons-logging:1.1.1
| +--- org.apache.httpcomponents:httpclient:4.0.1
| | +--- org.apache.httpcomponents:httpcore:4.0.1
| | +--- commons-logging:commons-logging:1.1.1
| | \--- commons-codec:commons-codec:1.3
| +--- org.khronos:opengl-api:gl1.1-android-2.1_r1
| +--- xerces:xmlParserAPIs:2.6.2
| +--- xpp3:xpp3:1.1.4c
| \--- org.json:json:20080701
因此,您需要为此库排除com.google.android
implementation ('com.foursquare:foursquare-android-oauth:1.0.3'){
exclude group: 'com.google.android'
}
答案 1 :(得分:2)
快速修复: 升级到Gradle插件3.0.0时出现此问题,快速解决方案是在proguard文件中添加此项,
-dontwarn android.**
这也适用于3.0.1。
<强>推荐:强> 当您使用的库未从支持库引用android类或引用不推荐的类时,会发生这种情况。我的猜测是,
com.github.tony19:logback-android-core
您正在使用导致此问题,您可以删除此依赖项并尝试重建。如果这没有帮助,您可以尝试删除您正在使用的任何其他库,但它们最近没有更新。