Первый раз, когда я сделал подписанный 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
, но проблемы с retrofit2 остались.
Я тоже пытался добавить -dontwarn retrofit2.Plataform$Java8.**
но теперь моя сборка не заканчивается (собирается уже больше 30 минут на I7 с 16gb ram).
Мой 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'
My 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.**
Как это исправить?
-downtar
- person LeonardoSibela   schedule 23.12.2016-keep class org.codehaus.mojo.animal_sniffer.** { *; }
, так как он не может найти этот класс - person Shark   schedule 26.12.2016-keep class
, и-dontwarn
? - person LeonardoSibela   schedule 26.12.2016-keep class
, так как-dontwarn
используется только для подавления предупреждений, фактически не влияя на процесс обфускации/минимизации. Используйте-dontwarn
только тогда, когда проект собирается/запускается/работает, но с большим количеством предупреждений от некоторых имен пакетов, но в вашем случае класс не может быть найден, поэтому просто попробуйте с-keep class
, и если вы получаете много предупреждений, но это работает, не стесняйтесь добавьте также-dontwarn
. Поскольку это не работает,-dontwarn
вам не сильно поможет. - person Shark   schedule 26.12.2016org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
, который не упоминается в ваших заявлениях-keep class
... Он не является частью имен пакетов okio или retrofit2, а также android.widget или android.support. - person Shark   schedule 26.12.2016