2017-05-19 24 views
1

私はproguardを使用することに新しいですし、署名付きAPIを作成した後にAPIを構築するときに、私はそれを解決する方法を知らない。Androidビルドエラー:エラー:タスク ':app:transformClassesAndResourcesWithProguardForRelease'の実行に失敗しました

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:rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef: can't find referenced class sun.misc.Unsafe 
Warning:rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef: can't find referenced class sun.misc.Unsafe 
Warning:rx.internal.util.unsafe.ConcurrentCircularArrayQueue: can't find referenced class sun.misc.Unsafe 
Warning:rx.internal.util.unsafe.ConcurrentSequencedCircularArrayQueue: can't find referenced class sun.misc.Unsafe 
Warning:rx.internal.util.unsafe.MpmcArrayQueueConsumerField: can't find referenced class sun.misc.Unsafe 
Warning:rx.internal.util.unsafe.MpmcArrayQueueProducerField: can't find referenced class sun.misc.Unsafe 
Warning:rx.internal.util.unsafe.MpscLinkedQueue: can't find referenced class sun.misc.Unsafe 
Warning:rx.internal.util.unsafe.SpmcArrayQueueConsumerField: can't find referenced class sun.misc.Unsafe 
Warning:rx.internal.util.unsafe.SpmcArrayQueueProducerField: can't find referenced class sun.misc.Unsafe 
Warning:rx.internal.util.unsafe.SpscArrayQueue: can't find referenced class sun.misc.Unsafe 
Warning:rx.internal.util.unsafe.SpscUnboundedArrayQueue: can't find referenced class sun.misc.Unsafe 
Warning:rx.internal.util.unsafe.UnsafeAccess: can't find referenced class sun.misc.Unsafe 
Warning:there were 66 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'. 
> Job failed, see logs for details 

と私のGradleは、次のようになります:

はここエラーログ

android { 
    compileSdkVersion 25 
    buildToolsVersion "25.0.2" 
    defaultConfig { 

     minSdkVersion 18 
     targetSdkVersion 25 
     versionCode 1 
     versionName "1.0" 
     testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" 
     packagingOptions { 
      exclude 'LICENSE.txt' 
     } 
     lintOptions { 
      abortOnError false 
     } 
     useLibrary 'org.apache.http.legacy' 
     multiDexEnabled true 
    } 
    buildTypes { 
     release { 
      minifyEnabled true 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    testOptions { 
     unitTests.returnDefaultValues = true 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', { 
     exclude group: 'com.android.support', module: 'support-annotations' 
    }) 
    compile 'com.android.support:appcompat-v7:25.3.1' 
    compile 'com.android.support.constraint:constraint-layout:1.0.2' 
    testCompile 'junit:junit:4.12' 

    compile 'com.squareup.retrofit2:converter-scalars:2.1.0' 

    compile 'com.android.support:support-annotations:25.3.1' 

    compile 'com.squareup.retrofit2:retrofit:2.0.1' 
    compile "com.squareup.retrofit2:adapter-rxjava:2.1.0" 


    compile 'com.google.code.gson:gson:2.6.1' 
    compile 'com.squareup.retrofit2:converter-gson:2.1.0' 

    compile 'io.reactivex:rxandroid:1.2.1' 
    compile 'io.reactivex:rxjava:1.1.6' 


} 

私は、エラーを解決する方法がわかりません。私はプロガードを使用してサイズを小さくしたい。どんな助けもありがとう。

+0

を構築リリース時に正しいファイルをロードすることを忘れproguard-rules.proファイル – MatPag

+0

にお返事ありがとうございます。どんなタイプのラインが必要でしたか? – exceptionnotgood

+0

あなたのRxJava、Retrofit、およびGsonのバージョンは古くなっていると思います –

答えて

0

あなたのproguard-rules.proファイルにこれらの行を追加する必要があります。

# exclusions for Okio 
-dontwarn okio.** 

# exclusions for Retrofit 
-dontnote retrofit2.Platform 
-dontwarn retrofit2.Platform$Java8 
-keepattributes Signature 
-keepattributes Exceptions 

# exclusions for RxJava 
-keepclassmembers class rx.internal.util.unsafe.*ArrayQueue*Field* { 
    long producerIndex; 
    long consumerIndex; 
} 
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueProducerNodeRef { 
    rx.internal.util.atomic.LinkedQueueNode producerNode; 
} 
-keepclassmembers class rx.internal.util.unsafe.BaseLinkedQueueConsumerNodeRef { 
    rx.internal.util.atomic.LinkedQueueNode consumerNode; 
} 
-dontwarn sun.misc.Unsafe 

いけない」あなたは、いくつかの除外を追加する必要が

release { 
    minifyEnabled true 
    proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
} 
+0

これを追加した後も、同じ警告と例外が発生します – exceptionnotgood

+0

リリースビルドに正しい行を追加しましたか?正しいファイルを編集しましたか? – MatPag

+0

私はそれをアプリケーションのproguard-rules.proに追加しました。パスはapp/proguard-rules.proです。そして、署名されたapkは再びこれらのエラーを返します。 – exceptionnotgood

関連する問題