This repository has been archived by the owner on Aug 8, 2023. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Keeping just the
getAssetManager
method that is referenced from JNI is enough in this context and would allow obfuscating all other java methods.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we also look up the class from JNI, so it needs to be kept as well
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe that if you keep at least one method/field from the class, the class name is not going to be obfuscated. This allows all other methods that are not accessed from native to be obfuscated then.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
verified in https://github.com/mapbox/mapbox-gl-native/blob/201a53386f9f51cba2113b0a58541370d76c64af/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/Mapbox.java that this doesn't work.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Huh, interesting. It fails because if we're looking up a static method, JNI tries to verify the instance first with:
Caused by: java.lang.NoSuchMethodError: no static method "Lcom/mapbox/mapboxsdk/Mapbox;.hasInstance()Z"
The class is not obfuscated, but this internal, static
hasInstance()
method seems to be? Anyway 🍏There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
we probably could fine tune this with using a specific proguard rule..