Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Android Proguard Rules #61

Open
andredoubleu opened this issue Sep 27, 2023 · 1 comment
Open

Android Proguard Rules #61

andredoubleu opened this issue Sep 27, 2023 · 1 comment

Comments

@andredoubleu
Copy link

andredoubleu commented Sep 27, 2023

Hi, I've found that when I include the SourceAFIS SDK in my Android application, and then compile a release version of my app, the SourceAFIS SDK is adding about 12 MB to my .apk's file size. I opened up my .apk file and took a look inside, and it looks like all 12 MB are coming from new Java classes (in classes2.dex, classes3.dex, and classes4.dex). It this expected? I've just never seen an SDK add so many classes to my project before. Of course I understand that every SDK has dependencies, which in turn have dependencies of their own, but I have 'minifyEnabled=true', which enables code-shrinking, obfuscation, and optimization, and this is usually enough to remove all of the unused classes.

Next I thought maybe I could improve the code-shrinking with Proguard rules. Do you have any recommended Proguard rules when including the SDK in an Android application?

I'm including the SDK in my Android app's build.gradle file like this:

dependencies {
    implementation "com.machinezoo.sourceafis:sourceafis:3.18.0"
}

And these are some rules I've set in my build.gradle file:

buildTypes {
    release {
        minifyEnabled true // Code shrinking, obfuscation, and optimization.
        shrinkResources true // Resource shrinking.
        debuggable false // The apk can not be attached to a debugger.
        signingConfig signingConfigs.release
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
    debug {
        debuggable true
        signingConfig signingConfigs.debug
        proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
    }
}

Thanks in advance, and thanks for making this great SDK.

@robertvazan
Copy link
Owner

My guess is it's mostly fastutil's primitive collections. Only a few of those classes will be actually loaded at runtime. Minification tools (no idea what's available for Android) should be able to filter out the unused classes.

Re Proguard, no, I do not have any experience with that tool.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants