2015-11-06 164 views
6

我目前正在嘗試爲Android Studio中的應用生成發佈版本。我試圖擺脫所有問題,同時生成發佈版本,但我堅持幾個問題。生成已簽名apk的發佈錯誤:Proguard config

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:[email protected]') { 
    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:[email protected]' 
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' 
}} 

如何擺脫問題併成功創建發佈版本?

UPDATE:

我能夠擺脫與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()'來改變。 – Fllo

+0

我應該如何以及在哪裏進行此更改?它是我發現的一個視圖庫的一部分。 – Rohan

+0

確實,這將是一個問題。我得到了同樣的問題,但我在本地文件夾中使用lib,因此我能夠更改這些方法。在LinePageIndicator.java中有'private',所以我不知道你至少在本地文件夾中得到這個lib。 – Fllo

回答

9

對我來說,目前的解決方案是將下面的行添加到我的ProGuard文件:

-dontwarn com.viewpagerindicator.** 

這將刪除警告以上包時到來您創建版本構建

+0

我還應該加上'-keep public class com.viewpagerindicator.LinePageIndicator'嗎? – natsumiyu

相關問題