适用于Facebook Conceal v2.0.2的Proguard规则

时间:2019-07-05 12:02:04

标签: android kotlin proguard facebook-conceal

我正在尝试获取一组proguard规则,以使用proguard编译我的应用程序,但无法解决Facebook-Conceal的问题

java_vm_ext.cc:504] JNI DETECTED ERROR IN APPLICATION: JNI GetFieldID called with pending exception java.lang.ClassNotFoundException: Didn't find class "com.facebook.jni.Countable"

我尝试使用Github中Facebook-Conceal存储库中指定的proguard规则以及论坛中的建议。似乎没有任何作用。而且我的自定义规则也不起作用

# Facebook Conceal
# from main project

# Keep our interfaces so they can be used by other ProGuard rules.
# See http://sourceforge.net/p/proguard/bugs/466/
-keep,allowobfuscation @interface com.facebook.crypto.proguard.annotations.DoNotStrip
-keep,allowobfuscation @interface com.facebook.crypto.proguard.annotations.KeepGettersAndSetters

# Do not strip any method/class that is annotated with @DoNotStrip
-keep @com.facebook.crypto.proguard.annotations.DoNotStrip class *
-keepclassmembers class * {
    @com.facebook.crypto.proguard.annotations.DoNotStrip *;
}

-keepclassmembers @com.facebook.crypto.proguard.annotations.KeepGettersAndSetters class * {
  void set*(***);
  *** get*();
}

# from first-party/fbjni/java/com/facebook/jni/fbjni.pro

# For common use cases for the hybrid pattern, keep symbols which may
# be referenced only from C++.

-keepclassmembers class * {
    com.facebook.jni.HybridData *;
    <init>(com.facebook.jni.HybridData);
}

-keepclasseswithmembers class * {
    com.facebook.jni.HybridData *;
}


# from first-party/proguard/annotations/proguard_annotations.pro

# Keep our interfaces so they can be used by other ProGuard rules.
# See http://sourceforge.net/p/proguard/bugs/466/
-keep,allowobfuscation @interface com.facebook.proguard.annotations.DoNotStrip
-keep,allowobfuscation @interface com.facebook.proguard.annotations.KeepGettersAndSetters

# Do not strip any method/class that is annotated with @DoNotStrip
-keep @com.facebook.proguard.annotations.DoNotStrip class *
-keepclassmembers class * {
    @com.facebook.proguard.annotations.DoNotStrip *;
}

-keepclassmembers @com.facebook.proguard.annotations.KeepGettersAndSetters class * {
  void set*(***);
  *** get*();
}


-keep class com.facebook.crypto.** { *; }
-keep class com.facebook.jni.** { *; }
-keepclassmembers class com.facebook.jni.** {*;}
-keepclassmembers class com.facebook.cipher.jni.** { *; }
-keepclasseswithmembers class * {
    native <methods>;
}

#just add this, everything is fine..
-dontwarn com.facebook.**
java_vm_ext.cc:504] JNI DETECTED ERROR IN APPLICATION: JNI GetFieldID called with pending exception java.lang.ClassNotFoundException: Didn't find class "com.facebook.jni.Countable"

1 个答案:

答案 0 :(得分:0)

似乎是我的环境出现了问题,两次重启Android Studio并清理了所有内容之后。它有效