我有一个在 Play 商店中发布的应用程序,因为 Play 商店要求将 targetSdkVersion 更改为 34,所以我转到 android/build.gradle 并手动更改了 targetSdkVersion // 顶级构建文件,您可以在其中添加所有子项目/模块通用的配置选项。
buildscript {
ext {
buildToolsVersion = "33.0.0"
minSdkVersion = 23
compileSdkVersion = 34
targetSdkVersion = 34
kotlin_version = "1.8.10"
googlePlayServicesVersion = "21.0.1"
// We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
ndkVersion = "23.1.7779620"
}
repositories {
google()
mavenCentral()
}
dependencies {
classpath("com.android.tools.build:gradle")
classpath("com.facebook.react:react-native-gradle-plugin")
classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:1.8.10")
}
allprojects{
repositories {
google()
mavenCentral()
}
}
}
我尝试生成 AAB 文件,并且在尝试升级 gradle、kotlin 插件和 kotlin 版本后,此错误仍然存在,我还尝试清理并重新构建应用程序。 我的package.json
{
"name": "wyngo",
"version": "0.0.1",
"private": true,
"scripts": {
"android": "react-native run-android",
"ios": "react-native run-ios",
"lint": "eslint .",
"start": "react-native start",
"test": "jest"
},
"dependencies": {
"@gorhom/bottom-sheet": "^4.6.0",
"@react-native-async-storage/async-storage": "^1.21.0",
"@react-native-community/checkbox": "^0.5.16",
"@react-native-community/cli-platform-android": "^13.2.0",
"@react-native-community/datetimepicker": "^7.6.2",
"@react-native-community/geolocation": "^3.3.0",
"@react-native-community/slider": "^4.5.2",
"@react-native-masked-view/masked-view": "^0.3.1",
"@react-native-picker/picker": "^2.7.7",
"@react-native-vector-icons/fontawesome6": "^6.6.0-alpha.28",
"@react-navigation/bottom-tabs": "^6.5.11",
"@react-navigation/drawer": "^6.6.6",
"@react-navigation/elements": "^1.3.21",
"@react-navigation/native": "^6.1.9",
"@react-navigation/native-stack": "^6.9.17",
"@react-navigation/stack": "^6.3.20",
"@shopify/flash-list": "^1.6.3",
"axios": "^1.6.3",
"formik": "^2.4.5",
"geolib": "^3.3.4",
"i18next": "^23.7.20",
"react": "18.2.0",
"react-i18next": "^14.0.1",
"react-native": "0.72.7",
"react-native-android-open-settings": "^1.3.0",
"react-native-asset": "^2.1.1",
"react-native-date-picker": "^5.0.4",
"react-native-draggable-flatlist": "^4.0.1",
"react-native-draggable-grid": "^2.2.1",
"react-native-event-listeners": "^1.0.7",
"react-native-geolocation-service": "^5.3.1",
"react-native-gesture-handler": "^2.18.1",
"react-native-image-picker": "^7.1.2",
"react-native-image-viewing": "^0.2.2",
"react-native-indicators": "^0.17.0",
"react-native-linear-gradient": "^2.8.3",
"react-native-maps": "^1.14.0",
"react-native-multi-slider": "^0.3.6",
"react-native-paper": "^5.12.1",
"react-native-picker-select": "^9.1.3",
"react-native-radio-buttons-group": "^3.0.7",
"react-native-ratings": "^8.1.0",
"react-native-reanimated": "^3.6.2",
"react-native-responsive-screen": "^1.4.2",
"react-native-safe-area-context": "^4.8.2",
"react-native-screens": "^3.29.0",
"react-native-toast-message": "^2.2.0",
"react-native-vector-icons": "^10.0.3",
"react-native-webview": "^13.7.0",
"yup": "^1.3.3"
},
"devDependencies": {
"@babel/core": "^7.20.0",
"@babel/preset-env": "^7.20.0",
"@babel/runtime": "^7.20.0",
"@react-native/eslint-config": "^0.72.2",
"@react-native/metro-config": "^0.72.11",
"@tsconfig/react-native": "^3.0.0",
"@types/react": "^18.0.24",
"@types/react-native-vector-icons": "^6.4.18",
"@types/react-test-renderer": "^18.0.0",
"babel-jest": "^29.2.1",
"eslint": "^8.19.0",
"jest": "^29.2.1",
"metro-react-native-babel-preset": "0.76.8",
"prettier": "^2.4.1",
"react-test-renderer": "18.2.0",
"typescript": "4.8.4"
},
"engines": {
"node": ">=16"
}
}
以及错误: 错误无法构建应用程序。
Error: Command failed with exit code 1: gradlew.bat app:bundleRelease
at makeError (C:\Users\BILEL\Downloads\wyngo_Frontend-main\wyngo_Frontend-main\node_modules\execa\lib\error.js:60:11)
at module.exports.sync (C:\Users\BILEL\Downloads\wyngo_Frontend-main\wyngo_Frontend-main\node_modules\execa\index.js:194:17)
at build (C:\Users\BILEL\Downloads\wyngo_Frontend-main\wyngo_Frontend-main\node_modules\react-native\node_modules\@react-native-community\cli-platform-android\build\commands\buildAndroid\index.js:95:22)
at Object.buildAndroid [as func] (C:\Users\BILEL\Downloads\wyngo_Frontend-main\wyngo_Frontend-main\node_modules\react-native\node_modules\@react-native-community\cli-platform-android\build\commands\buildAndroid\index.js:87:10)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Command.handleAction (C:\Users\BILEL\Downloads\wyngo_Frontend-main\wyngo_Frontend-main\node_modules\@react-native-community\cli\build\index.js:111:9)
info Run CLI with --verbose flag for more details.
我也看到了同样的错误消息,但真正的错误在更上面。
它看起来像这样:
> Task :app:signReleaseBundle FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:signReleaseBundle'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.FinalizeBundleTask$BundleToolRunnable
> Failed to read key my-key-alias from store "....\android\app\release.keystore": Get Key failed: Given final block not properly padded. Such issues can arise if a bad key is used during decryption.
这基本上是密钥库某处的“错误”配置。
如果您根据文档创建上传密钥,发布到 Google Play Store - React Native,(无论如何对我来说)不清楚
MYAPP_UPLOAD_STORE_PASSWORD
和 MYAPP_UPLOAD_KEY_PASSWORD
的值是什么。
如果遵循文档,这些都是相同的,并且是您在运行
keytool
命令 (keytool -genkeypair -v -storetype PKCS12 -keystore my-upload-key.keystore -alias my-key-alias -keyalg RSA -keysize 2048 -validity 10000
) 后出现提示时输入的值。
我还发现我的 Gradle 变量必须位于
android/gradle.properties
中。 它们没有从我的用户目录中被发现(因此被签入到 Git)。