我能够构建我的react-native应用程序的调试版本。但是,当我尝试构建发行版apk时,出现以下错误:
任务':blelibrary:verifyReleaseResources'的执行失败。
java.util.concurrent.ExecutionException:com.android.builder.internal.aapt.v2.Aapt2Exception:Android资源 链接失败输出: /Users/someguy/projects/third/someapp/android/blelibrary/build/intermediates/res/merged/release/values-v26/values-v26.xml:7: 错误:找不到资源android:attr / colorError。
其后是一堆看起来像这样的消息:
命令: /Users/someguy/.gradle/caches/transforms-1/files-1.1/aapt2-3.5.0-alpha03-5252756-osx.jar/8bd335ec556ebe5abcc696b2317758fe/aapt2-3.5.0-alpha03-5252756-osx/aapt2 链接-I \ /Users/someguy/Library/Android/sdk/platforms/android-24/android.jar \ --manifest \
app build gradle看起来像这样
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.oliveapp"
minSdkVersion 19
targetSdkVersion 28
multiDexEnabled true
versionCode 35
versionName "1.3.5"
ndk {
abiFilters "armeabi-v7a", "x86"
}
packagingOptions {
exclude "lib/arm64-v8a/libgnustl_shared.so"
}
externalNativeBuild {
cmake {
arguments '-DANDROID_STL=c++_static'
}
}
}
signingConfigs {
release {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
debug {
debuggable true
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
def versionCodes = ["armeabi-v7a":1, "x86":2]
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
}
}
}
externalNativeBuild {
cmake {
path 'CMakeLists.txt'
}
}
dexOptions {
jumboMode true
}
}
dependencies {
implementation project(':react-native-i18n')
implementation project(':react-native-svg')
implementation project(':react-native-extra-dimensions-android')
implementation project(':react-native-google-analytics-bridge')
implementation project(':react-native-splash-screen')
implementation project(':react-native-image-picker')
implementation project(':react-native-spinkit')
implementation project(':react-native-fbsdk')
implementation project(':react-native-picker')
implementation 'cn.aigestudio.wheelpicker:WheelPicker:1.1.2'
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'com.facebook.react:react-native:+'
// From node_modules
implementation 'com.facebook.fresco:fresco:2.0.0'
implementation 'com.facebook.fresco:animated-gif:2.0.0'
implementation project(':blelibrary')
implementation project(':gaialibrary')
implementation project(':vmupgradelibrary')
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation project(':react-native-connectivity-status')
implementation('com.google.android.gms:play-services-basement:17.0.0')
implementation('com.google.android.gms:play-services-base:17.0.0')
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.legacy:legacy-support-core-utils:1.0.0'
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation("androidx.annotation:annotation:1.1.0")
implementation("androidx.appcompat:appcompat:1.1.0-rc01")
implementation("androidx.vectordrawable:vectordrawable-animated:1.1.0-rc01")
implementation("androidx.fragment:fragment:1.1.0-rc01")
implementation("androidx.vectordrawable:vectordrawable:1.1.0-rc01")
implementation("androidx.lifecycle:lifecycle-viewmodel:2.1.0-rc01")
implementation("androidx.core:core:1.1.0-rc01")
implementation("androidx.lifecycle:lifecycle-runtime:2.1.0-rc01")
implementation("androidx.arch.core:core-common:2.1.0-rc01")
implementation("androidx.lifecycle:lifecycle-common:2.1.0-rc01")
implementation("androidx.versionedparcelable:versionedparcelable:1.1.0-rc01")
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
repositories {
}
buildscript {
repositories {
maven { url 'https://github.com/500px/500px-android-blur/raw/master/releases/' }
google()
}
dependencies {
}
}
// apply plugin: 'com.google.gms.google-services'
运行./gradlew assembleRelease --info之后 我看到了此消息:
> > Task :app:externalNativeBuildRelease Task ':app:externalNativeBuildRelease' is not up-to-date because: Task
> has not declared any outputs. externalNativeBuildRelease: starting
> build externalNativeBuildRelease: reading expected JSONs
> externalNativeBuildRelease: done reading expected JSONs
> externalNativeBuildRelease: executing build commands for targets that
> produce .so files or executables externalNativeBuildRelease: evaluate
> miniconfig externalNativeBuildRelease: evaluate library
> lib_someappfitting-Release-armeabi-v7a externalNativeBuildRelease: not
> building target lib_someappfitting because there was no build command
> for it externalNativeBuildRelease: evaluate library
> someappfittingjni-Release-armeabi-v7a externalNativeBuildRelease:
> building target library someappfittingjni because no targets are
> specified. externalNativeBuildRelease: about to build
> /Users/someguy/Library/Android/sdk/cmake/3.6.4111459/bin/cmake --build
> /Users/someguy/projects/third/someapp-app/android/app/.externalNativeBuild/cmake/release/armeabi-v7a
> --target someappfittingjni externalNativeBuildRelease: evaluate miniconfig externalNativeBuildRelease: evaluate library
> lib_someappfitting-Release-x86 externalNativeBuildRelease: not
> building target lib_someappfitting because there was no build command
> for it externalNativeBuildRelease: evaluate library
> someappfittingjni-Release-x86 externalNativeBuildRelease: building
> target library someappfittingjni because no targets are specified.
> externalNativeBuildRelease: about to build
> /Users/someguy/Library/Android/sdk/cmake/3.6.4111459/bin/cmake --build
> /Users/someguy/projects/third/someapp-app/android/app/.externalNativeBuild/cmake/release/x86
> --target someappfittingjni Build someappfittingjni x86 externalNativeBuildRelease: Executable :
> /Users/someguy/Library/Android/sdk/cmake/3.6.4111459/bin/cmake
> arguments :
> --build /Users/someguy/projects/third/someapp-app/android/app/.externalNativeBuild/cmake/release/x86
> --target someappfittingjni
答案 0 :(得分:0)
将以下内容添加到android build.gradle:
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 28 // have to match with build.gradle and app/build.gradle ones
buildToolsVersion '28.0.3' // have to match with build.gradle and app/build.gradle ones
variantFilter { variant ->
def names = variant.flavors*.name
// To check for a certain build type, use variant.buildType.name == "<buildType>"
if (names.contains("reactNative51") || names.contains("reactNative55") || names.contains("reactNative56")) {
// Gradle ignores any variants that satisfy the conditions above.
setIgnore(true)
}
}
}
}
}
}
查看此page以获得更多详细信息