Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

What is libclasifier_jni.so in android's apk?

My android apk is around 22MB, even when i have not used anything heavy. After analyzing the apk file i found a directory "lib" which contains a file name "libclasifier_jni.so" for different architectures, I am not sure where it is coming from. below is screenshot for sameenter image description here

Could you please tell me what i'm missing here?

Below is build.gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 27
    defaultConfig {
        applicationId "com.pixyfisocial"
        minSdkVersion 15
        targetSdkVersion 27
        versionCode 24
        versionName '5.0.0'
        multiDexEnabled true
        testApplicationId "com.pixyfisocial.screens.presenters"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        abortOnError false
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/license.txt'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/NOTICE.txt'
        exclude 'META-INF/notice.txt'
        exclude 'META-INF/ASL2.0'
    }
    productFlavors {
    }
}

configurations {
    all {
        exclude module: 'json'
        exclude module: 'commons-logging'
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    testImplementation 'junit:junit:4.12'
    testCompile 'org.powermock:powermock-api-mockito2:1.7.4'
    // https://mvnrepository.com/artifact/org.powermock/powermock-module-junit4
    testCompile 'org.powermock:powermock-module-junit4:1.7.4'
    // https://mvnrepository.com/artifact/org.mockito/mockito-core
    testCompile 'org.mockito:mockito-core:2.8.9'
    implementation 'de.hdodenhof:circleimageview:2.2.0'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
    compile 'com.android.support:appcompat-v7:27.1.1'
    compile 'com.android.support:recyclerview-v7:27.1.1'
    compile 'com.android.support:cardview-v7:27.1.1'
    compile 'com.android.support:design:27.1.1'
    implementation 'com.facebook.android:facebook-android-sdk:4.33.0'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.github.clans:fab:1.6.2'
    compile 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
    implementation 'com.google.firebase:firebase-core:16.0.0'
    implementation 'com.google.firebase:firebase-messaging:17.1.0'
    compile 'com.facebook.android:account-kit-sdk:4.+'
    compile 'com.android.support:support-v4:27.1.1'
    compile 'com.google.code.gson:gson:2.8.2'
    compile 'com.google.firebase:firebase-appindexing:15.0.1'
    compile 'com.google.firebase:firebase-auth:16.0.1'
    compile 'com.google.android.gms:play-services-auth:15.0.1'
    compile 'com.google.firebase:firebase-invites:16.0.0'
    compile 'com.android.support:customtabs:27.1.1'
    compile 'com.google.firebase:firebase-ml-vision:16.0.0'
    compile 'com.google.firebase:firebase-ml-vision-image-label-model:15.0.0'
    compile 'com.github.greenfrvr:hashtag-view:1.3.1'
    implementation 'com.android.support.constraint:constraint-layout:1.1.1'
    implementation project(':pixyfi-data')
    implementation project(':pixyfi-services')
    implementation project(':utility')
}
apply plugin: 'com.google.gms.google-services'
like image 838
Kumar Gaurav Avatar asked Oct 20 '18 11:10

Kumar Gaurav


People also ask

What is a debug APK?

A debug version of your app is meant to be optimized for that- even if that means adding extra logs (from the system or from your app), systems to catch errors, data tracking and management, everything you can access from the debug menu, and much more.

What is Lib folder in APK?

lib — directory with compiled native libraries used by your app. Contains multiple directories — one for each supported CPU architecture (ABI). META-INF — directory with APK metadata, such as its signature. AndroidManifest.

How do I find APK signature?

The apksigner tool, available in revision 24.0. 3 and higher of the Android SDK Build Tools, lets you sign APKs and confirm that an APK's signature will be verified successfully on all versions of the Android platform supported by that APK.


1 Answers

What is libclasifier_jni.so in android's apk?

You have used Firebase Vision Image library, that contains these SO files.

compile 'com.google.firebase:firebase-ml-vision-image-label-model:15.0.0'

My android apk is around 22MB

You must not exclude those ndk files from apk via any gradle configuration, if you are using Fragment Vision library in your app.

What is solution?

1. Build multiple APKs

Although you should build a single APK to support all your target devices whenever possible, that might result in a very large APK due to files needed to support multiple screen densities or Application Binary Interfaces (ABIs). One way to reduce the size of your APK is to create multiple APKs that contain files for specific screen densities or ABIs.

Play store supports splitting apk, in which you can make multiple apk for multiple cpu ABI. There are 4 SO files in your app. Each is 3-4MB of size. So if you use split APK then unnecessary 12MB will be reduced in every APK.

2. Include only armeabi-v7a and arm64-v8a

Let me tell you useful information about ABI percentage statics. If you don't really care about all ABIs, then you can include two ABI ndks. Earlier days I posted an detailed statics Answer Here, which will help you more understanding ABI percentage.

  • armeabi-v7a (required — most popular architecture nowadays)
  • arm64-v8a (required — newer version of armeabi-v7a)
  • x86 (optional, very limited number of devices, like Asus Zenfone 2, Genymotion/ Android emulator)
  • x86_64 (optional, very limited number of devices, like Asus Zenfone 2, Genymotion/ Android emulator)

So if you include armeabi-v7a and arm64-v8a architectures then you cover up 99% of Android devices.

This is how you can include only these two ABIs in your APK.

buildTypes {
    release {
        ndk {
            abiFilters "arm64-v8a", "armeabi-v7a"
        }
    }

image

This blog will help you in configuring gradle for multiple APK and ABI filter and understand ABI management better. Also I must say Google's Android page has perfect information that you need.

like image 77
Khemraj Sharma Avatar answered Sep 28 '22 04:09

Khemraj Sharma