在调试模式下工作时,我正在正确构建React Native项目,但是当我尝试在发布模式下构建项目时,我无法成功。
有关项目的一些信息:
RN版本:0.55.4
渐变版本:2.2.3
compileSdkVersion 26
buildToolsVersion“ 26.0.3”
操作系统:Windows 10
尽管我尝试了以下链接React Native APK build failure Unable to process incoming event 'ProgressComplete'中的所有建议,但仍无法达到任何良好的效果
例如:
react-native run-android --variant = release
gradlew assembleRelease --console普通
ect。
android / build.gradle ::
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
classpath 'com.google.gms:google-services:3.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
maven { url 'https://maven.google.com' }
maven { url "https://jitpack.io" }
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven { url "http://oss.sonatype.org/content/repositories/snapshots/" }
}
}
subprojects {
afterEvaluate {
project -> if (project.hasProperty("android")) {
android {
compileSdkVersion 26
buildToolsVersion '26.0.1'
}
}
}
}
和app / build.gradle:
apply plugin: "com.android.application"
import com.android.build.OutputFile
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
def enableSeparateBuildPerCPUArchitecture = true
def enableProguardInReleaseBuilds = false
android {
signingConfigs {
config {
keyAlias '*'
keyPassword '*!'
storeFile file('*')
storePassword '*!'
}
release {
if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
storeFile file(MYAPP_RELEASE_STORE_FILE)
storePassword MYAPP_RELEASE_STORE_PASSWORD
keyAlias MYAPP_RELEASE_KEY_ALIAS
keyPassword MYAPP_RELEASE_KEY_PASSWORD
}
}
}
compileSdkVersion 26
buildToolsVersion "26.0.3"
defaultConfig {
applicationId "*"
minSdkVersion 16
targetSdkVersion 26
versionCode 91
versionName "0.91"
multiDexEnabled = true
ndk {
abiFilters "armeabi-v7a", "x86", "arm64-v8a"
}
}
aaptOptions.cruncherEnabled = false
aaptOptions.useNewCruncher = false
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
include "armeabi-v7a", "x86"
}
}
buildTypes {
release {
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
minifyEnabled true
}
debug {
signingConfig signingConfigs.config
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
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
}
}
}
}
dependencies {
compile project(':react-native-version-check')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "org.jsoup:jsoup:1.8.3"
compile "com.android.support:appcompat-v7:26.1.0"
compile "com.facebook.react:react-native:0.55.4" // From node_modules
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
if (!requested.name.startsWith("multidex")) {
details.useVersion '25.3.0'
}
}
}
}
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
apply plugin: 'com.google.gms.google-services'
更多细节是,我们可以在MAC OS上以上述等级构建相同的项目,但是在Windows上无法以相同的方式构建。