我尝试为我的项目构建发行版构建APK。该项目在模拟器中运行正常。问题是,显示一些错误。我无法跟踪错误所在。请检查下面的屏幕截图以了解错误。
用于生成APK的代码: cd android && gradlew assembleRelease
如果有任何问题,请检查下面的Gradle属性。
build.gradle
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js",
enableHermes: false, // clean and rebuild if changing
]
apply from: "../../node_modules/react-native/react.gradle"
def enableSeparateBuildPerCPUArchitecture = false
def enableProguardInReleaseBuilds = false
def jscFlavor = 'org.webkit:android-jsc:+'
def enableHermes = project.ext.react.get("enableHermes", false);
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.raottsworld"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 12
versionName "1.2.0"
multiDexEnabled true
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
release {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
buildTypes {
debug {
minifyEnabled true
useProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://facebook.github.io/react-native/docs/signed-apk-android.
signingConfig signingConfigs.release
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
innerTest {
matchingFallbacks = ['debug', 'release']
}
}
// 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:
// 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
}
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':@react-native-community_async-storage')
implementation project(':@react-native-community_netinfo')
implementation project(':react-native-gesture-handler')
implementation "com.android.support:multidex:1.0.3"
implementation project(":react-native-image-zoom")
implementation project(":react-native-photo-view")
implementation project(":react-native-vector-icons")
implementation project(":react-native-video")
implementation project(":react-native-maps")
implementation project(":RNPermissionsModule")
implementation (project(":react-native-fcm")) {
exclude group: "com.google.firebase"
}
implementation (project(":react-native-maps")) {
exclude group: "com.google.android.gms", module: "play-services-base"
exclude group: "com.google.android.gms", module: "play-services-maps"
}
implementation ("com.google.android.gms:play-services-base:10.2.1") {
force = true;
}
implementation ("com.google.android.gms:play-services-maps:10.2.1") {
force = true;
}
implementation project(":react-native-image-picker")
implementation project(":react-native-camera")
implementation project(":react-native-fcm")
implementation project(":react-native-svg")
implementation ('com.google.firebase:firebase-messaging:10.2.1') {
force = true;
}
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
// 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'
}
// apply plugin: "com.google.gms.google-services"
apply from: file("../../node_modules/@react-native-community/cli-platform-
android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
Versions Used
"react": "16.9.0",
"react-native": "0.61.5",
我被卡在上述错误中,确实需要帮助来纠正错误。