I'm getting an error whenever I run the implementation() method.
I tried to import this Insiteo '.aar' file and set it's dependencies, but there's an issue with calling 'implementation()' method. Help?
Insiteo module build.gradle:
configurations.maybeCreate("default")
artifacts.add("default", file('Insiteo-SDK-3.6.3g.aar'))
dependencies {
implementation 'com.squareup.retrofit:retrofit:2.0.0-beta2'
implementation 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
implementation 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
}
Here's the error
Error:(6, 0) Could not find method implementation() for arguments ['com.squareup.retrofit:retrofit:2.0.0-beta2']
App module build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
apply plugin: 'com.android.library'
defaultConfig {
applicationId "com.example.joey.projectgenesis"
minSdkVersion 26
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:26.1.0'
implementation 'com.google.android.gms:play-services-ads:11.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:gridlayout-v7:26.1.0'
implementation 'com.squareup.retrofit:retrofit:2.0.0-beta2'
implementation 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
implementation 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
implementation project(':Insiteo')
}
Project build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
My Android plugin version is 3.0.1, and my Gradle version is 4.4.1
I've also tried compile() as well with the same error.
There isn't any problems with the other build.gradle scripts, just the Insiteo module script, and it's only with the implementation() method.
AFAIK, you can't add dependencies to an aar module like that. You most likely need to apply the app or library plugin in order to do that.
But it's generally easier just adding the dependencies directly into your project; not into the library module. Example:
Root /
app/
myAarLibrary/
Don't define dependencies in myAarLibrary, define them in app
Your gradle have some problem. You can use compile instead implelentaion in gradle dependencies. All gradle support this by default.
Make sure you are using Android Studio 3.0 or above.
Your app level build.gradle should look like this:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Make sure your gradle-wrapper.properties looks like this:
#DATE
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
Use
implementation 'com.squareup.retrofit:retrofit:2.3.0'
implementation 'com.squareup.retrofit:adapter-rxjava:2.3.0'
implementation 'com.squareup.retrofit:converter-gson:2.3.0'
instead of
implementation 'com.squareup.retrofit:retrofit:2.0.0-beta2'
implementation 'com.squareup.retrofit:adapter-rxjava:2.0.0-beta2'
implementation 'com.squareup.retrofit:converter-gson:2.0.0-beta2'
Related
I have a problem about exporting AAR from my project. My project has 3 modules that included as library into the project. One of that modules is android project that contains the actual project.
That means when you run the whole project in AVD, project opens the module as I mentioned before. And the other modules related and connected with the main module as a network and opencv library.
My problem is: When I want to create ONE AAR. file that includes all modules inside, the android project creates AAR. file by module that means three different AAR. file for 3 different module.
Because of that I cannot add my whole project's AAR. file to another project.
There is way of creating AAR. file of whole project that includes all modules inside like opencv module, network module, for all modules?
My project build.gradle;
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
apply from: "$rootProject.projectDir/dependencyVersion.gradle"
ext.kotlin_version = '1.4.10'
repositories {
google()
jcenter()
maven {url 'https://maven.fabric.io/public'}
maven { url 'https://maven.google.com' }
maven { url "https://plugins.gradle.org/m2/"}
}
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
classpath 'com.google.gms:google-services:4.3.3'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath "org.jfrog.buildinfo:build-info-extractor-gradle:4.17.0"
}
}
allprojects {
repositories {
google()
jcenter()
maven {url 'https://maven.fabric.io/public'}
maven { url 'https://maven.google.com' }
maven { url "https://plugins.gradle.org/m2/"}
}
apply plugin: "com.jfrog.artifactory"
apply plugin: 'maven-publish'
}
artifactoryPublish.skip = true
task clean(type: Delete) {
delete rootProject.buildDir
}
This is my build.gradle. of the library module. Lets call it module1 where i want to merge all other two library module(module2, module3) into this module1.
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
version = rootProject.sdkVersionName
group = rootProject.mainLibraryGroup
android {
compileSdkVersion rootProject.compileSdkVer
defaultConfig {
minSdkVersion rootProject.minSdkVer
targetSdkVersion rootProject.targetSdkVer
versionCode rootProject.sdkVersionCode
versionName rootProject.sdkVersionName
// versionCode 1
// versionName "1.0.0(10)"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dataBinding {
enabled true
}
lintOptions {
abortOnError false
}
externalNativeBuild {
cmake {
path file('CMakeLists.txt')
}
}
sourceSets {
main {
// The libs directory contains prebuilt libraries that are used by the app's library defined in CMakeLists.txt
// via an IMPORTED target.
jniLibs.srcDirs = ['libs'] //'libs'
}
}
}
dependencies {
// implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(path: ':module2')
implementation project(path: ':module3')
implementation "androidx.legacy:legacy-support-v4:1.0.0"
//getting dependencies from dependencies.gradle file
implementation deps.crashlytics
implementation "android.arch.lifecycle:extensions:$versions.arcLifecycle"
implementation "com.github.bumptech.glide:glide:$versions.glide"
implementation "androidx.appcompat:appcompat:$versions.appcompat"
implementation "androidx.constraintlayout:constraintlayout:$versions.constraintLayout"
implementation "com.google.code.gson:gson:$versions.gson"
implementation "com.google.android.material:material:$versions.material"
implementation "com.squareup.okhttp3:logging-interceptor:$versions.okHttp"
implementation "androidx.exifinterface:exifinterface:1.3.0-alpha01"
implementation "com.google.android.gms:play-services-location:$versions.playServices"
implementation "com.google.android.gms:play-services-mlkit-text-recognition:$versions.playServices"
implementation 'com.google.guava:guava:27.0.1-android'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'org.jmrtd:jmrtd:0.7.18'
implementation 'net.sf.scuba:scuba-sc-android:0.0.20'
implementation 'com.madgag.spongycastle:prov:1.58.0.0'
implementation 'edu.ucar:jj2000:5.2'
implementation 'com.github.mhshams:jnbis:1.1.0'
implementation 'androidx.camera:camera-core:1.0.0-beta05'
implementation 'androidx.camera:camera-camera2:1.0.0-beta05'
implementation "com.airbnb.android:lottie:3.4.4"
def camerax_version = "1.0.0-alpha01"
implementation "androidx.camera:camera-core:${camerax_version}"
implementation "androidx.camera:camera-camera2:${camerax_version}"
implementation "androidx.core:core-ktx:1.3.2"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
//RX
implementation "io.reactivex.rxjava2:rxandroid:$versions.rxandroid"
implementation "io.reactivex.rxjava2:rxjava:$versions.rxjava"
implementation 'org.jetbrains:annotations:15.0'
//image Cropping
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
}
repositories {
mavenCentral()
}
apply from: "$rootProject.projectDir/tools/artifactory/commonArtifactory.gradle"
I applied all of them. After that, i clicked the gradle in righ panel of Android Studi. And I selected the module1>other>assembleRelease. I gave me this error.
DSL element 'android.dataBinding.enabled' is obsolete and has been replaced with 'android.buildFeatures.dataBinding'.
Could not resolve io.reactivex.rxjava2:rxandroid:null
You need a fat-aar (An aar that includes all the others locally).
You can use something like kezong lib or cpdroid lib
Update:
Based on the snippet that you included in the question, I suggest to try the changes below:
In your root build-gradle file (I think that is the first snippet) you should add the below code:
dependencies {
classpath 'com.kezong:fat-aar:1.2.20'
}
In your library's build-gradle file you should add the
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'com.kezong.fat-aar'
and change the below dependencies section:
from
dependencies {
implementation project(path: ':module2')
implementation project(path: ':module3')
}
to
dependencies {
releaseEmbed project(path: ':module2')
releaseEmbed project(path: ':module3')
debugImplementation project(path: ':module2')
debugImplementation project(path: ':module3')
}
I am facing this strange issue where my project compiles and runs successfully but in my kotlin scope functions red errors are coming. It also shows errors on some of the kotlin functions like toLong(), toDouble() etc.
and I have this in my gradle file
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'io.fabric'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.xyz"
minSdkVersion 19
targetSdkVersion 28
versionCode 4
multiDexEnabled true
versionName "1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
repositories {
maven { url 'https://jitpack.io' }
}
dependencies {
def lifecycle_version = "2.0.0"
def room_version = "beta01"
implementation fileTree(dir: 'libs', include: ['*.jar'])
//android X
implementation "androidx.lifecycle:lifecycle-extensions:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata:$lifecycle_version"
implementation 'com.android.support:multidex:1.0.3'
api 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
api 'de.hdodenhof:circleimageview:3.0.0'
api 'com.jakewharton:butterknife:10.1.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
// For Kotlin use kapt instead of annotationProcessor
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.20'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.1.1'
implementation "androidx.room:room-runtime:2.2.0-$room_version"
implementation "androidx.room:room-ktx:2.2.0-$room_version"
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0'
api(name: 'sdk-release-1.6.1', ext: 'aar') {
transitive = true
}
// Add the Firebase SDK for Google Analytics
implementation 'com.google.firebase:firebase-analytics:17.2.0'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
//annotation processors
annotationProcessor "androidx.lifecycle:lifecycle-compiler:$lifecycle_version"
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
annotationProcessor "androidx.room:room-compiler:2.2.0-$room_version"
// Add dependency
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
//facebook app events sdk
implementation 'com.facebook.android:facebook-android-sdk:[5,6)'
}
apply plugin: 'com.google.gms.google-services' // Google Play services Gradle plugin
Gradle Properties
org.gradle.jvmargs=-Xmx1536m
android.useAndroidX=true
android.enableJetifier=true
build gradle
buildscript {
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.3.20"
classpath 'com.google.gms:google-services:4.3.1'
classpath 'io.fabric.tools:gradle:1.31.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
flatDir {
dirs 'libs'
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have tried Invalidate cache/Restart and also tried deleting .idea and .gradle files nothing helped, I have also tried to restart the android studio and also tried to change branches from git nothing helped.
any help appreciated.
I had similar experience on Android Studio with Kotlin since 2 weeks ago.
When I import a project on GitHub with old Kotlin plugin version 1.3.31. I quickly changed it to 1.3.72 (the latest kotlin) then, I had had this error too.
I could fix the error when I changed the plugin version to 1.3.61 (older version) and sync my project. It removed the error and update it to the latest plugin version 1.3.72. And everything worked smoothly now.
buildscript {
ext.kotlin_version = '1.3.72'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.6.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.3.0-alpha06"
}
}
I was like magic.
Just changed the Kotlin plugin version to a 2 or 3 older versions backward and sync your project. I should work
I hoped it helps
Change this line
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.50'
Into
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.3.50'
And then do again, clean build then invalidate cache and restart.
I get the following error ERROR: Could not find method android() for arguments [build_9fawur68cjcg5sfkvki95w8sr$_run_closure1#30cec325] on project ':app' of type org.gradle.api.Project.
I'm not sure why I get this error, and I've tried many other things to see if I can get it to work. Although it never does.
App level gradle has been modified many times none of which fix the issue. Project level gradle doesn't work right either.
App level gradle
android {
compileSdkVersion 28
defaultConfig {
applicationId "net.troop59.LoginFirebase"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-core:16.0.6'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:28.0.0'
//add this line
compile 'com.google.firebase:firebase-auth:16.1.0'
}
apply plugin: "com.google.gms.google-services"
Project level gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
You are missing the line
apply plugin: 'com.android.application'
at the very beginning of your app-level build.gradle file.
More info
An example on github
You should also have this dependency in the project-level build.gradle:
dependencies {
...
classpath 'com.android.tools.build:gradle:3.3.0'
...
}
UPDATE #1
You must add the google repository:
allprojects {
repositories {
google()
jcenter()
}
}
As I can't add a comment ,so I will add Answer
you should also
Change every Compile to Implementation
then Invalidates Cashes and restart (as follows)
[
I'm trying to sync with Firebase with my project I use the tool from Android Studio --> Firebase and then I do the steps (This is new Project) Image.
Android Studio version 3.0.1
The build.gradle in App folder is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.eranp.fiberbase"
minSdkVersion 19
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-database:11.0.4'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
apply plugin: 'com.google.gms.google-services'
The build.gradle in Project folder
// 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"
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
compile "com.android.support:support-core-utils:27.1.0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
But when I sync the project I have this Error:
Error:(13, 0) Could not find method compile() for arguments
[com.android.support:support-core-utils:27.1.0] on object of type
org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.
Please install the Android Support Repository from the Android SDK
Manager.
But this is installed: Image.
I tried for a week to work with Firebase but anything working to sync.
How can I fix this?
thank you for helping!
After you add this:
compile "com.android.support:support-core-utils:27.1.0"
under the dependencies in the app/build.gradle
then you need to change the:
compileSdkVersion 26
to this:
compileSdkVersion 27
also update the firebase version to this:
implementation 'com.google.firebase:firebase-database:11.8.0'
latest version
You're trying to add a compile dependency to your project buildscript, which is not valid. You are only supposed to add classpath dependencies to your buildscript, which effectively act as plugins for your Gradle build.
compile dependencies are to be using your app's build.gradle, which typically lives in the app folder. These are SDK components that you use to build your app.
If you want to use compile "com.android.support:support-core-utils:27.1.0" in your app, move it from the buildscript dependencies to the app dependencies.
My android version is 2.3.3. I update android sdk (26). I get an error after updating. I'm having trouble with build.gradle. What's wrong my code? How to use the DSL implementation() ? How can I configure this project to run ?
build.gradle (Project)
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle (Module)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.ppl.restaurant"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.1'
compile "com.android.support:support-core-utils:26.0.1"
implementation 'info.androidhive:barcode-reader:1.1.2'
implementation 'com.google.android.gms:play-services-vision:11.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
Error Message
Error:(38, 0) Gradle DSL method not found: 'implementation()'
Possible causes:<ul><li>The project 'Restaurant' may be using a version of the Android Gradle plug-in that does not contain the method (e.g. 'testCompile' was added in 1.1.0).
Upgrade plugin to version 2.3.3 and sync project</li><li>The project 'ABC' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file</li><li>The build file may be missing a Gradle plugin.
Apply Gradle plugin</li>
You can solve it this solutions, try this,
build.gradle (Project) file buildscript and allprojects area
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
build.gradle (Module) file dependencies area
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-compat:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
}
As you can read in the official doc, the implementation() DLS requires (currently)
Gradle v.4
Android Studio 3.x.
Gradle plugin for Android 3.x
Try to use in gradle-wrapper.properties use:
distributionUrl=\
https\://services.gradle.org/distributions/gradle-4.1-rc-1-all.zip
As gradle plugin for Android use:
classpath 'com.android.tools.build:gradle:3.0.0-beta1'
More information about the migration to plugin v3 here.
If you want to use "compile" and android studio 2.3, use this:
compile 'com.facebook.android:facebook-login:4.28.0'
That work for me.
I have solved it like this:
compile 'com.facebook.android:facebook-login:4.28.0'
You need android studio 3.0 to use "implementation" but with android studio 2.3 work with "compile"
P.D.: Sorry my english.