Kei*_*rke 6 android android-studio android-gradle-plugin react-native react-native-camera
我在Android上遇到了react-native-camera的问题.它现在正常工作大约一个星期,突然间,Gradle不会构建出现以下错误:
Error:Execution failed for task ':react-native-camera:processReleaseResources'.
> Error: more than one library with package name 'com.google.android.gms.license'
Run Code Online (Sandbox Code Playgroud)
从我收集的内容来看,这是由com.google.android.gms多次加载引起的.我按照RNCamera文档进行操作,确保我的Gradle文件匹配.
Android设备/应用/的build.gradle:
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.phase1"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
}
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 {
compile (project(':react-native-camera')) {
exclude group: "com.google.android.gms"
compile 'com.android.support:exifinterface:27.+'
}
//compile project(':react-native-camera')
compile fileTree(dir: "libs", include: ["*.jar"])
compile "com.android.support:appcompat-v7:23.0.1"
compile "com.facebook.react:react-native:+" // From node_modules
}
Run Code Online (Sandbox Code Playgroud)
安卓/ settings.gradle:
rootProject.name = 'Phase1'
include ':react-native-camera'
project(':react-native-camera').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-camera/android')
include ':app'
Run Code Online (Sandbox Code Playgroud)
安卓/的build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven { url "https://jitpack.io" }
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url "$rootDir/../node_modules/react-native/android"
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
Run Code Online (Sandbox Code Playgroud)
以下是外部库中的所有com.google.android.gms条目,我没有看到任何重复项并在此处尝试了所有答案Gradle:错误:包含名称为"com.google.android.gms"的多个库
我已经尝试删除com.android.support:appcompat-v7版本,创建一个新项目,卸载并重新安装Android SDK Build Tools(23.0.1,25.0.2,26.0.1,26.0.2,27.0.3)& Android支持存储库,已经没有想法.我正在使用Android Studio 3.0.1,gradle-2.14.1
一旦我从Gradle文件中删除相机refs,项目构建正常并按预期工作.所以我现在很困惑.任何建议将不胜感激.
小智 5
这是因为谷歌服务版本更新(12.0.0).您应该通过编辑android/build.gradle文件将其指回11.8.0:
def googlePlayServicesVersion = '11.8.0'
allprojects {
configurations.all {
resolutionStrategy {
eachDependency { DependencyResolveDetails details ->
if (requested.group == 'com.google.android.gms') {
details.useVersion "$googlePlayServicesVersion"
}
if (requested.group == 'com.google.firebase') {
details.useVersion "$googlePlayServicesVersion"
}
}
}
}
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
933 次 |
| 最近记录: |