[英]Faild to release react-native apk on gradlew assembleRelease
Hello guys, this is becoming a serious problem for me.大家好,这对我来说是一个严重的问题。 I have been trying to create release apk file from last 2 weeks but I'm unable to do that due to this issue.
我一直在尝试从过去 2 周开始创建发布 apk 文件,但由于这个问题我无法做到这一点。 It works fine on creating bundle ie gradlew bundleRelease.
它适用于创建捆绑包,即 gradlew bundleRelease。 It does not throw any error on creating bundle but it failed to create release apk.
它不会在创建捆绑包时抛出任何错误,但无法创建发布 apk。
package.json file package.json文件
Here is my package.json file where all my dependencies are located
这是我所有依赖项所在的 package.json 文件
{
"name": "edesign",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"start": "react-native start",
"test": "jest",
"build": "npx react-native bundle --platform android --dev false --entry-file index.js --bundle-output android/app/src/main/assets/index.android.bundle --assets-dest android/app/src/main/res/",
"lint": "eslint ."
},
"dependencies": {
"@react-native-community/cameraroll": "^4.1.2",
"@react-navigation/drawer": "^6.4.1",
"@react-navigation/native": "^6.0.10",
"@react-navigation/native-stack": "^6.6.1",
"react": "17.0.2",
"react-devtools": "^4.24.4",
"react-native": "0.67.3",
"react-native-admob-next": "^1.2.0",
"react-native-device-info": "^9.0.2",
"react-native-fetch-blob": "^0.10.8",
"react-native-fs": "^2.20.0",
"react-native-gesture-handler": "^2.4.1",
"react-native-image-crop-picker": "^0.37.3",
"react-native-push-notification": "^8.1.1",
"react-native-reanimated": "^2.8.0",
"react-native-safe-area-context": "3.4.1",
"react-native-screens": "^3.13.1",
"react-native-share": "^7.4.0",
"react-native-vector-icons": "^9.1.0",
"react-native-version-check": "^3.4.3",
"react-native-view-shot": "^3.1.2"
},
"devDependencies": {
"@babel/core": "^7.12.9",
"@babel/runtime": "^7.12.5",
"@react-native-async-storage/async-storage": "^1.17.3",
"@react-native-community/eslint-config": "^2.0.0",
"@react-native-community/slider": "^4.2.2",
"@react-native-firebase/app": "^14.9.1",
"@react-native-firebase/firestore": "^14.9.1",
"@react-native-firebase/messaging": "^14.9.1",
"babel-jest": "^26.6.3",
"eslint": "7.14.0",
"jest": "^26.6.3",
"metro-react-native-babel-preset": "^0.66.2",
"react-native-image-picker": "^4.8.1",
"react-test-renderer": "17.0.2"
},
"jest": {
"preset": "react-native"
}
}
android/build.gradle安卓/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext {
buildToolsVersion = "30.0.2"
minSdkVersion = 21
compileSdkVersion = 31
targetSdkVersion = 30
ndkVersion = "21.4.7075529"
googlePlayServicesVersion = "+" // default: "+"
firebaseVersion = "+" // default: "+"
androidXCore = "1.6.0"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle:4.2.2")
classpath 'com.google.gms:google-services:4.3.12'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenCentral()
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
maven { url 'https://www.jitpack.io' }
}
}
Error错误
This is the error when I run /android - gradlew assembleRelease
这是我运行 /android - gradlew assembleRelease 时的错误
* What went wrong:
Execution failed for task ':react-native-fetch-blob:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
> Android resource linking failed
ERROR:C:\Users\lylde\.gradle\caches\transforms-3\aee9ee05966214edc1879619afacf3e1\transformed\appcompat-1.0.2\res\values-v26\values-v26.xml:5:5-8:13: AAPT: error: resource android:attr/colorError not found.
ERROR:C:\Users\lylde\.gradle\caches\transforms-3\aee9ee05966214edc1879619afacf3e1\transformed\appcompat-1.0.2\res\values-v26\values-v26.xml:9:5-12:13: AAPT: error: resource android:attr/colorError not found.
ERROR:C:\Users\lylde\.gradle\caches\transforms-3\aee9ee05966214edc1879619afacf3e1\transformed\appcompat-1.0.2\res\values-v26\values-v26.xml:13:5-16:13: AAPT: error: style attribute 'android:attr/keyboardNavigationCluster' not found.
ERROR:C:\Users\lylde\.gradle\caches\transforms-3\aee9ee05966214edc1879619afacf3e1\transformed\appcompat-1.0.2\res\values-v28\values-v28.xml:5:5-8:13: AAPT: error: resource android:attr/dialogCornerRadius not found.
ERROR:C:\Users\lylde\.gradle\caches\transforms-3\aee9ee05966214edc1879619afacf3e1\transformed\appcompat-1.0.2\res\values-v28\values-v28.xml:9:5-12:13: AAPT: error: resource android:attr/dialogCornerRadius not found.
ERROR:C:\Users\lylde\.gradle\caches\transforms-3\6659f15da30f261a037980a726c1722d\transformed\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontStyle not found.
ERROR:C:\Users\lylde\.gradle\caches\transforms-3\6659f15da30f261a037980a726c1722d\transformed\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/font not found.
ERROR:C:\Users\lylde\.gradle\caches\transforms-3\6659f15da30f261a037980a726c1722d\transformed\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontWeight not found.
ERROR:C:\Users\lylde\.gradle\caches\transforms-3\6659f15da30f261a037980a726c1722d\transformed\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.
ERROR:C:\Users\lylde\.gradle\caches\transforms-3\6659f15da30f261a037980a726c1722d\transformed\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/ttcIndex not found.
ERROR:C:\Users\lylde\.gradle\caches\transforms-3\6659f15da30f261a037980a726c1722d\transformed\core-1.1.0\res\values\values.xml:174:5-210:25: AAPT: error: resource android:attr/startX not found.
ERROR:C:\Users\lylde\.gradle\caches\transforms-3\6659f15da30f261a037980a726c1722d\transformed\core-1.1.0\res\values\values.xml:174:5-210:25: AAPT: error: resource android:attr/startY not found.
ERROR:C:\Users\lylde\.gradle\caches\transforms-3\6659f15da30f261a037980a726c1722d\transformed\core-1.1.0\res\values\values.xml:174:5-210:25: AAPT: error: resource android:attr/endX not found.
ERROR:C:\Users\lylde\.gradle\caches\transforms-3\6659f15da30f261a037980a726c1722d\transformed\core-1.1.0\res\values\values.xml:174:5-210:25: AAPT: error: resource android:attr/endY not found.
ERROR:C:\Users\lylde\.gradle\caches\transforms-3\6659f15da30f261a037980a726c1722d\transformed\core-1.1.0\res\values\values.xml:211:5-217:25: AAPT: error: resource android:attr/offset not found.
Please go to react-native-fetch-blob/android/build.gradle and update these values请 go 到 react-native-fetch-blob/android/build.gradle 并更新这些值
compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { minSdkVersion 16 targetSdkVersion 23 versionCode 1 versionName "1.0" } compileSdkVersion 23 buildToolsVersion "23.0.3" defaultConfig { minSdkVersion 16 targetSdkVersion 23 versionCode 1 versionName "1.0" }
to these对这些
compileSdkVersion 26 buildToolsVersion "26.0.3" defaultConfig { minSdkVersion 16 targetSdkVersion 26 versionCode 1 versionName "1.0" } compileSdkVersion 26 buildToolsVersion "26.0.3" defaultConfig { minSdkVersion 16 targetSdkVersion 26 versionCode 1 versionName "1.0" }
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.