【问题标题】:Proguard rules for Facebook Conceal v2.0.2Facebook Conceal v2.0.2 的 Proguard 规则
【发布时间】:2019-07-05 12:02:04
【问题描述】:

我正在尝试获取一组 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"

【问题讨论】:

    标签: android kotlin proguard facebook-conceal


    【解决方案1】:

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

    【讨论】:

    • 你最好不要经常使用keep
    • 你能分享你的 Facebook 隐藏保护规则吗,因为我遇到了同样的问题 JNI GetFieldID 调用了挂起的异常 java.lang.ClassNotFoundException: 没有找到类“com.facebook.jni。可数”。我也使用了您的规则,还重新启动了 Android Studio /Invalidated 缓存等,但仍然无法正常工作。你能分享你的proguard规则吗?
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2022-11-14
    • 2020-11-16
    • 1970-01-01
    • 2019-08-28
    • 2019-04-02
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多