I really need your help, I am facing this error when I'm trying to build github project :
[ERROR]: Unsupported method: GradleProject.getProjectDirectory()
and this is my build.gradle(project)
// 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:0.13.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
and this is build.gradle(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "me.pntutorial.pnrtcblog"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
// TODO: Uncomment the following compilation lines
compile 'io.pristine:libjingle:9694#aar'
compile 'com.pubnub:pubnub-android:3.7.4'
compile 'me.kevingleason:pnwebrtc:1.0.6#aar'
}
and this is github project link
https://github.com/GleasonK/android-webrtc-tutorial
Task 'Xmx512m' not found in root project 'MyProject'
in gradle.properties it's showing Xmx1024m.
How can i get rid off this gradle build error?
My OS is windows 10.
build.gradle Module
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "in.ravisir.mateinstitute"
minSdkVersion 17
targetSdkVersion 24
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
productFlavors {
}
}
dependencies {
compile 'com.android.support:support-v4:24.1.1'
compile 'com.google.android.gms:play-services-ads:10.0.1'
compile 'com.android.support:appcompat-v7:24.1.1'
compile 'com.google.firebase:firebase-messaging:10.0.1'
compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-appindexing:10.0.1'
}
apply plugin: 'com.google.gms.google-services'
build.gradle Myapplication
// 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.2.3'
classpath 'com.google.gms:google-services:3.0.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Right now I am trying to integrate Fabric with Crashlytics (https://docs.fabric.io/android/fabric/integration.html) into an existing android application.
Following the integration instructions provided by Fabric I add apply plugin: 'com.android.application' to the root directory of my "build.grade (Project.NumenuApp)" file. I click to Sync Gradle, it fails, and I receive this error Error:Cause: buildToolsVersion is not specified. Android studio states that my plugins should be declared at the Module not Project level.
I already have the buildTools set in the "build.grade (Module:app)" file. My question is why is this happening and what can I do to remedy it? I have posted my code below. Thanks in advance. - Adrian
build.grade (Project:NumenuApp)
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
allprojects {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.grade (Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.numenu.numenuapp"
minSdkVersion 21
targetSdkVersion 23
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:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:recyclerview-v7:23.1.1'
}
You have to remove these lines from your build.gradle (Project:NumenuApp). You are using the wrong file to apply the plugins.
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
Also move these lines in your build.gradle (Module:app)
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
this is my build.gradle(Module:app) file and I have a working CrashLytics, and I have nothing related to fabrics in my project.gradle
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
//apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.ws.cs"
minSdkVersion 14
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
abiFilters "armeabi-v7a", "x86"
}
packagingOptions {
exclude "/lib/arm64-v8a/librealm-jni.so"
}
}
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:23.1.1'
compile 'com.google.code.gson:gson:2.2.2'
compile 'io.realm:realm-android:0.82.1'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar') {
transitive = true;
}
}
Please check this line in your app.gradle present or not
buildToolsVersion "25.0.3"
Example
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "kc.care.task"
minSdkVersion 20
targetSdkVersion 25
versionCode 23
versionName "3.7"
multiDexEnabled = true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
I know this question was answer before but non of the them worked for me. The app compiles and run perfectly but this warning it's annoying. Basicly defaultConfig, buildTypes, packagingOptions and dependencies in mobile gradle, and dependencies in top level gradle all give the cannot be applied to (groovy.lang.Closure) warning:
Top level gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.google.gms:google-services:1.3.0-beta1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
mobile gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "net.udazz.udazz"
minSdkVersion 11
targetSdkVersion 22
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'LICENSE.txt'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services-gcm:7.5.+'
compile 'com.android.support:appcompat-v7:22.2.1'
// Testing dependencies
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.1'
androidTestCompile 'com.android.support.test:runner:0.2'
androidTestCompile 'com.android.support:support-annotations:22.2.1'
}
I had the same problem, updating to gradle 1.3.1 worked for me.
classpath 'com.android.tools.build:gradle:1.3.1'
This is an old question which is irrelevant today. See Android developer's instruction. Applying Databinding to your projects is a lot easier now than four years ago.
As I am going over Android Data binding Guide from https://developer.android.com/tools/data-binding/guide.html. I have made sure I am running Android Studio 1.3 (canary version).
Following the guidelines, I get this error:
Gradle sync failed: could not find com.android.databinding:library:1.0-rc0
Has anyone else have the same problem? Thanks for your help.
App build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0-beta1'
classpath "com.android.databinding:dataBinder:1.0-rc0"
}
}
allprojects {
repositories {
jcenter()
}
}
Module build.graddle
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
apply plugin: 'android-apt'
def AAVersion = '3.3'
def MyProject = 'com.commonsware.android.frw.filesdemo'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
}
}
repositories {
mavenCentral()
}
apt {
arguments {
androidManifestFile variant.outputs[0].processResources.manifestFile
resourcePackageName "$MyProject"
}
}
android {
compileSdkVersion 22
buildToolsVersion "22"
defaultConfig {
applicationId "$MyProject"
minSdkVersion 17
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions{
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE'
exclude 'META-INF/services/com.fasterxml.jackson.core.JsonFactory'
}
dexOptions {
preDexLibraries = false
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile "com.squareup:otto:1.3.6"
compile "commons-io:commons-io:+"
compile 'com.fasterxml.jackson.jr:jackson-jr-all:2.5.0'
compile 'com.astuetz:pagerslidingtabstrip:1.0.1'
apt "org.androidannotations:androidannotations:$AAVersion"
compile "org.androidannotations:androidannotations-api:$AAVersion"
}
I had this problem and solved it by adding "jcenter" under allprojects.repositories in my top-level build.gradle (I had been using mavenCentral).
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.android.databinding:dataBinder:1.0-rc1'
}
}
allprojects {
repositories {
mavenCentral()
jcenter() // <=== *** Adding this fixed it ***
}
}
I got errors when I sync build.gradle files.
Error:Failed to resolve: com.android.databinding:library:1.0-rc0
Error:Failed to resolve: com.android.databinding:adapters:1.0-rc0
And I finally found the solution.
dependencies {
// instead of the below pathes...
//classpath "com.android.tools.build:gradle:1.3.0-beta2"
//classpath "com.android.databinding:dataBinder:1.0-rc0"
// I used the following classpathes.... It works!
classpath "com.android.tools.build:gradle:1.3.+"
classpath "com.android.databinding:dataBinder:1.+"
}
By looking at your error Gradle couldn't find com.android.databinding:dataBinder:1.0-rc0 you should try this instead,
classpath "com.android.databinding:dataBinder:1.0-rc1"
To use DataBinding follow all these steps.
Update your Android Studio to Android Studio 1.3 version.
To set up your application to use data binding, add data
binding to the class path of your top-level build.gradle file,
right below "android".
dependencies {
classpath "com.android.tools.build:gradle:1.3"
classpath "com.android.databinding:dataBinder:1.0-rc1"
}
Then make sure jcenter is in the repositories list for your projects
in the top-level build.gradle file.
allprojects {
repositories {
jcenter()
}
}
In each module you want to use data binding, apply the plugin right
after android plugin.
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
Clean and build your app.
Complete code
top-level build.gradle file,
// 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'
classpath "com.android.databinding:dataBinder:1.0-rc1"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
module-level build.gradle file,
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.example.packagename"
minSdkVersion 15
targetSdkVersion 22
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:22.2.1'
}
For more detail Data Binding Guide.
For Complete demo Data Binding Android
Make sure you have Android Studio 1.3 or higher
Your project build.gradle should look something like this:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0-beta1'
classpath "com.android.databinding:dataBinder:1.0-rc0"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
And your module build.gradle should look something like this:
apply plugin: 'com.android.application'
apply plugin: 'com.android.databinding'
android {
compileSdkVersion 22
buildToolsVersion "22.0.1"
defaultConfig {
applicationId "com.my.appId"
minSdkVersion 15
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
}
I had a problem where I was targeting M Preview so nothing worked. Once I changed the build tools to 22.0.1, and the targetSdkVersion to 22, everything worked.
I had the same issue and solved it by updating android sdk tools to 24.3.3.
Update for latest Android Studio & latest Gradle
You don't need to add databinding:dataBinder dependency now. Just enable dataBinding in app level build.gradle in android tag.
android
{
...
dataBinding {
enabled = true
}
...
}
As the Documentation said
To use data binding, Android Plugin for Gradle 1.5.0-alpha1 or higher
is required.
I have added the following line to build.gradle project :
// 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.5.0-beta2"
// 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
}
and then add the :
dataBinding {
enabled = true
}
to your build.graddle module app like this :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "gujarat.databinding"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
}
Please, try to change classpath to 'com.android.tools.build:gradle:1.3.0-beta2' and set buildToolsVersion "23 rc2".
Don't forget to update SDK packages via SDK manager before doing that.
Here you can find more information about Android Preview SDK: Set Up the Preview SDK
I had an identical issue, and solved it by removing the plugin for android-apt. Not sure what's conflicting there, but something is.
You should update your SDK and It will resolve this issue.
You should add
classpath 'com.android.tools.build:gradle:1.3.0'
classpath "com.android.databinding:dataBinder:1.0-rc0"
build.grade which in project Directory.
then Sync the gradle
Sync your project after adding classpath