混淆错误生成发布版apk

14
我尝试构建一个发布版apk时,出现了以下错误。
:app:compileReleaseNdk UP-TO-DATE
:app:compileReleaseSources
:app:lintVitalRelease
:app:proguardRelease
Warning: android.support.v4.app.NotificationCompat$NotificationCompatImplBase: can't find referenced method 'void setLatestEventInfo(android.content.Context,java.lang.CharSequence,java.lang.CharSequence,android.app.PendingIntent)' in library class android.app.Notification
Warning: android.support.v4.app.NotificationCompat$NotificationCompatImplGingerbread: can't find referenced method 'void setLatestEventInfo(android.content.Context,java.lang.CharSequence,java.lang.CharSequence,android.app.PendingIntent)' in library class android.app.Notification
Warning: android.support.v4.app.NotificationCompatGingerbread: can't find referenced method 'void setLatestEventInfo(android.content.Context,java.lang.CharSequence,java.lang.CharSequence,android.app.PendingIntent)' in library class android.app.Notification
Warning: there were 3 unresolved references to library class members.
         You probably need to update the library versions.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)
:app:proguardRelease FAILED

在build.gradle文件中,我有这样一段代码:
dependencies { compile "com.android.support:support-v4:23.0.0" }
如果我将其改为以下代码,仍然会收到同样的错误提示:
"com.android.support:support-v13:23.0.0"
当错误提示显示:“您可能需要更新库版本。”指的是哪个库?如何更新它?
错误信息所引用的文档提到:
"If you're developing for Android and ProGuard complains that it can't find a method that is only available in a recent version of the Android run-time, you should change the build target in your project.properties file or build.gradle file to that recent version. You can still specify a different minSdkVersion and a different targetSdkVersion in your AndroidManifest.xml file."
这是我的build.gradle文件,其中API版本号为最新的23。那么我该如何解决这个问题呢?
android {
    compileSdkVersion 23
    buildToolsVersion "23.0.1"

    defaultConfig {
        applicationId "com.cequint.ecid"
        minSdkVersion 23
        compileSdkVersion 23
    }

你尝试更新到 com.android.support:support-v4:23.1.0 了吗? - kandroidj
更新到com.android.support:support-v4:23.1.0后,出现了相同的错误消息。 - Gruntcakes
1
我将以下内容添加到proguard.cfg中,它可以正常工作:-dontwarn android.support.v4.** - Gruntcakes
1
很高兴你解决了问题,我建议你回答自己的问题并接受答案。 - kandroidj
1个回答

13

我将以下内容添加到pro guard.cfg中,然后它就起作用了:

-dontwarn android.support.v4.**

1
你是否真正使用了NotificationCompat及其构建器?我添加了这个文件,但现在却出现了运行时异常。 - Nilzor
1
是的,我正在使用NotificationCompat。你的意思是说你开始使用NotificationCompat,然后在这样做时开始出现异常?如果是这样,那么你可能在gradle文件中缺少依赖项。 - Gruntcakes
结果证明是一个无关的更改导致了这个问题。不用理我。 - Nilzor

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接