Facebook Integration in android giving compile() error - android

I am trying to add facebook login. I am following the facebook quick starts. But I am getting the following error.
`
Error:(24, 0) Gradle DSL method not found: 'compile()'
Possible causes:<ul><li>The project 'FacebookAdd' 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>`
and the gradle.build files.
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
mavenCentral()
}
}
dependencies {
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
}
task clean(type: Delete) {
delete rootProject.buildDir
}
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "com.psycho.ayush.facebookadd"
minSdkVersion 17
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
}
P.S. I have gone through almost every question related to this on this site.

It looks like you have two dependencies sections please try this:
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
}
and remove this
dependencies {
compile 'com.facebook.android:facebook-android-sdk:[4,5)'}

Related

How to handle error of "Could not find method android() on project ':app' of type org.gradle.api.Project"

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)
[

gradle is not resolving any new dependencies in android studio

I am making an Intro for my app.So after some research i had got an github project which is used to make cool intros.It requires following dependencies :
compile 'com.github.paolorotolo:appintro:4.0.0'
when I compile it with gradle it gives me following errors:
Failed to resolve: com.github.paolorotolo:appintro:4.0.0
I have done some research on internet but anything didn't worked out.
here is my build.gradle(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.1"
defaultConfig {
applicationId "com.example.adarsh.testapp"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:24.2.0'
compile 'com.android.support:support-v4:24.2.0'
compile 'com.github.paolorotolo:appintro:4.0.0'
}
and here is my build.gradle(project:testapp)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.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
}
I solved my issue by just adding mavenCentral() in repositories in build.gradle.

Add parse UI-widget but Gradle DSL Method not found: compile()

I'm trying to add the Parse UI widget by following the guide on https://github.com/ParsePlatform/ParseUI-Android. However, when I do that, I get an error that my project may be using a version of Gradle that does not contain the method and that the build file might be missing the Gradle plugin.
This is my Gradle module:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.joakim.boken"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs', include: 'Parse-*jar')
}
// Module dependency on ParseUI libraries sources
compile project(':ParseUI-Widget')
// Uncomment if using Facebook Login (optional Maven dependency)
// compile 'com.facebook.android:facebook-android-sdk:4.0.1'
// compile files('YOUR_PROJECT_LIBS_PATH/ParseFacebookUtilsV4-1.10.0.jar')
and this is my build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
Anybody know what I need to add or erase to get it working? I tried answers to similar questions, but so far nothing worked..
I'm not sure if it mattered that I downloaded the ZIP instead of cloning the repository?
You have to move this line inside the dependencies block:
compile project(':ParseUI-Widget')
It should be:
dependencies {
compile 'com.parse.bolts:bolts-android:1.+'
compile fileTree(dir: 'libs', include: 'Parse-*jar')
// Module dependency on ParseUI libraries sources
compile project(':ParseUI-Widget')
}

Error:(20, 0) Gradle DSL method not found: 'compile()'

I have looked at other related but none seems to Solve my Problem in Gradle.
Here is my Build Gradle (Module App )
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.abdul_000.project"
minSdkVersion 9
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/android-support-v13.jar')
compile 'com.android.support:appcompat-v7:22.0.0'
}
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
dependencies {
compile 'com.android.support:support-v4:19.0.0'
compile fileTree(dir: 'libs', include: ['*.jar'])
} apply plugin: 'application'
allprojects {
repositories {
jcenter()
}
}
}
The are it gives me
"Error:(20, 0) Gradle DSL method not found: 'compile()'
Possible causes:The project 'Project' may be using a version of Gradle that does not contain the method.
Open Gradle wrapper file
The build file may be missing a Gradle plugin. Apply Gradle plugin"
What am I doing wrong ?
You cannot add compile dependencies to global build.gradle file. Removing the second dependencies block in your global build.gradle file would fix the error.

Error:(22,0) Gradle DSL method not found: 'compile()'

Hi guys I'm having a problem Gradle DSL method not found: 'compile()'. Most of the discussions I read suggest that I add compile 'com.android.support:support-v4:21.+' to individual's module build file and in my case the compile 'com.android.support:support-v4:21.+' is already there. If I remove the one I added on the top most level build file I get this error (Error:Artifact 'support-v4.jar (com.android.support:support-v4:21.0.3)' not found. Android studio 1.0.2).
Please help, here are my gradle files:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
dependencies {
compile 'com.android.support:support-v4:21.+'
}
Gradle file under App folder:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.ntokozo.myapplication"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
}
Thank you.
Remove the dependencies block from the top level build.gradle file.
dependencies {
compile 'com.android.support:support-v4:21.+'
}
Also update your sdk files.

Categories

Resources