1

I am trying to get a set of proguard rules to compile my application with proguard and I can't solve an Issue with 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"

I have tried to use the specified proguard rules from the Facebook-Conceal repository in Github and also the recommendations from the forum. Nothing seems to work. And my custom rules don't work neither

# 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 Answers1

0

It seems that the problem was my environment, after restarting Android Studio twice and clean up everything. it works

  • you'd better not to use `keep` a lot. – c-an Jul 05 '19 at 13:20
  • can you share your pro-guard rules for Facebook conceal because I am getting the same issue JNI GetFieldID called with pending exception java.lang.ClassNotFoundException: Didn't find class "com.facebook.jni.Countable". I have used your rules also and also restarted Android Studio /Invalidated cache etc but still its not working. Can you share your proguard rules? – Nouman Bhatti Sep 29 '21 at 12:58