构建应用程序时出现以下错误
Android依赖项“ com.google.android.gms:play-services-base”具有 编译(15.0.1)和运行时(16.0.1)的不同版本 类路径。您应该通过以下方式手动设置相同的版本 DependencyResolution
APP / build.gradle文件
apply plugin: "com.android.application"
import com.android.build.OutputFile
project.ext.react = [
entryFile: "index.js"
]
apply from: "../../node_modules/react-native/react.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = false
android {
compileSdkVersion 26
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.afbmobilebanking"
minSdkVersion 16
targetSdkVersion 26
versionCode 14
versionName "1.0.9"
ndk {
abiFilters "armeabi-v7a", "x86"
}
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
signingConfigs {
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
}
}
}
buildTypes {
release {
debuggable false
// minifyEnabled true
// shrinkResources true
signingConfig signingConfigs.release
// minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
}
}
lintOptions {
abortOnError false
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86"
}
}
// buildTypes {
// release {
// minifyEnabled enableProguardInReleaseBuilds
// proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
// }
// }
// 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:
// http://tools.android.com/tech-docs/new-build-system/user-guide/apk-splits
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 {
implementation project(':react-native-maps')
implementation project(':react-native-i18n')
implementation project(':react-native-device-info')
implementation project(':react-native-maps')
implementation project(':react-native-device-info')
implementation project(':react-native-i18n')
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:23.0.1"
implementation "com.facebook.react:react-native:+" // From node_modules
implementation 'com.facebook.fresco:animated-gif:1.3.0'
// 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:15.0.1'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
}
// 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'
}
请让我知道如何解决此问题。
答案 0 :(得分:1)
您的某些库可能依赖于播放服务。您可以使用以下方式查看依赖关系树:
$ ./gradlew app:dependencies
然后您可以从库中排除冲突的依赖关系,或尝试将所有库升级到最新版本, 或尝试使用
简单地忽略该问题(不建议这样做)com.google.gms.googleservices.GoogleServicesPlugin.config.disableVersionCheck = true
答案 1 :(得分:0)
删除implementation project(':react-native-maps')
的重复声明,并
如果与react-native-maps库有冲突,则将以下代码替换为implementation project(':react-native-maps')
。
implementation(project(':react-native-maps')) {
exclude group: 'com.google.android.gms', module: 'play-services-base'
}
答案 2 :(得分:0)
implementation fileTree(dir: "libs", include: ["*.jar"])
implementation "com.android.support:appcompat-v7:27.1.1"
implementation "com.facebook.react:react-native:0.20.1" // From node_modules
implementation "com.google.android.gms:play-services-base:16.1.0"
在build.Gradle / app中添加实现“ com.google.android.gms:play-services-base:16.1.0”,