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
Related
I downloaded an open source game "ChaseWhisplyProject" source code from Github.
I imported the project in my Android Studio (Version 1.5.1).
It shows following error message:
Error:Failed to open zip file.
Gradle's dependency cache may be corrupt (this sometimes occurs after a network connection timeout.)
Re-download dependencies and sync project (requires network)
Re-download dependencies and sync project (requires network)
I changed all the dependency versions to latest one bu still it is showing the same message.
It has two modules under the main project 1) BaseGameUtils & 2)ChaseWhisply.
The above modules are not shown in bold letters (I think it should be shown in bold letters like module "app").
Following are the gradle files.
1) Root Gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
allprojects {
repositories {
jcenter()
}
}
2) BaseGameUtils Module Gradle
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
}
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
dependencies {
compile 'com.android.support:support-v4:23.1.1'
compile 'com.google.android.gms:play-services:8.4.0'
}
3) ChaseWhisply Module Gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.5.0'
}
}
apply plugin: 'com.android.application'
dependencies {
compile 'com.android.support:gridlayout-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:cardview-v7:23.1.1'
compile 'com.nineoldandroids:library:2.4.0'
compile project(':BaseGameUtils')
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
lintOptions {
// TODO fix and remove !
disable 'MissingTranslation', 'DuplicateIds', 'ExtraTranslation'
}
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 22
versionName "0.3.6"
}
}
4) Settings.gradle
include ':ChaseWhisply', ':BaseGameUtils'
What is wrong over here? Please help.
While importing a libGDX project I got the same message from Android Studio 2.2.
Went to File->Project Structure then selected Project and set
Gradle version
and
Android Plugin Version
to values identical to another project I had recently created with Android Studio 2.2 and updated SDK. Could then sync gradle. Did Build->Build Clean with no issues. Then did Run->Clean and Rerun and project ran fine.
Hope this helps.
It basically means that the gradle zip file in the cache folder is corrupted, if you don't want to change the version like the up-voted answer then you must delete the folder for your gradle version you're using for this project from the below path.
Then just retry the sync and android studio will download it again
C:\Users\ [user here] \.gradle\wrapper\dists
ex: if you're using 3.3 for this project you'd be deleting the folder
C:\Users\[user here]\.gradle\wrapper\dists\gradle-3.3-all
I was also facing the same issue. The solution worked for me was go to "gradle\wrapper\dists" and deleted the folder "grade-4.10.1-all" folder and downloaded the same version after that i pasted the extracted folder in same address.After that I again synchronized the android studio. I worked for me.
I face the same problem and I search for it and found a best solution and i works for me:
Manually download Gradle 3.3 binary (direct link: https://services.gradle.org/distributions/gradle-3.3-bin.zip)
Open your android studio root directory, and extract the zip to the gradle folder (for example: program files/android-studio/gradle/gradle-3.3)
Open Android Studio, go to File->Settings-> (Build, Exectution, Deployment) >Gradle and set "Gradle home" to point your new gradle-3.3 folder.
Apply and sync.
May be incompatible with Gradle and maven version
delete project dir/gradle/wrapper
put a right version gradle into it
run again
change the gradle-wraper-properties distributionUrl to your local downloaded gradle such as
distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip
I solved this issue by this following steps
1.C:\Users\System name.gradle\wrapper\
2.Inside wrapper folder u will find grale file with some version, You just have to delete it
3.Come/Go to android studio and Go to File->Sync project with Gradle Files.
4.Android studio automatically download the require gradle file.
5.And now go for coding
The close android studio then goes to the directory and you will find this type of folder. I saw in my pc. after deleted then clean project and sync. its works fine.
you just delete from this directory
C:\Users\ [user here] .gradle\wrapper\dists
if you use 3.3 version in android studio. you can see like this
C:\Users[user here].gradle\wrapper\dists\gradle-3.3-all
Well, It's a bit late, but usually happens when something went wrong in Android Studio's initial launch (eg. system crash, connection loss or whatever). We can call it bad programming or lazy QA.
To fix this close Android Studio and delete everything from the following directory. Don't worry files will be downloaded on next launch.
For Windows: C:\Users\your-username.gradle\wrapper\dists
For Linux: ~/.gradle/wrapper/dists
For mac: ~/.gradle/wrapper/dists
You can also Gradle manually to fix this issue, But it's better to let Android studio does this work. .
Clean Project is a way to go. After you clean project, make sure you rebuild it. Usually it solves the gradle issues for me.
In my case I was running IntelliJ IDEA as non root user.
If you want to use the new features, you should not revert it to the old version, just delete the directory ~/.gradle recursively, then restart Android Studio.
Update your gradle version and update with required version of gradle and syn your project.
https://services.gradle.org/
First of all, open your gradle-wrapper.properties file from the project then note down the version of the Gradle.
It could be like this:
distributional=https\://services.gradle.org/distributions/gradle-6.5-bin.zip
So, here my Gradle version is 6.5. It could be different in your case.
After this, open file explorer and open your project folder. There you will be having the Gradle folder open it, inside it the version will be mentioned of your previous Gradle.
Now you will have to download the Gradle file according to the wrapper.properties(for example nothing but 6.5 version).
You can download it from here
Extract it
paste it to the Gradle folder
open your project > file > settings > Build, Execution, Deployment > Gradle, then select the newly downloaded Gradle file in the Gradle user home.
Then run your project.
This worked for me - go to https://gradle.org/releases/ and download latest stable version (binary-only works fine). extract and insert into C:\Users\OWNER\.gradle\wrapper\dists folder.
Open Android Studio settings > Build, Execution, Deployment > Gradle, use gradle from: specific location.
The following steps solved my problem :
1.C:\Users\System name.gradle\wrapper\
2.Inside wrapper folder u will find grale file with some version, You just have to delete it
3.Come/Go to android studio and Go to File->Sync project with Gradle Files.
4.Android studio automatically download the require gradle file.
5.And now go for coding
I have recently updated android studio to the latest version,but then comes the problem.
Gradle 'MyApplication' project refresh failed.
Error:Could not run build action using Gradle distribution 'https://services.gradle.org/distributions/gradle-2.2.1-all.zip'.
Found this in StackOverflow
However trying everything nothing works - cannot create new project of import anything at the moment.Please kindly advice.
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.sclick.myapplication"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
task assemble{}
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:21.0.3'
}
**Top Level Gradle.build**
// 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.0.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
jcenter()
}
}
gradle-wrapper.properties
#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-2.2.1-all.zip
I had same issue. I have tried many things but nothing worked Until I try following:
Close Android Studio
Delete any directory matching gradle-[version]-all within C:\Users\<username>\.gradle\wrapper\dists\. If you encounter a "File in use" error (or similar), terminate any running Java executables.
Open Android Studio as Administrator.
Try to sync project files.
If the above does not work, try restarting your computer and/or delete the project's .gradle directory.
Open the problem project and trigger a Gradle sync.
I had a similar issue, when I upgraded to the latest version of Android Studio 1.3.2. What seemed to work for me was removing the .gradle folder from my project directory:
rm -rf ~/project/.gradle
I had same issue when first start Android Studio in Window 10, with java jdk 1.8.0_66. The solution that worked is:
Step 1: Close Android Studio
Step 2: Delete Folder C:\Users\Anna\.gradle
(Anna is my username)
Step 3: Open Android Studio as Administrator
Step 4: If you are currently in an opened project, close current project by select File > Close Project.
Step 5: Now you seeing this Quick Start GUI:
Select Open an existing Android Studio project, navigate to your project folder and select it.
Wait for gradle to build again (it would download all the dependency in your build.gradle for every module in your project)
If it has not worked till now, you could restart your computer. Do step 1 again.
This happens sometime when I changed Android Studio version or recently upgrade Window. Hope that helps !
I forced to use a proxy and also forced to add proxy setting on gradle.properties as these:
systemProp.http.proxyHost=127.0.0.1
systemProp.http.proxyPort=1080
systemProp.https.proxyHost=127.0.0.1
systemProp.https.proxyPort=1080
And also forced to close and open studio64.exe as administrator .
Now its all seems greate
Event log says
8:21:39 AM Platform and Plugin Updates: The following components are ready to update: Android Support Repository, Google Repository, Intel x86 Emulator Accelerator (HAXM installer), Android SDK Platform-Tools 24, Google APIs Intel x86 Atom System Image, Android SDK Tools 25.1.7
8:21:40 AM Gradle sync started
8:22:03 AM Gradle sync completed
8:22:04 AM Executing tasks: [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:prepareDebugUnitTestDependencies, :app:mockableAndroidJar]
8:22:25 AM Gradle build finished in 21s 607ms
I'm using android studio 2.1.2 downloaded as exe setup file. it has its Gradle ( I also forced to use custom install to address the Gradle )
Go on Project->Settings->Compiler(Gradle-based android project), find the text field "VM option" and put there:
-Xmx512m -XX:MaxPermSize=512m
This shouls solve the issue in any case the error shown in the gradle message window is "Could not reserve enough space for object heap"
Hope this helps
You can download the gradle you want from Gradle Service by reading the gradle-wrapper.properties.Download it ,unpack it where you like and then change your grandle configuration use local not the recommended.
I had the same problem and I Just Invalidate caches/restart
Try updating gradle dependency to 2.4. For that you need to go to
File -> Project Structure -> Project -> Gradle version.
There you need to change from 2.2.1 to 2.4. Wait for new gradle version to be downloaded.
And you are ready to go.
I have run into a similar problem on Mac.
Looking at the log under Help -> Show logs in Finder I found the following entry.
You have JVM property "https.proxyHost" set to "127.0.0.1".This may lead to incorrect behaviour. Proxy should be set in Settings | HTTP ProxyThis JVM property is old and its usage is not recommended by Oracle.(Note: It could have been assigned by some code dynamically.)
and it turned out I had Charles as a network proxy running. Shutting down Charles solved the problem.
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.
I've updated my Android Studio into version 0.3.2. but I'm having a problem about my project and it gives me this error:
I only have a bit of idea on whats happening on this so I tried to press F4 (Windows) then 'Module' and then the TabFragmentExercise then tried to change the 'Paths' and selected the 'Use module compile path' just like on how the default project does and changed into this:
C:\Users\PCNAME\AndroidStudioProjects\TabFragmentExerciseProject\TabFragmentExercise \build\classes\debug
Then rebuild the project but still no chance. It will just give me this result:
Local path doesn't exist.
Here's my config for gradle anyways:
gradle-wrapper.properties
#Wed Apr 10 15:27:10 PDT 2013
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=http\://services.gradle.org/distributions/gradle-1.8-bin.zip
build.gradle
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.6.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 16
}
}
dependencies {
compile files('libs/android-support-v4.jar', 'libs/commons-io-2.4.jar', 'libs/apache-mime4j-0.6.1.jar', 'libs/httpclient-4.1.jar', 'libs/httpcore-4.1.jar', 'libs/httpmime-4.1.jar')
}
Hope someone can help me on this.
So after searching I found out the solution for this. First the problem that the "APK path is not specified for module "ProjectName" really means that the path was not configured correctly upon importing on your project. What you can do is do the steps I've done above but instead of that path locate your apk instead.
Now after doing it when you clean the app and tried to run it you will now encounter an error saying that the "Local path doesn't exists". when that happens go to your .iml file then just configure the path by adding this lines under the facet->configuration:
<option name="APK_PATH" value="/build/apk/YourProject.apk" />
Rebuild project then run. It works like magic indeed.
Try doing a ./gradlew clean, then go to Tools -> Android -> Sync Project with Gradle Files
If that doesn't work, then delete all your *.iml files and re-import the project. This process should only take a couple minutes if you're importing from a Gradle project
I'm trying to add a .jar library to my project into the /libs folder. Here is my grade.build:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.4'
}
}
apply plugin: 'android'
dependencies {
compile files('libs/android-support-v4.jar', 'libs/java-api-wrapper-1.2.0-all.jar')
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 15
targetSdkVersion 16
}
}
After I add that, I build my project and there are no errors. But when I try to use the class in my code private ApiWrapper wrapper, I get an error:
Gradle: error: cannot find symbol class ApiWrapper
I can't quite find where the error is. Is my grade.build not ok, or am I supposed to build it some other way?
Using the command line, in the root of your project, run :
./gradlew clean && ./gradlew build
Then recompile your project in studio and you should see your new lib.
Set minifyEnabled to false for all your library projects in build.gradle.
See accepted answer by Scott Barta in this thread.
See accepted answer by Scott Barta in this thread
Goto File ⇒ Invalidate Caches & Restart
Solved my problem
As first option, i think will be enough Syncronizing the Project with Gradle Files.
Another option, from the command line, run the batch file gradlew.bat located inside your project folder:
./gradlew clean && ./gradlew build
I had a similar situation where Android Studio couldn't find a library that definitely existed. Even though I was able to compile my project in Android Studio, run it from Android Studio in the emulator or on a physical device, and build it from the command line using gradlew, the Android Studio IDE complained Cannot resolve symbol 'ConstraintLayout'. I believe I had imported the library correctly because I followed Google's instructions: https://developer.android.com/training/constraint-layout/#add-constraintlayout-to-your-project.
Anyway, I ended up solving the problem as follows:
Close Android Studio
Delete the .idea folder in the project's directory
Open Android Studio
Re-import the project so Android Studio can regenerate the .idea folder
This in-fact solved the problem. I believe Android Studio somehow corrupted the .idea folder when I had done "Android Studio" > "Check for Updates" earlier in the day.
Go to the Android studio File and press Invalidate Caches/Restart. This worked for me to find the library