After updating to Android Studio 2.3 trying to build the project causes a build failure.
Execution failed for task ':app:greendao'.
org.eclipse.jdt.internal.compiler.impl.CompilerOptions.versionToJdkLevel(Ljava/lang/Object;)J
How to solve this issue?
The solution is to move
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.0'
form app/build.gradle into top level build.gradle file.
Example:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.0'
classpath 'org.greenrobot:greendao-gradle-plugin:3.2.0'
}
}
Related
I am completely new to android and kotlin programming. I just started learning android since yesterday. I have successfully created a project but it doesn't show me xml editor.
Error:Execution failed for task ':app:preDebugAndroidTestBuild'.
Conflict with dependency 'com.android.support:support-annotations' in project ':app'. Resolved versions for app (26.1.0) and test app (27.1.1) differ. See https://d.android.com/r/tools/test-apk-dependency-conflicts.html for details.
build.gradle
buildscript {
ext.kotlin_version = '1.1.51'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.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
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Any idea to solve this problem
configurations.all {
resolutionStrategy {
force 'com.android.support:support-annotations:26.1.0'
}
}
Add the above line in your app.gradle file before dependencies block & replace compile to implementation.
In Android Studio , click on Terminal and execute this command.
gradlew app:dependencies
and then search for com.android.support:support-annotations.
Then in your app level gradle file , exculude the com.android.support:support-annotations dependency from the dependency which has the older version i.e 26.1.0. To learn how to exuclude go here.
I've got two workstations with Android Studio installed. The first one is having version 2.3.3, but the other one is having version 3.0. Both of them are using Gradle 3.3. The problem that I am facing is that when I create an application on the 3.0 system and then transfer it to the 2.3.3 it doesn't want to build. I am receiving
Could not resolve all dependencies for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:3.0.0.
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.jar
I compared a build.gradle file created from the older version of Android Studio and from the newer version
3.0 version:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
2.3.3:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
allprojects {
repositories {
jcenter()
}
}
From the 3.0 version, I removed "google()", because it was also failing.
I am new to Android Development and I would really appreciate it if you can help me to solve my problem of using one project on both of the environments.
Could not resolve all dependencies for configuration ':classpath'. > Could not find com.android.tools.build:gradle:3.0.0. Searched in the following locations: https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0/gradle-3.0.0.pom
It happens because you are using the wrong repository.
If you want to use android plugin for gradle 3.x you have to use:
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
It requires also gradle v4.+ using in gradle/wrapper/gradle-wrapper.properties :
distributionUrl=\
https\://services.gradle.org/distributions/gradle-4.1-all.zip
If you are using Android Studio 2.x you have to change the repository google() with maven { url "https://maven.google.com" }
If you want to use the android plugin for gradle 2.3.x you can use:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.3'
}
}
and you can use gradle v.3.3 with:
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Of course in this case you can't use the new DSL introduced with gradle v.4.x and the plugin 3.x for example the implementation() and api() DSL.
Android plugin 3.0 located in Google Maven Repository (google() line) and it requires new Gradle. You should update Gradle to version 4.1.
Open file gradle/wrapper/gradle-wrapper.properties and set
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
If you are using android studio <3.0 then go to gradle-wrapper.properties and change the gradle from 4.1 to 3.3.
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Go to top level gradle and change the gradle version from 3.0.0 to 2.3.3 and then it should work fine.
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
If you are using android studio >3.0 then Go to gradle-wrapper.properties and change the gradle to 4.1.
distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip
Go to top level gradle and change the gradle version from 3.0.0 and then it should work fine.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
I update the gradle plugin to the latest, and i'm getting this error:
Error:Could not find com.android.tools.build.gradle:3.0.0-alpha7:.
Searched in the following locations:
file:/C:/Users/dmin/Documents/android-studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha7//3.0.0-alpha7-.pom
file:/C:/Users/dmin/Documents/android-studio/gradle/m2repository/com/android/tools/build/gradle/3.0.0-alpha7//3.0.0-alpha7-.jar
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha7//3.0.0-alpha7-.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.0.0-alpha7//3.0.0-alpha7-.jar
https://maven.google.com/com/android/tools/build/gradle/3.0.0-alpha7//3.0.0-alpha7-.pom
https://maven.google.com/com/android/tools/build/gradle/3.0.0-alpha7//3.0.0-alpha7-.jar
Here's my build.gradle
buildscript {
repositories {
jcenter()
maven { url 'https://maven.google.com' }
}
dependencies {
classpath 'com.android.tools.build.gradle:3.0.0-alpha7'
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Where i'm getting wrong? since i modified my gradle.build according to the question Could not find com.android.tools.build:gradle:3.0.0-alpha1 in circle ci
thank you!!
-- Updated the build.gradle according to Mr Tim, but i'm still having the same error
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build.gradle:3.0.0-alpha7'
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
jcenter()
}
}
Follow the steps in the 3.0.0 plugin migration guide
Update gradle version
The new Android plugin requires Gradle version 4.1-milestone-1 or
higher. If you're opening an existing project using Android Studio 3.0
Preview 5 or later, follow the prompts to automatically update an
existing project to the compatible version of Gradle.
To update Gradle manually, update the URL in gradle-wrapper.properties
as follows:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-milestone-1-all.zip
and
Apply the plugin
If you're opening an existing project using Android
Studio 3.0 Preview 5 or later, follow the prompts to automatically
update your project to the latest version of the Android plugin. To
manually update your project, include the maven repo and change the
plugin version in your project-level build.gradle file as follows:
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.1' //Minimum supported Gradle version is 4.6
}
}
You try :
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
Credits: https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html
If you're in Android Studio 3.1 or higher, you're likely encounter such type of issue prompting by a Build window.
Simply click on the Add Google Maven repository and sync project option at right side and initiate another gradle sync.
It'll make the necessary changes in both gradle-wrapper.properties as well as build.gradle files.
Update gradle plugin : in gradle.properties file
add this line
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
then apply ther plugin in build.gradle file :
buildscript {
repositories {
...
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
}
}
the distributionUrl property inside gradle-wrapper.properties should be:
distributionUrl=https\://services.gradle.org/distributions/gradle-4.1-all.zip
that works for me
open the file path(just as the log said):
file:/C:/Users/dmin/Documents/android-studio/gradle/m2repository/com/android/tools/build/gradle/
found this file
just change classpath 'com.android.tools.build.gradle:3.0.0-alpha7'
to classpath 'com.android.tools.build.gradle:* * * ' ; * * * is the exist gradle file;
this problem is because of gradle file do not found
I'm trying to update gradle from 1.3.1 to 3.5, as some of my dependencies requires version 3.3 or above.
I've seen similar questions, but none of them help.
build.gradle:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5'
}
}
gradle-wrapper.properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
Still i'm getting this when trying to do anything (build, clean etc):
Building and installing the app on the device (cd android && ./gradlew installDebug...
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring root project 'chat'.
> Could not resolve all dependencies for configuration ':classpath'.
> Could not find com.android.tools.build:gradle:3.5.
Searched in the following locations:
https://jcenter.bintray.com/com/android/tools/build/gradle/3.5/gradle-3.5.pom
https://jcenter.bintray.com/com/android/tools/build/gradle/3.5/gradle-3.5.jar
Required by:
project :
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
To fix this issue check do you have google() repo in your project's level build.gradle file.
buildscript {
repositories {
jcenter()
google() //HAVE YOU MISS IT?
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
}
}
allprojects {
repositories {
jcenter()
google() //HAVE YOU MISS IT?
}
}
There is a difference between the Android Plugin for Gradle version and the Gradle version being used. The plugin version typically matches the version number of Android Studio you are using. See the documentation for more information. So if using the latest stable Android Studio it should currently be com.android.tools.build:gradle:2.3.1.
These values can also be reviewed and set from the Project Structure window in Android Studio.
Try this
** If you are using android studio 3.5 and your build.gradle(Project
level) is=> classpath 'com.android.tools.build:gradle:3.5.1' or =>
classpath 'com.android.tools.build:gradle:3.5.1'.
than replace with ***
classpath 'com.android.tools.build:gradle:3.3.2' to
classpath 'com.android.tools.build:gradle:3.5.0'
OR
classpath 'com.android.tools.build:gradle:3.5.1'
I had google() repo both in buildscript and allprojects repositories, but still it shows me Could not find gradle-3.5.3 error
Finally I added maven { url "https://maven.google.com" }, and it fixed the errors!
project's level build.gradle:
buildscript {
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 16
compileSdkVersion = 29
targetSdkVersion = 29
}
repositories {
maven { url "https://maven.google.com" } // <= this line
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.3")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven { url "https://maven.google.com" } // <= this line
mavenLocal()
maven {
// All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
url("$rootDir/../node_modules/react-native/android")
}
maven {
// Android JSC is installed from npm
url("$rootDir/../node_modules/jsc-android/dist")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
You may need to save your build.gradle (for whatever reason, Android Studio doesn't always save your latest changes, as I found even with Android Studio 3.5.3, the gradle sync kept failing even after I had changed the classpath line, and it only picked up the new value after saving the build.gradle file)
I got an error after changing version code from 2 to 2.1.
When I opened the build with ctrl+shift+alt+s, I realized adding .1 (decimals) resulted in a $ symbol being added to the right and so build failed. I opted to use numbers without decimal positions and it worked.
For example, I used 3 for buildversion because I wanted to upgrade the app in playstore.
I got following Error if I try to add dependency in Top - level build.gradle file. This dependency is very much useful to add GCM in project without it GCM won't work:
Dependency :
classpath 'com.google.gms:google-services:1.5.0-beta2'
Error :-
Error:Execution failed for task ':app:mergeDebugResources'.
> Some file crunching failed, see logs for details
If I remove that dependency from top-level build.gradle the project compiles and run successfully.
If I add that file I got the error and Android Studio do not run project.
Please help me to get out of this error.
Edit
Here is my project 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:2.0.0-alpha6'
classpath 'com.android.tools.build:gradle:2.0.0-beta5'
classpath 'com.google.gms:google-services:2.0.0-beta5'
// 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
}
try Changing latest version of dependency from HERE:
classpath 'com.google.gms:google-services:2.0.0-beta5'
Also make sure you are setting correct Gradle plugin dependency as well in root project gradle file.
classpath 'com.android.tools.build:gradle:2.0.0-beta5'
So, your final project build.gradle file will look like
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-beta5'
classpath 'com.google.gms:google-services:2.0.0-beta5'
}
Try this it should help.
buildTypes {
release {
multiDexEnabled true;
}
}
in your Gradle log, if you're getting bad/invalid PNG file then take a look at my answer at Android Studio Gradle 2.0.0-alpha1 build errors
Hope this helps...