为了减小应用的大小,我们在android/app/build.gradle中进行了以下更改:
def enableSeparateBuildPerCPUArchitecture = false => true
def enableProguardInReleaseBuilds = false => true
但是当尝试生成签名的apk时,我们遇到了这个错误:
* What went wrong:
执行任务“:app:packageRelease”失败。
执行com.android.build.gradle.internal.tasks.Workers$动作外观java.io时发生错误。IOException:无法创建路径-项目/android/应用程序/构建/输出/apk/版本/app1.0.5(65)-版本.apk'
我们尝试添加
org.gradle.jvmargs=-Xmx4608m
到gradle.properties,但它不起作用。
我们在android/build.gradle中有以下内容
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 30
targetSdkVersion = 30
firebaseMessagingVersion = "+"
googlePlayServicesVersion = "+"
playServicesVersion = "17.0.0"
androidMapsUtilsVersion = "2.2.5"
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:4.0.1")
classpath 'com.google.gms:google-services:4.3.8'
}
}
以及以下内容在android/app/build.gradle中
esplits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
applicationVariants.all { variant ->
variant.outputs.all {
outputFileName = "tcard${variant.versionName}(${variant.versionCode})-${variant.name}.apk"
}
}
}
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// https://developer.android.com/studio/build/configure-apk-splits.html
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
packagingOptions {
pickFirst 'lib/x86/libc++_shared.so'
pickFirst 'lib/x86_64/libjsc.so'
pickFirst 'lib/arm64-v8a/libjsc.so'
pickFirst 'lib/arm64-v8a/libc++_shared.so'
pickFirst 'lib/x86_64/libc++_shared.so'
pickFirst 'lib/armeabi-v7a/libc++_shared.so'
}
1条答案
按热度按时间zpf6vheq1#
可能是您在输出文件名中添加的括号使编译器感到困惑,或者您运行它的系统不允许将括号作为路径的有效字符。
因此,我会首先尝试更改文件名(可能使用破折号代替括号?),然后再做其他事情。