开发环境运行正常,react native项目打包发行报错!!!
报错截图:
error:resource android:style/TextAppearance.Material.Widget.Button.Borderless.Colo.........
折磨了我一天,最后分享求助大佬的解决方案
修改项目下:android/build.gradle
buildscript {
ext {
buildToolsVersion ="27.0.3"
minSdkVersion =16
compileSdkVersion =27
targetSdkVersion =26
supportLibVersion ="27.1.1"
}
repositories {
google()
jcenter()
}
dependencies {
classpath'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
// 解决方案开始
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion rootProject.ext.compileSdkVersion//do this in android/app/build.gradle too
buildToolsVersion rootProject.ext.buildToolsVersion//do this in android/app/build.gradle too
}
}
}
}
// 解决方案结束
allprojects {
repositories {
google()
mavenLocal()
jcenter()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url"$rootDir/../node_modules/react-native/android"
}
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs <<"-Xlint:unchecked" <<"-Xlint:deprecation"
}
}
}
task wrapper(type: Wrapper) {
gradleVersion ='4.4'
distributionUrl = distributionUrl.replace("bin","all")
}
最后重新运行gradle assembleRelease 打包
结果惊喜的发现,打包成功!!!
分享等于快乐