2017-05-23 3 views
4

가 나는 때문에 내 난독 화 - 규칙에 나를 위해 이상한 모양Proguard와 나에게 경고를 많이 제공하고

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

같은 경고를 많이 얻을 오류

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

을 얻고 실패 나는

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

[EDITED] 나는 또한 얻고 경고

같은이 규칙을 추가

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

내가 경고를 무시에 대한 대답 한 후 내 패키지

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

을 유지하기 위해 단검 규칙을

-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 

및 규칙을 추가,이 규칙

-dontwarn com.mypackage.android.** 

그리고 난독 추가 지금은 실패하지 않습니다. 그러나 이러한 모범 사례와이 경고를 무시한 후 깨질 수있는 것이 있는지 확실하지 않습니다.

+0

가능한 복제 [난독 화 지옥 - 참조 클래스를 찾을 수 없습니다 (https://stackoverflow.com/questions/6974231/proguard-hell- cant-find-referenced-class) – user1643723

답변

2

라이브러리 클래스 es.usc.citius.hipster.util.examples.maze.MazeSearch은이 패키지를 포함하지 않는 Android JDK는 아니지만 JDK의 일부인 패키지 java.awt.Point을 참조합니다. Android 환경에서는 사용할 수 없습니다.

+0

고마워요! 나는 편집했다, 나의 질문. 답변에 대한 감사와 나의 의심에 대한 설명. – qbait

2

업데이트

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.graphics) 자신의 그래픽 라이브러리를 가지고는 Java AWT 클래스 대신에 그것을 사용할 수 있습니다. 안드로이드 런타임의 일부

class java.awt.Point

java.awt.* 클래스

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

원래되지 않습니다

여기 java.awt.Toolkit에서 꽤 유용한 의견입니다. 가장 좋은 해결책은이를 참조하는 클래스를 제거하는 것입니다. 바로 경고를 억제 할 것

간단한 솔루션 :

-dontwarn java.awt.** 
+0

고마워요! 나는 편집했다, 나의 질문. 답변에 대한 감사와 나의 의심에 대한 설명. – qbait