android studio - Gradle DSL method not found: 'compile()' Error:(36,0) - android

Hi people i have the following error on the title im so done of searching for a solution and still got nothing :'( this is a project for my company and it is 1 month of work please help me I really need my project back .
This is my build.gradle:
apply plugin: 'com.android.application'
buildscript {
repositories {
jcenter() // or mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-alpha3'
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.0 rc3"
defaultConfig {
applicationId "nunoalmeida.atphc"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
buildscript {
repositories {
jcenter() // or mavenCentral()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.google.android.gms:play-services:6.5.+'
}
}
}

Replace this , it worked for me
classpath 'com.android.tools.build:gradle:2.2.0'

buildscript {
repositories {
jcenter() // or mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.0-alpha3'
}
}
cut this code from your module level build.gradle file and paste it to your project level build.gradle file.
it worked for me.

Download the Gradle distribution and read the "User Guide" PDF from top to bottom and save yourself the time that you'll spend asking questions.
If you do that, you'll find that buildscript dependencies are set with "classpath", not "compile".

Related

failed to resolved support-vector-Drawable

I have project which was working fine till yesterday but this morning when i try to build it keeps throwing failed to resolved support-vector-Drawable error.
I try to clean and this error shows up
Error:Could not resolve all files for configuration ':app:debugCompileClasspath'.
Could not find support-vector-drawable.aar (com.android.support:support-vector-drawable:26.0.2).
Searched in the following locations:
https://jcenter.bintray.com/com/android/support/support-vector-drawable/26.0.2/support-vector-drawable-26.0.2.aar
and here is my gradle
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.arizeh.arizehplus"
minSdkVersion 17
targetSdkVersion 22
multiDexEnabled true
versionCode 29
versionName "3.0.5"
useLibrary 'org.apache.http.legacy'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dependencies {
compile 'com.android.support:appcompat-v7:26+'
testCompile 'junit:junit:4.12'
compile 'com.android.support:design:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
}
and here is my level build.gradle file
buildscript {
repositories {
google()
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
classpath 'com.google.gms:google-services:3.2.1'
classpath 'io.fabric.tools:gradle:1.24.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven { url 'http://jhoobin.abroid.com/repo/' }
maven { url "https://jitpack.io" }
maven {
url "https://maven.google.com"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Hi as per my understanding please try bellow tow thing one
One is replacing your app compact version dependancy with specific version else of plus
compile 'com.android.support:appcompat-v7:26+'
Replace with (Please set as per your build tool)
compile 'com.android.support:appcompat-v7:26.1.0'
And Another thing try updating your build tool version.
so after half day searching and rebuild finally it fixed by upgrading my compileSdkVersion and all other library to 27 ... I hope this help any one who has this problem
defaultConfig {
defaultConfig {
vectorDrawables.useSupportLibrary = true
}
}
Change to
defaultConfig {
vectorDrawables.useSupportLibrary = true
}

Android Studio Gradle DSL method not found: 'compile()'

I am getting the following error:
Error:(4, 0) Gradle DSL method not found: 'compile()'
Possible causes:The project 'Jp' 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.
I tried looking to other similar questions, but nothing worked.
My build.gradle(Project:JP) file is below:
Error:(4, 0) Gradle DSL method not found: 'compile()'
buildscript {
repositories {
jcenter()
}
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
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(Module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.jal.jp"
minSdkVersion 19
targetSdkVersion 26
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 project(":sdk-audio-1.60.1")
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
}
build.gradle(sdk-audio-1.60.1)
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.jal.jp"
minSdkVersion 19
targetSdkVersion 26
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 project(":sdk-audio-1.60.1")
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
compile 'com.android.support:design:26.0.0-alpha1'
}
settings.gradle:
include ':app', ':sdk-audio-1.60.1'
can anyone help me to fix this?
Thanks
Your build gradle tools seem too old, change the following line in the root build.gradle:
classpath 'com.android.tools.build:gradle:1.5.0'
to
classpath 'com.android.tools.build:gradle:2.3.3'
And don't forget to add google maven to your build.gradle too:
maven { url "https://maven.google.com" }
This is because all support library are moved to maven as in the release note at https://developer.android.com/topic/libraries/support-library/revisions.html:
Important: The support libraries are now available through Google's
Maven repository. You do not need to download the support repository
from the SDK Manager. For more information, see Support Library Setup.
So then your root build.gradle will be something like this:
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()
maven { url "https://maven.google.com" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}

Gradle build failed for two dependencies

I am trying to build gradle with the following dependencies. but its not compiling. I have tried a lot by changing the versions by seeing forums. I search for the dependencies in project structure dialog and found the following two.
de.hdodenhof:circleimageview:2.0.0
com.mcxiaoke.volley:library-aar:1.0.1
Actually I am using two pc. This was build in another pc with following
de.hdodenhof:circleimageview:1.2.1
com.mcxiaoke.volley:library-aar:1.0.19
Still no luck and the gradle build taking 20-25 minutes each time
Main 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.5.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
}
App build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.map"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
mavenCentral()
}
dependencies {
compile('com.mapbox.mapboxsdk:mapbox-android-sdk:0.7.4#aar') {
transitive = true
}
compile 'de.hdodenhof:circleimageview:2.0.0'
compile 'com.mcxiaoke.volley:library:1.0.19'
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:recyclerview-v7:23.0'
}
This sounds like gradle is unable to reach the remote repository. Does your firewall block it, is your internet connection working,...?

Gradle couldn't find com.android.databinding:dataBinder:1.0-rc0

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

Android Studio: Repository defined in module not respected

I've got a project in Android Studio and I can't quite seem to figure out this gradle issue. My app structure is as follows:
app (module) relies on crashlib (module), crashlib relies on an AAR from an external repository which I have listed in crashlib's gradle file.
The problem is that when I go to compile the app the default repository (https://jcenter.bintray.com/) is used instead of the one defined in crashlib, so the build fails. If I add the repository definition from crashib to the app module then it builds successfully, but it's not ideal. I can also build crashlib successfully on its own.
Here is the crashlib build.gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.library'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 22
buildToolsVersion "21.1.2"
defaultConfig {
minSdkVersion 19
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.0.0'
compile('com.crashlytics.sdk.android:crashlytics:2.2.3#aar')
}
Any ideas how to get the repository to be used when building the app?
In your buildscript block you should use somenthing like this:
buildscript {
repositories {
jcenter()
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'com.android.tools.build:gradle:1.1.3'
classpath 'io.fabric.tools:gradle:1.+'
}
}

Categories

Resources