我试图在react-native应用程序上构建一个Android项目。直到今天早上,一切工作正常。奇怪的是,没有代码更改,但是构建失败。可能与内部依赖项更新有关,但我无法弄清楚。
我试图将compileSdkVersion更新为28,但这会产生更多问题,如果不是完全必要,我想避免使用它。
android / build.gradle
buildscript {
ext {
buildToolsVersion = "27.0.3"
minSdkVersion = 21
compileSdkVersion = 27
targetSdkVersion = 26
supportLibVersion = "27.1.1"
googlePlayServicesAuthVersion = "15.0.1"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
android / app / build.gradle
dependencies {
// this is copied from
implementation('com.onesignal:OneSignal:3.10.8') {
// Exclude com.android.support(Android Support library) as the version range starts at 26.0.0
// This is due to compileSdkVersion defaulting to 23 which cant' be lower than the support library version
// And the fact that the default root project is missing the Google Maven repo required to pull down 26.0.0+
exclude group: 'com.android.support'
// Keeping com.google.android.gms(Google Play services library) as this version range starts at 10.2.1
}
implementation project(':react-native-onesignal')
implementation project(':appcenter')
implementation project(':react-native-gesture-handler')
implementation project(':react-native-reanimated')
implementation project(':react-native-audio-jack')
implementation project(':react-native-firebase')
androidTestImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test:rules:1.0.1'
implementation project(':appcenter-crashes')
implementation project(':appcenter-analytics')
implementation project(':react-native-heading')
implementation project(':react-native-billing')
implementation project(':react-native-android-badge')
implementation project(':react-native-sound')
implementation project(':react-native-google-analytics-bridge')
implementation project(':react-native-bluetooth-state')
implementation project(':react-native-code-push')
implementation (project(':@mapbox_react-native-mapbox-gl')){
implementation ('com.squareup.okhttp3:okhttp:3.9.1') {
force = true
}
}
implementation project(':react-native-kontaktio')
implementation project(':realm')
implementation project(':rn-fetch-blob')
implementation project(':react-native-restart')
implementation project(':react-native-linear-gradient')
implementation project(':react-native-keep-awake')
implementation project(':react-native-image-crop-picker')
implementation project(':react-native-i18n')
implementation project(':react-native-fs')
implementation project(':react-native-exception-handler')
implementation project(':react-native-device-info')
implementation (project(':react-native-camera')){
exclude group: "com.android.support"
}
implementation project(':react-native-android-location-services-dialog-box')
implementation project(':lottie-react-native')
implementation project(':react-native-google-signin')
implementation project(':react-native-fbsdk')
implementation project(':react-native-config')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation "com.google.firebase:firebase-invites:16.1.0"
}
我希望Android版本能够顺利通过。
答案 0 :(得分:3)
这似乎与Google发布其Play服务的新版本有关,并且您不想更新compileSdkVersion。
尝试一下:
implementation(project(":react-native-device-info"), {
exclude group: "com.google.android.gms"
})
implementation "com.google.android.gms:play-services-gcm:16.0.0"
有关更多详细信息,您可以参考this
答案 1 :(得分:0)
在根级别的build.gradle文件中添加以下代码行
subprojects {
afterEvaluate {project ->
if (project.hasProperty("android")) {
android {
compileSdkVersion 28
buildToolsVersion '28.0.1'
}
}
}
}