Proguard removing annotations in Android application Proguard removing annotations in Android application android android

Proguard removing annotations in Android application


I'm also using javacv and here's how my proguard file looks:

## JavaCV-keepattributes *Annotation*, Exceptions, Signature, Deprecated, SourceFile, SourceDir, LineNumberTable, LocalVariableTable, LocalVariableTypeTable, Synthetic, EnclosingMethod, RuntimeVisibleAnnotations, RuntimeInvisibleAnnotations, RuntimeVisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations, AnnotationDefault, InnerClasses-keep class org.bytedeco.javacpp.** {*;}-dontwarn java.awt.**-dontwarn org.bytedeco.javacv.**-dontwarn org.bytedeco.javacpp.**

It may be somewhat excessive, but it is what finally got it working for me. Hope it helps you.

You also don't need to add any extra jar files if you add the following lines to your gradle file:

compile group: 'org.bytedeco.javacpp-presets', name: <module>, version: <module-version>, classifier: <your-platform>

To get the available modules, search for javacpp in jcenter and you'll see them as org.bytedeco.javacv-presets:<module>.

Clicking any of them will enable you to get the version that matches your javacv version. So if you're using javacv 0.11 and wants to add the opencv module, you'll need to use 2.4.11-0.11 version of the javacpp-preset.

Finally, just add the platform of your choice android-arm or android-x86 or both for that matter and you should be good to go.

Finally, as an example, here's the javacv import would look like for opencv and ffmpeg for the arm platform:

compile group: 'org.bytedeco', name: 'javacv', version: '0.11'compile group: 'org.bytedeco.javacpp-presets', name: 'opencv', version: '2.4.11-0.11', classifier: 'android-arm'compile group: 'org.bytedeco.javacpp-presets', name: 'ffmpeg', version: '2.6.1-0.11', classifier: 'android-arm'


Maybe this can help.

-keep @org.bytedeco.javacpp.annotation.Platform public class *-keepclasseswithmembernames class * {    @org.bytedeco.* <fields>;}-keepclasseswithmembernames class * {    @org.bytedeco.* <methods>;}


The following could help:

-keepattributes *Annotation*-keepattributes EnclosingMethod-keep @interface org.bytedeco.javacpp.annotation.*,javax.inject.*