| Summary: | Add @Keep to JNI methods to preserve them during proguard obfuscate/shrink | ||
|---|---|---|---|
| Product: | SDL | Reporter: | Anthony @ POW Games <ant> |
| Component: | *don't know* | Assignee: | Ryan C. Gordon <icculus> |
| Status: | WAITING --- | QA Contact: | Sam Lantinga <slouken> |
| Severity: | enhancement | ||
| Priority: | P2 | CC: | sylvain.becker |
| Version: | HG 2.0 | ||
| Hardware: | All | ||
| OS: | Android (All) | ||
Another alternative is to list every JNI in proguard-rules.pro, but there are a lot of them and it'd be something more to manage (and maybe forget to update). Can you provide a tested patch? I'd like to add that for 2.0.13. Are there any build environment dependencies? Thanks! I wonder whether adding "import android.support.annotation.Keep;" would increase size. Does it need to add some gradle dependency ? Do you have an example of a proguard line to keep the method ? |
At present, the only way to build a successful APK with proguard is to add the following line to the rules: -keep public class org.libsdl.app.** { public *; } This works, but leaves the entire Android SDL Java code unoptimised. I've found the @Keep keyword (import android.support.annotation.Keep;) works really well to preserve the methods for JNI. If we add them to all the JNI methods, it should allow us to run a full proguard optimization. Not vital - but very useful for developers wanting to reduce their APK size.