gpt4 book ai didi

由于 lib 目录,Android APK 文件太大

转载 作者:塔克拉玛干 更新时间:2023-11-02 22:19:34 24 4
gpt4 key购买 nike

我正在构建一个大小约为 4MB APK 文件的 Android 应用程序。从几周前开始,在构建签名应用时,生成的 APK 文件约为 17MB。

在调查了为什么会发生这种情况之后,我发现新的 APK 存档包含 /lib 目录,而该目录在 4MB 大小的旧 APK 中是不存在的。有谁知道为什么这个 lib 目录突然出现在 APK 存档中,有没有办法删除它?

APK 存档中 /lib 目录的结构是:

/lib
/arm64-v8a
/armeabi
/armeabi-v7a
/mips
/x86
/x86_64

我最近更新了Android Studio 到2.0,也升级了gradle。这会是一个问题吗?是否有一些配置参数可以解决这个问题?

我的 gradle 文件如下所示:

buildscript {
repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }

}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0'
classpath 'io.fabric.tools:gradle:1.+'

}
}

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

repositories {
mavenCentral()
maven { url 'https://maven.fabric.io/public' }
flatDir { dirs 'aars' }
}

android {
// when changing this, YOU MUST change C:\AndroidADT\sdk\build-tools\xx.yy.zz\dx.bat to have -> set java_exe=C:\Windows\System32\java.exe
compileSdkVersion 21
buildToolsVersion "21.1.1"

defaultConfig {
minSdkVersion 11
targetSdkVersion 21
}
def homeDir = System.getenv('HOMEDRIVE') + System.getenv('HOMEPATH');

signingConfigs {
cinema {
storeFile = file("keystore\\cinema.keystore.jks")
storePassword = "cinema"
keyAlias = "cinema"
keyPassword = "cinema"
}
dev {
storeFile = file("keystore\\development.keystore.jks")
storePassword = "development"
keyAlias = "development"
keyPassword = "development"
}
}

buildTypes {
debug {
applicationIdSuffix ".debug"
}
cinema {
debuggable false
signingConfig signingConfigs.cinema
jniDebuggable false
applicationIdSuffix ".cinema"
}
dev {
debuggable true
signingConfig signingConfigs.dev
jniDebuggable true
applicationIdSuffix ".dev"
}
}

sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src', 'src-gen']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']

assets.srcDirs = ['assets']
}
debug {
}
dev {
res.srcDirs = ['res_dev']
}
cinema {
res.srcDirs = ['res_cinema']
}
androidTest.setRoot('tests')
}


packagingOptions {
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
}
}

dependencies {
compile 'joda-time:joda-time:2.3'
compile 'com.android.support:support-v4:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.google.android.gms:play-services-plus:8.3.0'
compile 'com.google.android.gms:play-services-auth:8.3.0'
compile 'com.google.android.gms:play-services-gcm:8.3.0'
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
compile 'com.markupartist.android.widget:pulltorefresh:1.0@aar'
compile 'com.paypal.sdk:paypal-android-sdk:2.13.3'
compile('com.crashlytics.sdk.android:crashlytics:2.2.0@aar') {
transitive = true;
}
compile files('libs/gson-2.2.4.jar')
compile files('libs/twitter4j-core-4.0.2.jar')
compile files('libs/core-3.1.0.jar')
compile files('libs/estimote-sdk-preview.jar')

compile files('libs/commons-codec-1.10.jar')
compile files('libs/commons-lang-2.6.jar')
compile files('libs/FastPaySDK_pro.jar')
}

最佳答案

试试这个从发布版本中排除 SO 文件

android {
buildTypes {
release {
ndk {
abiFilters "armeabi-v7a", "armeabi" // includes ARM SO files only, so no x86 SO file
}
}
}
}

没有测试过,也许你可以试试:abiFilters ""排除所有.SO文件

关于由于 lib 目录,Android APK 文件太大,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/36567235/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com