Ошибка transformClassesAndResourcesWithProguardForRelease в Android

Привет, я изо всех сил пытаюсь создать релизную версию для своего проекта. Я пробовал много вещей на Progaurd через помощь SO / Google, но я все еще не могу создать версию выпуска.

Может ли кто-нибудь помочь мне с этим? Я всегда получаю эту проблему:

Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForRelease'.
> java.io.IOException: Please correct the above warnings first.

Вот полная подробная ошибка: http://justpaste.it/perror извините, мне пришлось поставить ссылку, потому что это огромный.

Вот зависимости:

//compile fileTree(dir: 'libs', include: ['*.jar'])
 testCompile 'junit:junit:4.12'
 compile 'com.android.support:appcompat-v7:23.1.1'
 compile 'com.android.support:design:23.1.1'
 compile 'com.rengwuxian.materialedittext:library:2.1.4'
 compile 'com.squareup.picasso:picasso:2.5.2'
 compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.4'
 compile 'org.apache.httpcomponents:httpcore:4.4.1'
 compile 'com.squareup.retrofit:retrofit:1.9.0'
 compile 'com.loopj.android:android-async-http:1.4.8'
 compile 'com.android.support:cardview-v7:23.1.1'
 compile 'com.android.support:recyclerview-v7:23.1.1'
 compile project(':pageIndicator')
 compile 'com.github.neopixl:PixlUI:v1.0.6'
 compile 'com.github.bumptech.glide:glide:3.6.1'

Мой файл progaurd:

# You can edit the include path and order by changing the ProGuard
# include property in project.properties.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
-dontwarn com.google.code.**
-dontwarn  org.apache.**
-dontwarn  jp.wasabeef.recyclerview.**
-dontwarn  com.nostra13.universalimageloader.**
-dontwarn  org.acra.** 

#wasabeef recyclerview
-keep class jp.wasabeef.recyclerview.** { *; }
-keepattributes Signature
#HTTP Legacy
-keep class org.apache.** { *; }
-keepattributes Signature
#Universal Image Loader
-keep class com.nostra13.universalimageloader.** { *; }
-keepattributes Signature
#Acra
-keep class org.acra.**  { *; }
-keepattributes Signature
#Support libraries
-keep class com.android.** { *; }
-keepattributes Signature

# Keep the annotations
-keepattributes *Annotation*
-allowaccessmodification
-keepattributes *Annotation*
-renamesourcefileattribute SourceFile
-keepattributes SourceFile,LineNumberTable
-repackageclasses ''

-dontnote com.android.vending.licensing.ILicensingService

# Explicitly preserve all serialization members. The Serializable interface
# is only a marker interface, so it wouldn't save them.
-keepclassmembers class * implements java.io.Serializable {
    static final long serialVersionUID;
    private static final java.io.ObjectStreamField[] serialPersistentFields;
    private void writeObject(java.io.ObjectOutputStream);
    private void readObject(java.io.ObjectInputStream);
    java.lang.Object writeReplace();
    java.lang.Object readResolve();
}

# Preserve all native method names and the names of their classes.
-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembernames class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembernames class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

# Preserve static fields of inner classes of R classes that might be accessed
# through introspection.
-keepclassmembers class **.R$* {
  public static <fields>;
}

# Preserve the special static methods that are required in all enumeration classes.
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep public class * {
    public protected *;
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}


-keep class com.splunk.** { *; }
-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.app.backup.BackupAgentHelper
-keep public class * extends android.preference.Preference
-keep public class com.android.vending.licensing.ILicensingService
-keepclasseswithmembernames class * {
    native <methods>;
}
-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.app.Activity {
   public void *(android.view.View);
}
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}
-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

-keep class com.splunk.** { *; }
-dontwarn rx.**

-dontwarn okio.**

-dontwarn com.squareup.okhttp.**
-keep class com.squareup.okhttp.** { *; }
-keep interface com.squareup.okhttp.** { *; }

-keep class org.apache.http.** { *; }
-dontwarn org.apache.http.**
-dontwarn android.net.**

-dontwarn retrofit.**
-dontwarn retrofit.appengine.UrlFetchClient
-keep class retrofit.** { *; }
-keepclasseswithmembers class * {
    @retrofit.http.* <methods>;
}

-keepattributes Signature
-keepattributes *Annotation*

-keep class sun.misc.Unsafe { *; }
#your package path where your gson models are stored
-keep class com.ylg.others.** { *; }

person Sanjana Nair    schedule 30.11.2015    source источник
comment
похоже на проблему с файлом gradle   -  person    schedule 30.11.2015
comment
Известно, что такая проблема возникает, когда версия SDK, версия gradle и версия инструментов сборки несовместимы: title="errorexecution failed for task androidtransformclassesandresourceswithprogua"> stackoverflow.com/questions/33877134/ Я столкнулся с той же проблемой и не смог ее решить. Я временно исправил это, установив minifyEnabled на false.   -  person Vedavyas Bhat    schedule 22.12.2015
comment
@VedavyasBhat: если мы это сделаем, мой код не запутается, верно?   -  person Sanjana Nair    schedule 24.12.2015
comment
@SanjanaNair ты нашел решение этой проблемы?   -  person Pandiyan Muthu    schedule 24.05.2016
comment
@MuthuPandiyan: Нет. У вас был шанс получить его?   -  person Sanjana Nair    schedule 20.06.2016
comment
@SanjanaNair Пожалуйста, ознакомьтесь с моим ответом   -  person    schedule 17.10.2017


Ответы (4)


В файле ProGuard добавьте:

-ignorewarnings

Нравится:

# Add project specific ProGuard rules here.
# By default, the flags in this file are appended to flags specified
# in D:\Softwares\Developing\Android\sdk/tools/proguard/proguard-android.txt
# You can edit the include path and order by changing the proguardFiles
# directive in build.gradle.
#
# For more details, see
#   http://developer.android.com/guide/developing/tools/proguard.html

# Add any project specific keep options here:

# If your project uses WebView with JS, uncomment the following
# and specify the fully qualified class name to the JavaScript interface
# class:
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
#   public *;
#}

# Uncomment this to preserve the line number information for
# debugging stack traces.
#-keepattributes SourceFile,LineNumberTable

# If you keep the line number information, uncomment this to
# hide the original source file name.
#-renamesourcefileattribute SourceFile


-ignorewarnings

Вам не нужно указывать какой-либо пакет, такой как com.viewpagerindicator.** , это отключит все предупреждения, а Gradle Console просто скажет:

......
Warning: there were 4 unresolved references to classes or interfaces.
         You may need to add missing library jars or update their versions.
         If your code works fine without the missing classes, you can suppress
         the warnings with '-dontwarn' options.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedclass)
Warning: there were 2 unresolved references to library class members.
         You probably need to update the library versions.
         (http://proguard.sourceforge.net/manual/troubleshooting.html#unresolvedlibraryclassmember)

Note: you're ignoring all warnings! 
Ignoring unused library classes...
  Original number of library classes: 4237
  Final number of library classes:    1317
Printing kept classes, fields, and methods...
Shrinking...
......
person Community    schedule 17.10.2017

В файле ProGuard добавьте:

-dontwarn com.viewpagerindicator.**

Если вы откроете предоставленную вами ссылку и выполните поиск «Предупреждение» примерно на две трети вниз, вы увидите сообщение:

Warning:com.viewpagerindicator.LinePageIndicator: can't find referenced method 'float ceil(float)' in library class android.util.FloatMath

Если есть какие-либо предупреждения, ProGuard остановится и попросит вас сначала исправить их, или, если ваш код работает, вы можете игнорировать их с помощью dontwarn.

Обновление от 01.05.2017

Если в предупреждении указано in program class, вероятно, ваши скомпилированные файлы классов несовместимы, попробуйте удалить их все и перестроить проект.

Если в предупреждении указано in library class, ваши скомпилированные файлы классов несовместимы с библиотеками. Попробуйте перекомпилировать файлы классов или обновить библиотеки до согласованных версий.

Вы можете прочитать больше здесь.

person Daniel Stanley    schedule 03.08.2016
comment
Не произойдет ли сбой приложения, если оно попытается использовать метод, который не может быть найден? - person OneCricketeer; 03.08.2016
comment
^ Я отчаянно пытаюсь понять, почему ProGuard обнаруживает эти отсутствующие ссылки, а обычная сборка — нет, и насколько они опасны. - person David Lord; 04.01.2017

Что мне помогло, так это обновить все зависимости до последней версии.

person beretis    schedule 09.11.2017

В моем случае файл proguard был полностью проигнорирован, потому что проект состоял из нескольких модулей. Согласно этому ответу, решение состояло в том, чтобы установить следующее в градации модуля, вызывающего проблему:

defaultConfig {
    consumerProguardFiles 'proguard-rules.txt'
}

Кажется, это включает в себя proguard модуля в proguard приложения. Теперь мои dontwarn утверждения принимаются во внимание.

person Raslanove    schedule 29.05.2018