gpt4 book ai didi

android - 使用 ABI 拆分启用 externalNativeBuild

转载 作者:可可西里 更新时间:2023-11-01 19:07:38 25 4
gpt4 key购买 nike

我已经从 ndk-build 切换到 cmake 构建系统。但是无法使 APK 拆分功能正常工作。

这是我的应用build.gradle文件

构建的结果只有一个文件 - foo.bar-armeabi-v7a-release-1.5.1.apk
如果我正在为 x86 模拟器构建应用程序,结果是 foo.bar-x86-release-1.5.1.apk

buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

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

android {
compileOptions.encoding = 'ISO-8859-1'
compileSdkVersion CompiledSdkVersion
buildToolsVersion BuildToolsVersion

defaultConfig {
applicationId "foo.bar"
minSdkVersion MinSdkVersion
targetSdkVersion TargetSdkVersion
versionCode VersionCode
versionName VersionName
vectorDrawables.useSupportLibrary = true

externalNativeBuild {
cmake {
cppFlags "-fexceptions", "-std=c++11"
}
}

ndk {
abiFilters "armeabi", "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
}
}

signingConfigs {
release {
storeFile file("..\\release.keystore")
}
}

lintOptions {
checkReleaseBuilds false
abortOnError false
}

buildTypes {
release {
signingConfig signingConfigs.release
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-project.txt'
}
}

splits {
abi {
enable true
reset()
include "armeabi", "armeabi-v7a", "arm64-v8a", "mips", "mips64", "x86", "x86_64"
universalApk true
}
}

project.ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'arm64-v8a': 3, 'mips': 5, 'mips64': 6, 'x86': 8, 'x86_64': 9]
android.applicationVariants.all { variant ->
variant.outputs.each { output ->
output.versionCodeOverride = project.ext.versionCodes.get(output.getFilter(com.android.build.OutputFile.FilterType.ABI), 0) * 1000000 + android.defaultConfig.versionCode
output.outputFile = new File(output.outputFile.parent, output.outputFile.name.replace(".apk", "-${variant.versionName}.apk"))
}
}

externalNativeBuild {
cmake {
path 'src/main/jni/CMakeLists.txt'
}
}
}

crashlytics {
enableNdk false // too many reports for third-party modules
androidNdkOut '.externalNativeBuild/cmake/release'
androidNdkLibsOut 'src/main/libs'
}

dependencies {
compile project(':common-sources')
compile project(':chess-board-library')
compile project(':number-picker')

compile files('libs/kxml2-2.3.0.jar')
compile files('libs/StartADLib-1.0.1.jar')

compile Dependencies.appCompat
compile Dependencies.cardView
compile Dependencies.firebaseAds
compile Dependencies.googleAnalytics
compile Dependencies.googlePlus
compile Dependencies.googleGames

compile(Dependencies.crashlytics) {
transitive = true
}
compile(Dependencies.crashlyticsNdk) {
transitive = true
}
}

apply plugin: 'com.google.gms.google-services'

附言请投票my issue in Google's bug tracker如果您可以重现错误,但找不到解决方案。

最佳答案

看起来这是构建工具中的错误。即使使用旧的 ndk-build,ABI Split 也不起作用。

在研究过程中,我发现了一个很好的解决方法 - 直接从命令行启动构建。

gradlew assembleDebug

gradlew assembleRelease

命令需要从项目的根目录启动。

非常感谢this sudden comment :)

关于android - 使用 ABI 拆分启用 externalNativeBuild,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40215158/

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