當我建立一個發佈版本,我得到以下警告的gradle:搖籃(ProGuard的)異常,而處理任務java.io(複製ZIP條目)
Warning:Exception while processing task java.io.IOException:
Can't write [C:\Users\MyName\AndroidStudioProjects\MyApp\app\build\intermediates\transforms\proguard\free\release\jars\3\1f\main.jar]
(Can't read [C:\Users\MyName\AndroidStudioProjects\MyApp\app\build\intermediates\classes\free\release(;;;;;;**.class)]
(Can't read [com] (Can't read [android] (Can't read [vending] (Can't read [billing]
(Can't read [IInAppBillingService$Stub$Proxy.class]
(Duplicate zip entry [com/android/a/a/a$a$a.class == com/android/vending/billing/IInAppBillingService$Stub$Proxy.class])))))))
和錯誤:
Error:Execution failed for task
':app:transformClassesAndResourcesWithProguardForFreeRelease'.
> Job failed, see logs for details
可能某種ProGuard問題。這是因爲我一直在嘗試實施新的Play Billing Library。我嘗試清理並重建項目(多次),並使緩存失效並重新啓動,但都無濟於事。
注意真的要確定在這裏包含哪些資源...以下是可能相關的片段。
從build.gradle
:
compileSdkVersion 26
buildToolsVersion '26.0.1'
defaultConfig {
minSdkVersion 16
targetSdkVersion 26
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':playLicensing')
compile 'com.android.billingclient:billing:1.0'
compile 'com.firebase:firebase-jobdispatcher:0.8.3'
compile 'com.google.android.gms:play-services-location:11.4.2'
compile 'com.google.android.gms:play-services-places:11.4.2'
compile 'com.google.android.gms:play-services-auth:11.4.2'
compile 'com.google.guava:guava:23.1-android'
compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support:design:26.0.2'
}
和proguard-rules.pro
:
-dontwarn com.google.**
-keepattributes EnclosingMethod
-keepattributes JavascriptInterface
-keepclassmembers class * {
@android.webkit.JavascriptInterface <methods>;
}
-assumenosideeffects class android.util.Log {
public static boolean isLoggable(java.lang.String, int);
public static int v(...);
public static int i(...);
public static int w(...);
public static int d(...);
public static int e(...);
}
-printmapping mapping.txt
謝謝,它解決了我的問題 – Vitaly