问题
I am using RN 0.55.4 react-native-fbsdk 0.8.0
There is a build error
Where: Build file 'C:\Users\WOT\fdrrnc\node_modules\react-native-fbsdk\android\build.gradle' line: 30
What went wrong: A problem occurred evaluating project ':react-native-fbsdk'. Could not find method implementation() for arguments [com.android.support:appcompat-v7:27.0.2] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
This my gradle on android/build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
}
Anyone know whats wrong?
回答1:
In case anyone is still looking for this, here's what I did based on the answers from Pritish for this question and similar ones.
Make sure you are using the compatible version of gradle
Update android/gradle/wrapper/gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Update android/build.gradle classpath
classpath 'com.android.tools.build:gradle:3.1.2'
Add maven google url
Update android/build.gradle (both buildscript and allprojects)
buildscript {
repositories {
jcenter()
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
...
}
allprojects {
repositories {
mavenLocal()
jcenter()
maven {
url "$rootDir/../node_modules/react-native/android"
}
maven {
url 'https://maven.google.com/'
name 'Google'
}
}
}
Check that you are using at least API 26
If you are using an older react native version prior to the changes where they updated to use API 26, check these values in your android/app/build.gradle file:
compileSdkVersion 26
buildToolsVersion "26.0.3"
defaultConfig {
...
targetSdkVersion 26
...
}
回答2:
Your gradle version needs to be version 3.0 or higher in order to use implementation
.
Therefore you need to upgrade it.
build.gradle (project level)
dependencies {
classpath 'com.android.tools.build:gradle:3.x.x'
}
gradle wrapper-properties
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
来源:https://stackoverflow.com/questions/52297950/react-native-fbsdk-build-error-could-not-find-method-implementation