2017-05-23 3 views
4

que je reçois l'erreurProguard me donne beaucoup d'avertissements et ne

Error:Execution failed for task ':app:transformClassesAndResourcesWithProguardForDebug'. Job failed, see logs for details

Je reçois beaucoup d'avertissements comme

Warning:es.usc.citius.hipster.util.examples.maze.MazeSearch$Result: can't find referenced class java.awt.Point

qui fait un peu bizarre pour moi parce que dans mes ProGuard règles J'ai ajouté cette règle

-keep public class es.usc.citius.hipster.** { *; } 

[edited] Je suis aussi obtenir des avertissements comme

Warning:com.mypackage.android.dagger.modules.AppModule_ProvideAccelerometerSensorFactory: can't find superclass or interface dagger.internal.Factory

I a ajouté des règles de poignard

-dontwarn dagger.internal.codegen.** 
-keepclassmembers,allowobfuscation class * { 
    @javax.inject.* *; 
    @dagger.* *; 
    <init>(); 
} 

-keep class dagger.* { *; } 
-keep class javax.inject.* { *; } 
-keep class * extends dagger.internal.Binding 
-keep class * extends dagger.internal.ModuleAdapter 
-keep class * extends dagger.internal.StaticInjection 

et règle pour garder mon paquet

-keep public class com.mypackage.android.** { *; } 

Après la réponse d'ignorer les avertissements, j'ai ajouté cette règle

-dontwarn com.mypackage.android.** 

Et proguard n'échoue pas maintenant. Cependant, je ne suis pas sûr si c'est la meilleure pratique et ce qui peut être cassé après avoir ignoré ces avertissements?

+0

double possible de [proguard enfer - ne peut pas trouver la classe référencé] (https://stackoverflow.com/questions/6974231/proguard-hell- cant-find-referenced-class-class) – user1643723

Répondre

2

La classe de bibliothèque es.usc.citius.hipster.util.examples.maze.MazeSearch fait référence à un package java.awt.Point qui fait partie de JDK mais pas de JDK Android, qui ne contient pas ce package. Vous ne pouvez pas l'utiliser dans l'environnement Android.

+0

Merci! J'ai édité, ma question. Je serai reconnaissant pour la réponse et la clarification de mes doutes. – qbait

2

Mise à jour

And proguard doesn't fail now. However, I'm not sure if that the best practice and what can be broken after ignoring these warnings?

Android a ses propres bibliothèques graphiques (par exemple android.graphics), l'utiliser au lieu des Java AWT classes.

est ici un commentaire très utile de java.awt.Toolkit:

WARNING: This is a temporary workaround for a problem in the way the AWT loads native libraries. A number of classes in the AWT package have a native method, initIDs(), which initializes the JNI field and method ids used in the native portion of their implementation. Since the use and storage of these ids is done by the implementation libraries, the implementation of these method is provided by the particular AWT implementations (for example, "Toolkit"s/Peer), such as Motif, Microsoft Windows, or Tiny. The problem is that this means that the native libraries must be loaded by the java.* classes, which do not necessarily know the names of the libraries to load. A better way of doing this would be to provide a separate library which defines java.awt.* initIDs, and exports the relevant symbols out to the implementation libraries. For now, we know it's done by the implementation, and we assume that the name of the library is "awt". -br. If you change loadLibraries(), please add the change to java.awt.image.ColorModel.loadLibraries(). Unfortunately, classes can be loaded in java.awt.image that depend on libawt and there is no way to call Toolkit.loadLibraries() directly. -hung

originale

class java.awt.Point

java.awt.* cours ne font pas partie de l'exécution Android. La meilleure solution serait de supprimer les classes qui les référencent.

solution simple serait de supprimer simplement les avertissements:

-dontwarn java.awt.** 
+0

Merci! J'ai édité, ma question. Je serai reconnaissant pour la réponse et la clarification de mes doutes. – qbait