发布时生成签名APK时出现错误:Proguard配置

6

我目前正在尝试在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)

1
可能是因为FloatMath.ceil()已经被弃用了。你需要改成Math.ceil() - Blo
我应该在哪里进行这个更改?这是我找到的一个viewindicator库aar的一部分。 - Rohan
确实,这将是一个问题。我遇到了同样的问题,但我在本地文件夹中使用了该库,因此我能够更改这些方法。LinePageIndicator.java 中有 private 方法,所以我不知道你是否至少将此库获取到本地文件夹中。 - Blo
有什么想法我应该如何处理这个问题?我需要尽快创建一个发布版本并发送给客户。 - Rohan
如果您等不及,请下载lib ViewPagerIndicator zip文件,解压到libs文件夹中,更改两个已弃用的方法,并按照此答案添加外部库到您的项目gradle中。希望对您有所帮助。 - Blo
嘿 @Fllo。这正是我最终所做的。如果你将此作为答案添加,我会将其视为帮助过我的解决方案并点赞。我下载了该项目,将其添加为依赖项,然后将FloatMatch更改为Math。再次感谢! - Rohan
2个回答

10

对我而言,目前的解决方案是在我的proguard文件中添加以下行:

-dontwarn com.viewpagerindicator.**

创建发布版时,此操作将删除上述软件包中出现的警告。


我还需要添加“-keep public class com.viewpagerindicator.LinePageIndicator”吗? - natsumiyu

0

使用这个,它已经修复了。

编译 'fr.avianey.com.viewpagerindicator:library:2.4.1.1@aar'

你可以查看这个github问题


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