React Native Camera无法构建android项目

时间:2018-08-03 13:18:31

标签: android react-native

我花了一段时间尝试在我的一个项目中实现react-native-camera,但是由于android项目,我再也无法做到这一点。升级Gradle插件和工具后,每次收到此消息。我必须具体说明我使用以下几行安装了react-native-camera:

npm install react-native-camera --save

并与以下链接:react-native link react-native-camera

这是我收到的消息:

Android dependency 'com.google.android.gms:play-services-base' has different 
version for the compile (11.0.4) and runtime (12.0.1) classpath. You should 
manually set the same version via DependencyResolution

我永远无法解决此问题。我真的会帮忙。

这是我的build.gradle文件:

android {
compileSdkVersion 23
buildToolsVersion '27.0.3'

defaultConfig {
    applicationId "com.bluelinenotes"
    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"
    }
}

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 {
        minifyEnabled enableProguardInReleaseBuilds
        proguardFiles getDefaultProguardFile("proguard-android.txt"), 
"proguard-rules.pro"
        signingConfig signingConfigs.release
    }
}
    // 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')
    compile project(':react-native-admob')
    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 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'
}

这是我的build.gradle(Module react-native-camera)

buildscript {
repositories {
jcenter()
google()
maven {
  url 'https://maven.google.com'
    }
  }

 dependencies {
  classpath 'com.android.tools.build:gradle:3.0.0'
 }
}

apply plugin: 'com.android.library'

def DEFAULT_COMPILE_SDK_VERSION             = 26
def DEFAULT_BUILD_TOOLS_VERSION             = "26.0.2"
def DEFAULT_TARGET_SDK_VERSION              = 26
def DEFAULT_GOOGLE_PLAY_SERVICES_VERSION    = "12.0.1"
def DEFAULT_SUPPORT_LIBRARY_VERSION         = "27.1.0"

android {
  compileSdkVersion rootProject.hasProperty('compileSdkVersion') ? 
rootProject.compileSdkVersion : DEFAULT_COMPILE_SDK_VERSION
  buildToolsVersion rootProject.hasProperty('buildToolsVersion') ? 
rootProject.buildToolsVersion : DEFAULT_BUILD_TOOLS_VERSION

  defaultConfig {
    minSdkVersion 16
    targetSdkVersion rootProject.hasProperty('targetSdkVersion') ? 
    rootProject.targetSdkVersion : DEFAULT_TARGET_SDK_VERSION

versionCode 1
versionName "1.0.0"
  }
  lintOptions {
    abortOnError false
    warning 'InvalidPackage'
  }
}

repositories {
  mavenCentral()
  maven {
   url 'https://maven.google.com'
  }
  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"
  }
}

dependencies {
  def googlePlayServicesVersion = 
rootProject.hasProperty('googlePlayServicesVersion')  ? 
rootProject.googlePlayServicesVersion : DEFAULT_GOOGLE_PLAY_SERVICES_VERSION
  def supportLibVersion = rootProject.hasProperty('supportLibVersion')  ? 
rootProject.supportLibVersion : DEFAULT_SUPPORT_LIBRARY_VERSION

  compileOnly 'com.facebook.react:react-native:+'
  compileOnly 'com.facebook.infer.annotation:infer-annotation:+'
  implementation "com.google.zxing:core:3.2.1"
  implementation "com.drewnoakes:metadata-extractor:2.9.1"
  implementation "com.google.android.gms:play-services- 
  vision:$googlePlayServicesVersion"
 implementation "com.android.support:exifinterface:$supportLibVersion"
  implementation "com.android.support:support-annotations:$supportLibVersion"
  implementation "com.android.support:support-v4:$supportLibVersion"
}

我真的不知道该怎么办。请告诉我!

0 个答案:

没有答案