Android - 任务应用程序的执行失败:transformClassesAndResourcesWithProguardForRelease

时间:2016-12-23 15:35:42

标签: android gradle retrofit2 android-proguard signed-apk

制作签名APK的第一时间,我收到了一些警告和错误:

Warning:okio.DeflaterSink: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning:okio.Okio: can't find referenced class java.nio.file.Files
Warning:okio.Okio: can't find referenced class java.nio.file.Path
Warning:okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning:okio.Okio: can't find referenced class java.nio.file.Path
Warning:okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning:okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning:okio.Okio: can't find referenced class java.nio.file.Path
Warning:okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning:okio.Okio: can't find referenced class java.nio.file.Path
Warning:okio.Okio: can't find referenced class java.nio.file.OpenOption
Warning:okio.Okio: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandles$Lookup
Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandle
Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandles
Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandle
Warning:retrofit2.Platform$Java8: can't find referenced class java.lang.invoke.MethodHandles$Lookup
Warning:retrofit2.Platform$Java8: can't find referenced class org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
Warning:there were 22 unresolved references to classes or interfaces.
Warning:Exception while processing task java.io.IOException: Please correct the above warnings first.
Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> java.io.IOException: Please correct the above warnings first.

我通过在okio上添加-dontwarn okio.**来了解并解决了proguard-rules.pro的问题,但改版2的问题仍然存在。

我也尝试添加-dontwarn retrofit2.Plataform$Java8.**,但现在我的版本没有结束(它在I7上使用16gb ram构建超过30分钟)。

我的build.gradle文件:

buildscript {
    repositories {
        maven { url 'https://maven.fabric.io/public' }
    }

    dependencies {
        classpath 'io.fabric.tools:gradle:1.+'
    }
}
apply plugin: 'com.android.application'

repositories {
    maven { url 'https://maven.fabric.io/public' }
}

apply plugin: 'android-apt'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 25
    buildToolsVersion "24.0.1"

    defaultConfig {
        applicationId "com.sibela.gohelper"
        minSdkVersion 11
        targetSdkVersion 25
        versionCode 1
        versionName "1.0.13"
    }

    buildTypes {
        release {
            shrinkResources true
            minifyEnabled true
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'

        }
    }

    buildTypes.each {
        it.buildConfigField 'String', 'MAPS_API_KEY', MapsApiKey
        it.buildConfigField 'String', 'MAPS_GEOCODING_API_KEY', MapsGeocodingApiKey
    }

    dexOptions {
        javaMaxHeapSize "3g"
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    apt 'com.jakewharton:butterknife-compiler:8.2.1'
    compile 'com.android.support:appcompat-v7:25.0.1'
    compile 'com.android.support:design:25.0.1'
    compile 'com.jakewharton:butterknife:8.2.1'
    compile 'com.github.bumptech.glide:glide:3.6.0'
    compile 'de.hdodenhof:circleimageview:1.3.0'
    compile 'com.android.support:support-v4:25.0.1'
    compile 'com.android.support:cardview-v7:25.0.1'
    compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
    compile 'com.squareup.retrofit2:retrofit:2.1.0'
    compile 'com.squareup.retrofit2:converter-gson:2.0.2'
    compile 'com.google.android.gms:play-services-location:10.0.1'
    compile 'com.google.android.gms:play-services-appinvite:10.0.1'
    compile 'com.google.android.gms:play-services-auth:10.0.1'
    compile 'com.takisoft.fix:preference-v7:25.0.1.0'
    compile('com.crashlytics.sdk.android:crashlytics:2.6.5@aar') {
        transitive = true;
    }
}

apply plugin: 'com.google.gms.google-services'

我的proguard-rules.pro

-keepnames class android.widget.ScrollView { *; }
-keepnames class android.widget.AbsListView { *; }
-keepnames class android.support.v4.widget.NestedScrollView { *; }
-keepnames class android.support.v7.widget.RecyclerView { *; }
-keepnames class android.support.v4.view.ViewPager { *; }
-keepnames class android.widget.EdgeEffect { *; }
-keepnames class android.support.v4.widget.EdgeEffectCompat { *; }
-dontwarn okio.**
-dontwarn retrofit2.Plataform$Java8.**

我该如何解决这个问题?

0 个答案:

没有答案