Gradle Sync Failed in Android Studio after 2.3 update - android

I just updated Android Studio to 2.3. An error is shown that one of the cache files in the Gradle folder cannot be accessed, hence the Gradle sync failed. I tried restarting Android Studio and re-downloading the Gradle files but it doesn't help. Here is a picture of the error:
https://i.stack.imgur.com/iYwAE.png

You need to update your build tools to 25.0.0. Edit your build.gradle file in the main module:
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
...
}
If that doesn't work, I recommend you to go back to Android Studio 2.2.3:
http://tools.android.com/download/studio/builds/android-studio-2-2-3

Related

Android Studio build fail with minSDK=29

I have Android Studio build problem.
Build fails only when changing the minSdk=29 with follwing error.
( It's OK with minSdk=28 )
android {
compileSdkVersion 29
defaultConfig {
applicationId "com.example.aaa"
minSdkVersion 29 // build fails with 29, it's OK with 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
Fail messages on Android Studio build console
- Build: build failed
- Run build :
...
Caused by: com.android.tools.r8.utils.AbortException
- Andriod issues: (1 error)
Dex file with version '38' cannot be used with min sdk level '29'.
If anyone resolved this problem, please share your know-hows.
Thank you.
I came across this recently when updating a project for Android studio 3.5.3 to 3.6.3, however I manually changed gradle-wrapper.properties and the project's build.gradle before even opening the project.
In my case I was able to clean the build, delete the .gradle and .idea folders and rebuild without issue.
Edit: As stated in the comments, it is worthwhile to try a clean-rebuild first, rather than the "Scorched Earth" approach of deleting .gradle and .idea folders. Deleting them will take longer to recover from and blow away all your nice IDE settings!
This is because of latest gradle version :
classpath 'com.android.tools.build:gradle:3.5.3'
in Android 6.0 and lower android versions. In order to fix it you can downgrade the gradle version as follows :
classpath 'com.android.tools.build:gradle:3.5.1'
It will run on all android versions perfectly.

Gradle 2.2.0 execution failed: SymbolForDebug

After upgrading gradle of my project (and library attached to it) from 2.1.3 -> 2.2.0 it doesn't build anymore and it says:
Error:Execution failed for task ':app:transformNative_libsWithStripDebugSymbolForDebug'.
java.lang.NullPointerException (no error message)
Anyone have a clue on why this is?
I found answer here:
https://stackoverflow.com/a/40117446/1088975
The point is to set both targetSdkVersion and compileSdkVersion to 22"
You need to change the following lines in build.gradle file:
android {
// SDK 24 worked for me - make sure you have the latest and update it accordingly.
compileSdkVersion 24
buildToolsVersion "24.0.2"
...
}
Maybe you can update the ndk version.
I update the ndk version from r10 to r13,and finally it worked.
You might want to check if the location of your NDK folder has any white space in it...if it has you can move your ndk folder to the c:\ drive and rebuild
Also, check the gradle versiom of your app and either upgrade or download later version, because some ndk versions do not support later gradle version

Android studio - gradle - failed to find target with hash string 'Google Inc.:Glass Development Kit Preview:19'

Failed to sync Gradle Project ‚HelloGlass‘
Error: Cause: failed to find target with hash string 'Google Inc.: Glass Development Kit Preview:19' in D:\Project\Android-SDK
Strangly, this error didn’t appear 3 days ago when I last built the project. I haven’t changed anything or used Android Studio since then.
These are the steps that I’ve tried to solve the issue:
restarted Android Studio and tried to build again
made sure that both gradle and my project use the same path for the Android SDK
made sure that I have the Google Glass Development Kit Installed in the SDK Manager (and all other packages for API 19 as well), also deleted and re-installed it
installed the latest Build Tools via the SDK Manager and consequently changed buildToolsVersion „23.0.1“ to „23.0.2“ in my gradle file
Replaced 'com.android.tools.build:gradle:2.0.0-alpha3' in my top-level gradle file with 'com.android.tools.build:gradle:2.0.0-alpha6' since this is the latest version
in gradle-wrapper.properties changed this line distributionUrl=https://services.gradle.org/distributions/gradle-2.8-all.zip
to this line:
distributionUrl=https://services.gradle.org/distributions/gradle-2.10-all.zip
and chose „use default gradle wrapper“ in the project options
cleared gradle caches in project/gradle and %HOME%/gradle
tried to build a new Google Glass Project from scratch in Android Studio – same problem
This is the relevant part of my gradle file:
android {
compileSdkVersion "Google Inc.:Glass Development Kit Preview:19"
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.helloglass"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
...
And my top-level gradle file:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.0.0-alpha6'
}
}
I don’t know what else to do. Any help is greatly appreciated!
I haven't found the reason for the problem, but after re-installing both Android Studio and Android SDK I can finally build the project.
Replace
compileSdkVersion "Google Inc.:Glass Development Kit Preview:19"
with
compileSdkVersion 23
then rebuild the project, hope it will work

How to Get Cordova to Work With Android Studio?

I have the newest everything, node, npm, android studio, cordova.
I created a new project with:
cordova create test
cd test
cordova platform add android
I go into Android Studio, import project, go to test/platforms/android it finds the build.gradle file, works on it for awhile then spits out:
Gradle version 1.10 is required. Current version is 2.2.1
So I go to my build.gradle file, and update the line
dependencies {
classpath 'com.android.tools.build:gradle:0.10.+'
}
to:
dependencies {
classpath 'com.android.tools.build:gradle:0.14.+'
}
And then I re-import my project, it chugs on it for awhile, then spits out:
Error:failed to find Build Tools revision 19.0.0
So I install Build Tools 19.0.0
And it tells me:
Error:The SDK Build Tools revision (19.0.0) is too low for project 'android'. Minimum required is 19.1.0
So I look at my SDK Manager and I have 19.1.0 installed
So I go back into my build.gradle file:
and I change:
buildToolsVersion "19.0.0"
to
buildToolsVersion "19.1.0"
And re-import again,
And still tells me:
Error:The SDK Build Tools revision (19.0.0) is too low for project ':CordovaLib'. Minimum required is 19.1.0
I even try and delete SDK Build Tools revision 19, and keep 19.1 but it still tells me that.
Can anyone that has done this song and dance please help me?
I had exactly the same problem and just fixed it. What you need to do is complete the same buildToolsVersion "19.1.0" change to the build.gradle file in the CordovaLib folder within your platform project folder e.g. platforms/android/CordovaLib.
I solved the problem, modifing gradle file App and gradle file CordovaLib, with the following information:
changed dependencies {
classpath 'com.android.tools.build:gradle:1.1.0+'
}
}
and
android {
compileSdkVersion 19
buildToolsVersion "19.1.0"
}
Tested on Android Studio 1.1
I had same problem. In the end choosing "Import Non-Android Studio project" and navigating to the android folder platforms/android worked. Wasn't sure if you initially choose the "Import Non-Android Studio project" option.
I had the same problem and corrected the content of build.gradle directly in Android Studio (replacing 19.0.0 with 19.1.0). The build was succeful after that. Of course, this is only a workaround until the Cordova team fixes the problem permanently. Good luck.

Old projects are not building after changing SDK path in Android Studio

Recently, I uninstalled my SDK from location /Users/Shared/Downloads/adt-bundle-mac-x86_64-20130729/sdk and installed in /usr/local/android_sdk/sdk
and the same changes I made in Android Studio Settings
Configure->Project Default->Project Structure->Platform Settings->SDK
Now, The problem is with these changes I can build any new project but when I open my old project It gives me this error:
Gradle 'GPSProvider' project refresh failed:
Could not execute build using Gradle distribution 'http://services.gradle.org/distributions/gradle-1.7-bin.zip'.
Build file '/Users/zohrakhan/AndroidStudioProjects/GPSProvider/GPSProvider/build.gradle' line: 9
A problem occurred evaluating project ':GPSProvider'.
A problem occurred evaluating project ':GPSProvider'.
The SDK directory '/Users/Shared/Downloads/adt-bundle-mac-x86_64-20130729/sdk' does not exist.
Please help me to find out the problem.
Edit 1:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.0"
defaultConfig {
minSdkVersion 11
targetSdkVersion 16
}
}
dependencies {
compile 'com.android.support:appcompat-v7:18.0.0'
}
Check local.properties file (in /Users/zohrakhan/AndroidStudioProjects/GPSProvider/GPSProviderdirectory). This file may contain:
sdk.dir=/Users/Shared/Downloads/adt-bundle-mac-x86_64-20130729/sdk
So, just replace sdk.dir property.
If it is an Old project and you were using different sdk that time Do the following before import
Delete all the content of .idea directory inside the project directory
Open Studio and import the project and wait until it sync with gradle.
If it gives gradle version related error while sync, update your build.gradle file with whaever version your error message is suggesting.
Now do mentioned below to update your local.propertiesfile
Sync your project with Gradle it will automatically ask if there are any conflicts in your sdk paths in project .
Choose default project sdk to use from dialog.
This is introduced from Android Studio 0.3.7

Categories

Resources