我的安卓apk大约是22MB,即使我没用过重的东西。在分析了apk文件后,我发现了一个目录"lib“,其中包含一个用于不同架构的文件名"libclasifier_jni.so”,我不确定它来自哪里。下面是相同的屏幕截图

你能告诉我这里漏掉了什么吗?
下面是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'发布于 2018-10-26 14:31:56
安卓apk中的libclasifier_jni.so是什么?
您已经使用了包含这些SO文件的Firebase Vision图像库。
compile 'com.google.firebase:firebase-ml-vision-image-label-model:15.0.0'我的安卓apk大约是22MB
如果您在应用程序中使用Fragment Vision库,则不能通过任何gradle配置从apk中排除这些ndk文件。
什么是解决方案?
尽管您应该构建单个应用程序开发工具包来尽可能支持所有目标设备,但由于支持多屏幕密度或应用程序二进制接口(ABI)所需的文件,这可能会导致非常大的应用程序开发工具包。减小APK大小的一种方法是创建多个APK,其中包含特定屏幕密度或ABI的文件。
Play store支持拆分apk,可以为multiple cpu ABI制作多个apk。你的应用中有4 SO files。每个都有3-4MB的大小。因此,如果您使用拆分APK,那么不必要的12MB将在每个APK中减少。
2. Include only armeabi-v7a and arm64-v8a
让我告诉您有关ABI百分比静态的有用信息。如果您并不真正关心所有的ABI,那么可以包含两个ABI ndk。早些时候,我发布了一个详细的静态,它将帮助您更多地了解ABI百分比。
因此,如果你包括armeabi-v7a arm64-v8a 和架构,那么你覆盖了99%的安卓设备。
这就是在APK中只包含这两个ABI的方法。
buildTypes {
release {
ndk {
abiFilters "arm64-v8a", "armeabi-v7a"
}
}

This blog将帮助您为多个APK和ABI filter配置gradle,并更好地了解ABI管理。此外,我必须说,Google's Android page有你需要的完美信息。
发布于 2018-10-25 14:01:01
它是编译后的本地库,并与您的apk一起附加。检查您的cmake脚本或ndk Android.mk文件。如果你不确定它是从哪里来的,那么你也可以从不同架构的apk中排除它。在你的gradle里面写下以下几行
android{
packagingOptions {
exclude 'lib/arm64-v8a/libclasifier_jni.so'
exclude 'lib/armeabi/libclasifier_jni.so'
exclude 'lib/armeabi-v7a/libclasifier_jni.so'
exclude 'lib/mips/libclasifier_jni.so'
exclude 'lib/mips64/libclasifier_jni.so'
exclude 'lib/x86/libclasifier_jni.so'
exclude 'lib/x86_64/libclasifier_jni.so'
}
}发布于 2018-10-26 05:42:26
这个特定的库来自这个依赖项:
compile 'com.google.firebase:firebase-ml-vision-image-label-model:15.0.0'您可以转到工件link,下载aar并解压缩。您将看到如下图片所示的内容:

https://stackoverflow.com/questions/52905029
复制相似问题