Proguard重复邮编输入 [英] Proguard Duplicate Zip Entry

查看:46
本文介绍了Proguard重复邮编输入的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试通过Proguard运行我的android应用程序,但这一直出现:

I am trying to run my android application through Proguard, however this keeps appearing:

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'添加到可能包含它的任何可能的依赖项中,但是即使经过清理和重建.

I am aware that this means that the android.support.v4 is being declared twice somewhere, so I have tried adding exclude group: 'com.android.support', module: 'support-v4' to any possible dependencies that might have it included, however that didn't work, even after a clean and rebuild.

考虑到我一定在某个地方错过了依赖,我继续将其添加到所有内容中(Overkill),但这仍然没有用.

Thinking I must have missed a dependency somewhere, I proceeded to add it to everything (Overkill), but that still hasn't worked.

四处搜寻,我在类似的帖子中找到了这个片段,并将其添加到了android部分:

Searching around, I found this snippet in similar posts and added this in the android section as well:

packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
}

我的想法已经用光了,寻找答案似乎使我了解了我已经尝试过的东西.我有什么想念吗?

I have run out of ideas and searching for answers seems to take me to things I have already tried. Anything I'm missing?

app build.gradle(一团糟,上面有所有hack):

app build.gradle (A mess, with all the hacks above):

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'
    }
}

项目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
}

保护规则:

#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>; }

任何帮助将不胜感激.

推荐答案

问题是butterknife,它是使用更高支持版本(25.1.0)编译的,因此您可能想降级butterknife或移走所有支持库到25.1.0

The issue is butterknife which is compiled with a higher support version (25.1.0), so you may want to downgrade butterknife or move all support library to 25.1.0

在这里,我已将butterknife降级为8.0.1:

Here I've downgraded butterknife to 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中处理警告:

Then in your proguard.pro to deal with warning :

 -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

Note that I've also enabled multidex to build successfully : I've added multiDexEnabled true to defaultConfig

这篇关于Proguard重复邮编输入的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆