android error : Gradle sync failed: Gradle DSL method not found: 'classpath()' - java

hi i'm newbie with Android studio, after updating from android studio 1.4 to 2.1, I am getting the following build error when I try and sync my project:
Gradle sync failed: Gradle DSL method not found: 'classpath()'
and Here is the build.gradle:
apply plugin:'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "android.arisa.---------"
minSdkVersion 11
targetSdkVersion 23
versionCode 1
versionName "1.0"
//multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile('cn.trinea.android.view.autoscrollviewpager:android-auto-scroll-view-pager:1.1.2') {
exclude module: 'support-v4'
}
compile('com.afollestad.material-dialogs:core:0.8.1.0#aar') {
transitive = true
}
compile('com.afollestad.material-dialogs:commons:0.8.1.0#aar') {
transitive = true
}
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.google.android.gms:play-services-maps:7.8.0'
compile 'com.google.android.gms:play-services-location:7.8.0'
//compile 'com.android.support:multidex'
//compile 'com.mcxiaoke.volley:library-aar:1.0.0'
//compile 'com.mcxiaoke.volley:library:1.+'
compile files('/Users/Bmaster/AndroidStudioProjects/KalahroodFinal/.idea/libraries/jsoup-1.8.3.jar')
compile files('/Users/Bmaster/AndroidStudioProjects/KalahroodFinal/jsoup-1.8.3.jar')
compile files('/Users/Bmaster/AndroidStudioProjects/KalahroodFinal/libraries/jsoup-1.8.3.jar')
compile 'com.google.android.gms:play-services:8.3.0'
}
repositories {
jcenter()
}
//repositories {
// maven { url "https://jitpack.io" }
//}
and the gradle-wrapper.properties is:
#Sat Apr 30 11:59:41 2016
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.10-all.zip
#distributionUrl=https\://services.gradle.org/distributions/gradle-2.12-all.zip
How can i correct this?(please help me)
edit: After editing grade, my android gradle is:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "android.arisa.kalahroodfinal"
minSdkVersion 10
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile('cn.trinea.android.view.autoscrollviewpager:android-auto-scroll-view-pager:1.1.2') {
exclude module: 'support-v4'
}
compile('com.afollestad.material-dialogs:core:0.8.1.0#aar') {
transitive = true
}
compile('com.afollestad.material-dialogs:commons:0.8.1.0#aar') {
transitive = true
}
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:support-v4:23.0.1'
compile 'com.google.android.gms:play-services-maps:7.8.0'
compile 'com.google.android.gms:play-services-location:7.8.0'
compile files('/Users/Bmaster/AndroidStudioProjects/KalahroodFinal/.idea/libraries/jsoup-1.8.3.jar')
compile files('/Users/Bmaster/AndroidStudioProjects/KalahroodFinal/jsoup-1.8.3.jar')
compile files('/Users/Bmaster/AndroidStudioProjects/KalahroodFinal/libraries/jsoup-1.8.3.jar')
compile 'com.google.android.gms:play-services:8.3.0'
}
but i have new error:
Error:(43, 13) Failed to resolve: com.afollestad.material-dialogs:commons:0.8.1.0
Error:(40, 13) Failed to resolve: com.afollestad.material-dialogs:core:0.8.1.0

Try to remove the classpath 'com.android.tools.build:gradle:2.1.0' string.
I also would recommend you to create new project in Android studio 2.1 and compare the gradle files generated by IDE with yours.

You are using
classpath 'com.android.tools.build:gradle:2.1.0'
in the wrong block.
More it in the top-level build.gradle file (in the root of your 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:2.1.0'
}
}
To solve the issue with the library material dialog you have to add the repository from which download the dependencies:
In your top-level build.gradle file add the jitpack repo:
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}

Related

Unable to Merge Dex Android Studio 3.0 after update

updated my project to gradle 3 and generated this error
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
in another questions says "libraries having transitive dependency " but i don't find the library with this transitive dependency
in gradle 2.3 don't show this error
build.gradle app
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
compileOptions.encoding = 'UTF-8'
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.my.my"
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
sourceSets {
main {
jni.srcDirs = ["libs"]
}
}
packagingOptions {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':dd-plist')
compile project(':Emojicon')
compile project(':CameraModule')
compile project(':ScapeUtils')
compile project(':circleimageview')
compile project(':FFMPG')
compile project(':PdfViewer')
compile project(':LibLinphone')
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.github.bumptech.glide:glide:3.6.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.github.ornolfr:rating-view:0.1.1#aar'
compile 'cat.ereza:customactivityoncrash:1.5.0'
compile 'com.writingminds:FFmpegAndroid:0.3.2'
compile 'com.google.firebase:firebase-messaging:11.0.4'
compile "com.android.support:appcompat-v7:26.1.0"
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support:design:26.1.0'
compile 'com.google.android.gms:play-services:11.0.4'
compile 'org.apache.commons:commons-io:1.3.2'
}
apply plugin: 'com.google.gms.google-services'
build.gradle project
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
classpath 'com.google.gms:google-services:3.0.0'
}
I am battling also with this or similar problem. I have set to use the old gradle version manually. From File/Project structure/projet I have put gradle version 3.4.1 and plugin version 2.3.3
I have also added multiDexEnabled true in app/build.gradle inside defaultConfig Hth

Failed to resolve dependency conciseclock

Actually, it worked but I did not understand and I get an error. How can I fix it?
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "com.example"
minSdkVersion 18
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
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:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.github.:conciseclock:0-SNAPSHOT'
testCompile 'junit:junit:4.12'
}
and
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
allprojects {
repositories {
jcenter()
maven{ url 'https://dl.bintray.com/spark/maven' }
maven { url "https://jitpack.io" }
mavenCentral()
}
}
task customClean(type: Delete) {
delete rootProject.buildDir
}
Error:A problem occurred configuring project ':app'.
Could not resolve all dependencies for configuration ':app:_debugApkCopy'.
Could not find com.:conciseclock:0-SNAPSHOT.
Required by:
project :app
Error(37,13) Failed to resolve: com.:conciseclock:0-SNAPSHOT
Try with compile 'com.tomduan.conciseclock:library:0.2.2'
Anyway, where did you get this snapshot, because it looks like you are using custom repository manager, not official git.
easy there is no library on this dependences
com.github.zurnacibatuhan:conciseclock:0-SNAPSHOT
or i recommend to check library version so there is no number version as
0-SNAPSHOT
or replace with this line
compile 'com.tomduan.conciseclock:library:0.2.2'
you are using 25.3.1 version in your dependencies.it means you should first add this to your project gradle repositories like this
allprojects {
repositories {
jcenter()
maven{ url 'https://dl.bintray.com/spark/maven' }
maven { url "https://jitpack.io" }
maven {url "https://maven.google.com"}
}
add line
maven {url "https://maven.google.com"}
after that you should replace this line:
compile 'com.github.zurnacibatuhan:conciseclock:0-SNAPSHOT'
with this line:
compile 'com.tomduan.conciseclock:library:0.2.2'

Unable to delete old javaCompile action, maybe the class name has changed

I am learning RxJava. For that i followed droidcon talk video on RxJava. The instructor has given repo link for the project he was using. I cloned the repo when i try to build project in my machine. I get this error
Error:Unable to delete old javaCompile action, maybe the class name
has changed? Please submit a bug report with what version of gradle
you are using.
Here is gradle.build file
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:2.5.0'
}
}
repositories {
mavenCentral()
maven { url "https://github.com/alter-ego/advanced-android-logger/raw/develop/releases/" }
}
apply plugin: 'retrolambda'
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "25.0.0"
defaultConfig {
applicationId "com.packtpub.apps.rxjava_essentials"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
jackOptions {
enabled true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
disable 'InvalidPackage'
abortOnError false
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.1.1'
compile "com.android.support:appcompat-v7:23.1.1"
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.jakewharton.timber:timber:4.1.0'
compile 'org.projectlombok:lombok:1.14.8'
compile 'com.jakewharton:butterknife:6.0.0'
compile 'io.reactivex:rxandroid:1.1.0'
compile 'io.reactivex:rxjava:1.1.0'
compile 'io.reactivex:rxjava-joins:0.22.0'
compile 'com.google.guava:guava:18.0'
compile 'com.google.code.gson:gson:2.4'
compile 'com.github.lzyzsd:circleprogress:1.1.0#aar'
compile 'com.github.rey5137:material:1.0.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
}
Any idea how can i fix this issue?
The problem comes from RetroLambda plugin (see line 108 in this link).
I assume upgrading plugin version would resolve your issue:
classpath 'me.tatarka:gradle-retrolambda:3.6.1'
Try this one on app/build.gradle
Reference on github
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.4.0'
}
}
repositories {
mavenCentral()
maven { url "https://github.com/alter-ego/advanced-android-logger/raw/develop/releases/" }
}
apply plugin: 'com.android.application'
apply plugin 'me.tatarka:gradle-retrolambda:3.4.0'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.packtpub.apps.rxjava_essentials"
minSdkVersion 16
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
lintOptions {
disable 'InvalidPackage'
abortOnError false
}
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:support-v4:23.1.1'
compile "com.android.support:appcompat-v7:23.1.1"
compile 'com.android.support:recyclerview-v7:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.jakewharton.timber:timber:4.1.0'
compile 'org.projectlombok:lombok:1.14.8'
compile 'com.jakewharton:butterknife:6.0.0'
compile 'io.reactivex:rxandroid:1.1.0'
compile 'io.reactivex:rxjava:1.1.0'
compile 'io.reactivex:rxjava-joins:0.22.0'
compile 'com.google.guava:guava:18.0'
compile 'com.google.code.gson:gson:2.4'
compile 'com.github.lzyzsd:circleprogress:1.1.0#aar'
compile 'com.github.rey5137:material:1.0.0'
compile 'com.squareup.retrofit:retrofit:1.9.0'
compile 'com.squareup.okhttp:okhttp-urlconnection:2.0.0'
compile 'com.squareup.okhttp:okhttp:2.0.0'
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
}

Error: package com.lapism.searchview.view does not exist

I have used searchview in my project with dependency compile 'com.lapism:searchview:3.0.2' in build.gradle file. But while I'm trying run the application I'm getting an error
Error: package com.lapism.searchview.view does not exist
Error:
cannot find symbol class SearchView
Error:Execution failed for task
':app:compileDebugJavaWithJavac'.
My current android version is 2.1
My Build.gradle File:
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'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
multiDexEnabled true
applicationId "pingo.betnek.mobigrab"
minSdkVersion 16
targetSdkVersion 15
versionCode 2
versionName "1.1"
}
dexOptions
{
incremental true
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'),'proguard-rules.pro'
}
}
}
repositories {
jcenter()
mavenCentral()
maven {
url "https://jitpack.io"
}
maven { url 'https://maven.fabric.io/public' }
}
dependencies
{
provided fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile files('libs/activation.jar')
compile files('libs/additionnal.jar')
compile files('libs/mail.jar')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'io.realm:realm-android:0.87.2'
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.lapism:searchview:3.0.2'
compile 'com.googlecode.libphonenumber:libphonenumber:7.2.7'
compile 'com.android.support:multidex:1.0.1'
compile('com.crashlytics.sdk.android:crashlytics:2.5.5#aar')
{
transitive = true;
}
}
Show us your code usage..
In any case, change com.lapism.searchview.view.SearchView to com.lapism.searchview.SearchView, or just remove the imports and let Android Studio re-import them with the correct namings.
It has been refactored since 2.3 or whatever version..

com.google.gms.google-services not adding class GoogleSignInOptions

It is very simple and the problem might be fundimental
i want to use GoogleSignInOptions, GoogleSignInResult, and Auth to implement google+ signin.
i am following the guides here are the gradle builds:
project build:
// 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:1.3.0'
classpath 'com.google.gms:google-services:1.3.0-beta1'
}
}
allprojects {
repositories {
jcenter()
maven { url "http://jzaccone.github.io/SlidingMenu-aar" }
}
}
app build:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.ili.BDigital"
minSdkVersion 14
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile project(':eventBrowser')
}
library (extra module) build:
apply plugin: 'com.android.library'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.google.android.gms:play-services:8.4.0'
compile 'com.squareup.okhttp3:okhttp:3.1.2'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:design:23.1.1'
compile 'com.google.code.gson:gson:2.3'
compile 'com.etsy.android.grid:library:1.0.5'
compile 'com.jeremyfeinstein.slidingmenu:library:1.3#aar'
compile 'com.jakewharton:butterknife:4.0.1'
compile 'com.pubnub:pubnub:3.7.5'
compile 'com.nineoldandroids:library:2.4.0'
compile 'com.wefika:horizontal-picker:1.1.0'
compile 'com.facebook.android:facebook-android-sdk:4.5.0'
compile files('libs/com.haarman.listviewanimations-2.5.2.jar')
compile files('libs/google-play-services.jar')
compile files('libs/htmlcleaner-2.8.jar')
compile files('libs/socialauth-4.9.jar')
compile files('libs/socialauth-android-3.2.jar')
}
/*
compile 'com.pubnub:pubnub-android-debug:3.7.+'
compile 'javax.inject:javax.inject:1#jar'
compile 'com.squareup.dagger:dagger-compiler:1.1.0'
compile 'com.jakewharton:butterknife:4.0.1'
compile 'com.squareup.dagger:dagger:1.1.0'
compile 'com.github.pedrovgs:renderers:1.0.9'
compile 'com.google.gms:google-services:2.0.0-rc1'
*/
I've been stuck on this for a day and it's driving me insane
UPDATE: I removed "compile files('libs/google-play-services.jar')" and now even R is giving me "cannot resolve symbol"
Try to add this line in the bottom of your build.gradle file (which you import your dependency)
apply plugin: 'com.google.gms.google-services'

Categories