我正在尝试通过Proguard运行我的Android应用程序,但这一直在出现:
Warning:Exception while processing task java.io.IOException: Can't write [C:\Users\Aliaksei\AndroidStudioProjects\SignOutSystem\app\build\intermediates\transforms\proguard\debug\jars\3\1f\main.jar] (Can't read [D:\Users\Aliaksei\.android\build-cache\f7a6034d02d095f18cc21950f131d07fa78b41c0\output\jars\classes.jar(;;;;;;**.class)] (Duplicate zip entry [android/support/v4/os/j.class == classes.jar:android/support/v4/os/ResultReceiver$MyResultReceiver.class]))
我知道这意味着android.support.v4
在某处被声明了两次,所以我尝试将exclude group: 'com.android.support', module: 'support-v4'
添加到可能包含它的任何可能的依赖项中,但这并不起作用,即使经过清洁和重建。
认为我一定错过了某个地方的依赖,我继续将它添加到所有内容(Overkill),但这仍然没有奏效。
搜索周围,我在类似的帖子中找到了这个片段,并在android部分添加了这个:
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
我已经用尽了想法并且寻找答案似乎把我带到了我已经尝试过的事情上。我失踪了什么?
app build.gradle(乱七八糟,上面有所有黑客攻击):
apply plugin: 'com.android.application'
apply plugin: 'realm-android'
//apply plugin: 'com.getkeepsafe.dexcount'
android {
compileSdkVersion 23
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.aliakseipilko.signoutsystem"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
zipAlignEnabled true
proguardFile 'proguard-signoutsystem.txt'
}
debug {
minifyEnabled true
shrinkResources false
zipAlignEnabled true
proguardFile 'proguard-signoutsystem.txt'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
//dexcount {
// format = "list"
// includeClasses = false
// includeFieldCount = true
// includeTotalMethodCount = true
// orderByMethodCount = true
// verbose = false
// maxTreeDepth = Integer.MAX_VALUE
// teamCityIntegration = false
// enableForInstantRun = false
//}
repositories {
maven {
url "https://jitpack.io"
}
}
dependencies {
compile('com.google.api-client:google-api-client-android:1.22.0') {
exclude group: 'org.apache.httpcomponents'
exclude group: 'com.android.support', module: 'support-v4'
}
compile('com.google.apis:google-api-services-sheets:v4-rev19-1.22.0') {
exclude group: 'org.apache.httpcomponents'
exclude group: 'com.android.support', module: 'support-v4'
}
compile('com.google.android.gms:play-services-identity:9.2.0') {
exclude group: 'com.google.guava'
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.google.android.gms:play-services-auth:9.2.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.android.support:appcompat-v7:23.4.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.android.support:design:23.4.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile 'com.android.support:support-v4:23.4.0'
compile ('com.android.support:percent:23.4.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.squareup.okhttp3:okhttp:3.3.1') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.squareup.okhttp3:logging-interceptor:3.3.1') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.squareup.okio:okio:1.8.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.squareup.picasso:picasso:2.5.2') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('net.sf.biweekly:biweekly:0.4.6') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.github.tibolte:agendacalendarview:1.0.4') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.7heaven.widgets:segmentcontrol:1.14') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.survivingwithandroid:weatherlib:1.6.0') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile 'com.survivingwithandroid:weatherlib_okhttpclient:1.6.0'
compile files('libs/FDxSDKProAndroid.jar')
debugCompile ('com.squareup.leakcanary:leakcanary-android:1.5') {
exclude group: 'com.android.support', module: 'support-v4'
}
releaseCompile ('com.squareup.leakcanary:leakcanary-android-no-op:1.5') {
exclude group: 'com.android.support', module: 'support-v4'
}
testCompile ('com.squareup.leakcanary:leakcanary-android-no-op:1.5') {
exclude group: 'com.android.support', module: 'support-v4'
}
compile ('com.jakewharton:butterknife:8.5.1') {
exclude group: 'com.android.support', module: 'support-v4'
}
annotationProcessor ('com.jakewharton:butterknife-compiler:8.5.1') {
exclude group: 'com.android.support', module: 'support-v4'
}
}
project build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.4.0-alpha1'
classpath "io.realm:realm-gradle-plugin:3.0.0"
// classpath 'com.getkeepsafe.dexcount:dexcount-gradle-plugin:0.5.5'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Proguard规则:
#DEBUGGING
#-dontobfuscate
#-dontoptimize
###############
-optimizationpasses 5
-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-dontpreverify
-verbose
-optimizations !code/simplification/arithmetic,!field/*,!class/merging/*
-adaptresourcefilenames
-keep class com.aliakseipilko.signoutsystem.** { *; }
-keep public class * extends android.app.Activity
-keep public class * extends android.app.Application
-keep public class * extends android.app.Service
-keep public class * extends android.content.BroadcastReceiver
-keep public class * extends android.content.ContentProvider
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.billing.IInAppBillingService
-keep public class * extends android.view.View {
public <init>(android.content.Context);
public <init>(android.content.Context, android.util.AttributeSet);
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet);
}
-keepclasseswithmembers class * {
public <init>(android.content.Context, android.util.AttributeSet, int);
}
-keepclassmembers class * extends android.content.Context {
public void *(android.view.View);
public void *(android.view.MenuItem);
}
-keepclassmembers enum * {
public static **[] values();
public static ** valueOf(java.lang.String);
}
-dontwarn sun.misc.Unsafe
-dontwarn okio.**
-dontwarn com.squareup.okhttp.**
-dontwarn biweekly.io.**
-dontwarn com.github.tibolte.**
-keep class com.github.tibolte.**
-keep class okio.**
-keep class biweekly.io.**
-keep class com.squareup.okhttp.**
-keep class SecuGen.FDxSDKPro.**
-keep class com.survivingwithandroid.**
-keep class android.support.v4.app.** { *; }
-keep interface android.support.v4.app.** { *; }
-dontwarn android.support.**
-keep public class android.support.v7.widget.** { *; }
-keep public class android.support.v7.internal.widget.** { *; }
-keep public class android.support.v7.internal.view.menu.** { *; }
-keep public class * extends android.support.v4.view.ActionProvider {
public <init>(android.content.Context);
}
-keepclasseswithmembernames class * {
native <methods>;
}
-keep class * implements android.os.Parcelable {
public static final android.os.Parcelable$Creator *;
}
-keep class *.R
-keepclasseswithmembers class **.R$* {
public static <fields>;
}
# Retain generated class which implement Unbinder.
-keep public class * implements butterknife.Unbinder { public <init>(**, android.view.View); }
# Prevent obfuscation of types which use ButterKnife annotations since the simple name
# is used to reflectively look up the generated ViewBinding.
-keep class butterknife.*
-keepclasseswithmembernames class * { @butterknife.* <methods>; }
-keepclasseswithmembernames class * { @butterknife.* <fields>; }
任何帮助将不胜感激
答案 0 :(得分:8)
问题是butterknife
使用更高的支持版本(25.1.0
)编译,因此您可能希望降级butterknife
或将所有支持库移至25.1.0
< / p>
我已将butterknife
降级为8.0.1
:
dependencies {
compile('com.google.api-client:google-api-client-android:1.22.0') {
exclude module: 'httpclient'
}
compile('com.google.apis:google-api-services-sheets:v4-rev19-1.22.0') {
exclude module: 'httpclient'
}
compile 'com.google.android.gms:play-services-identity:9.2.0'
compile 'com.google.android.gms:play-services-auth:9.2.0'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.android.support:percent:23.4.0'
compile 'com.squareup.okhttp3:okhttp:3.3.1'
compile 'com.squareup.okhttp3:logging-interceptor:3.3.1'
compile 'com.squareup.okio:okio:1.8.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'net.sf.biweekly:biweekly:0.4.6'
compile 'com.github.tibolte:agendacalendarview:1.0.4'
compile 'com.7heaven.widgets:segmentcontrol:1.14'
compile 'com.survivingwithandroid:weatherlib:1.6.0'
compile 'com.survivingwithandroid:weatherlib_okhttpclient:1.6.0'
compile files('libs/FDxSDKProAndroid.jar')
debugCompile 'com.squareup.leakcanary:leakcanary-android:1.5'
releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.5'
testCompile('com.squareup.leakcanary:leakcanary-android-no-op:1.5')
compile 'com.jakewharton:butterknife:8.0.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.0.1'
}
然后在proguard.pro
处理警告:
-keep class com.fasterxml.** { *; }
-dontwarn com.fasterxml.**
-keep class biweekly.io.json.** { *; }
-dontwarn biweekly.io.json.**
-dontwarn java.lang.invoke**
-dontwarn sun.misc.Unsafe
-dontwarn okio.**
请注意,我还启用了multidex以便成功构建:我已将multiDexEnabled true
添加到defaultConfig