4

I am creating a project in React Native and trying to run it in Android but I am facing some issues while deploying it in Android

Could not find method implementation() for arguments [com.facebook.react:react-native:0.20.1] on project ':react-native-camera'.

This is the error message which I got in the logcat

buildscript {
repositories {
jcenter()
maven {
  url 'https://maven.google.com'
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.3'
}
}

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_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'
}


 buildToolsVersion '27.0.3'
}

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 supportLibVersion = rootProject.hasProperty('supportLibVersion')  ? rootProject.supportLibVersion : DEFAULT_SUPPORT_LIBRARY_VERSION

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

If anyone have the solution please tell me. Thanks in Advance

Akash Mishra
  • 623
  • 1
  • 6
  • 22
  • 1
    Where is this gradle file located at? it looks like a combination of the app-level and top-level gradle files.. I think it makes a mess.. You also define buildToolsVersion twice in the android block..The buildscript and the dependencies blocks should be in the top-level gradle file... – HedeH Jul 02 '18 at 10:50
  • 1
    Refer to https://stackoverflow.com/questions/44493378/whats-the-difference-between-implementation-and-compile-in-gradle – Anurag Chutani Jul 02 '18 at 12:21
  • I got it, This happens because some gradle version issue. there are two files for the gradle version and both of them needs to be same and both the files should have use implementation for dependencies. Thanks for your support – Akash Mishra Jul 04 '18 at 06:29

0 Answers0