web-dev-qa-db-ja.com

Proguard重複Zipエントリ

私はAndroidアプリケーションをProguard経由で実行しようとしていますが、これは表示され続けます:

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がどこかで2回宣言されていることを意味しているため、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'
    }
}

プロジェクト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>; }

任意の助けいただければ幸いです。

10
aliaksei

問題はbutterknifeで、これはより高いサポートバージョン(25.1.0)でコンパイルされているため、butterknifeをダウングレードするか、すべてのサポートライブラリを25.1.0に移動することをお勧めします

ここでbutterknife8.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 truedefaultConfigに追加しました

8
Bertrand Martel