android - 为版本 : Proguard config 生成签名的 apk 时出错

标签 android android-gradle-plugin proguard android-proguard

我目前正尝试在 Android Studio 中为应用程序生成发布版本。我试图在生成发布版本时消除所有问题,但我遇到了一些问题。

Warning:com.viewpagerindicator.LinePageIndicator: can't find referenced method 'float ceil(float)' in library class android.util.FloatMath
Warning:org.androidannotations.api.rest.RestClientHeaders: can't find referenced class org.springframework.http.HttpAuthentication
Warning:org.androidannotations.api.rest.RestClientSupport: can't find referenced class org.springframework.web.client.RestTemplate
Warning:org.androidannotations.api.rest.RestErrorHandler: can't find referenced class org.springframework.core.NestedRuntimeException
Warning:there were 4 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 1 unresolved references to library class members.
     You probably need to update the library versions.
     (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)
Exception while processing task 
java.io.IOException: Please correct the above warnings first.

我还收到一个错误,指出

Error:Execution failed for task ':app:packageRelease'.
> Unable to compute hash of  /Users/rohanmahale/AndroidStudioProjects/Prism/app/build/intermediates/classes-proguard/release/classes.jar

在我的 gradle 文件中,我设置了以下内容

android {
compileSdkVersion 23
buildToolsVersion '23.0.2'
defaultConfig {
    applicationId 'com.prism.prismapp'
    minSdkVersion 16
    targetSdkVersion 23
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        minifyEnabled true
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
productFlavors {
}

我的依赖列表如下

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:cardview-v7:23.0.+'
compile 'com.android.support:recyclerview-v7:23.0.+'
compile 'de.greenrobot:eventbus:2.4.0'
compile 'com.joooonho:selectableroundedimageview:1.0.1'
compile 'com.commonsware.cwac:camera:0.6.+'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'commons-io:commons-io:2.4'
compile 'com.facebook.android:facebook-android-sdk:4.7.0'
compile 'com.github.nkzawa:socket.io-client:0.5.2'
compile 'io.nlopez.smartlocation:library:3.2.0'
compile('com.crashlytics.sdk.android:crashlytics:2.5.2@aar') {
    transitive = true;
}
compile 'uk.co.chrisjenx:calligraphy:2.1.0'
compile 'com.github.bumptech.glide:glide:3.6.1'
compile 'com.pixplicity.multiviewpager:library:1.0'
compile 'com.githang:viewpagerindicator:2.4.2@aar'
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.3.1'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.3.1'
compile 'com.commit451:PhotoView:1.2.4'
compile 'me.villani.lorenzo.android:android-cropimage:1.1.0'
compile ('com.google.android.gms:play-services-analytics:8.1.0') {
    exclude module: 'play-services-ads'
}}

如何解决问题并成功创建发布版本?

更新:

我能够摆脱与 android 注释相关的警告。

我还有以下问题

Warning:com.viewpagerindicator.LinePageIndicator: can't find referenced method 'float ceil(float)' in library class android.util.FloatMath
Warning:there were 1 unresolved references to library class members.
     You probably need to update the library versions.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)

最佳答案

对我而言,当前的解决方案是将以下行添加到我的混淆文件中:

-dontwarn com.viewpagerindicator.**

当您创建release build

时,这将删除上面包中的警告

关于android - 为版本 : Proguard config 生成签名的 apk 时出错,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33569532/

相关文章:

Android:使用 Retrofit 库获取 JSON 数据中的第一个值

java - Android 包生成器错误 : Unsupported Major Minor version 52. 0

android - 在 Android Studio 中评论 junit test 是一种安全的方式吗?

android - Android 上的 Gradle 7 : add BuildConfigField with new variant api from AGP 7

android - 过时的 proguard 文件;使用 -keepclasseswithmembers 而不是 -keepclasseswithmembernames

android - TextView 不显示。但是在 logcat 中显示时一切正常

Android 二维码扫描器库

android - AAPT2 错误 - 在 mergeDebugResources 中找不到 appcompat-v7 文件

Gradle:分发可执行的混淆 Jar 文件

firebase - 在 java 类中为 firestore 文档指定序列化名称