After I updated form 0.2.2 to 0.2.3, I create new project failed.
Error message is below:
下午 08:51:58 Gradle 'NotifyViaGoogleMapsProject' project refresh failed:
The SDK directory 'C:\Program Files (x86)\Android\android-studio\bin\Program Files (x86)Androidandroid-studiosdk' does not exist.
Build file 'F:\AndroidStudioDevelop\NotifyViaGoogleMapsProject\NotifyViaGoogleMaps\build.gradle' line: 9
NotifyViaGoogleMapsProject is my project name,and my android studio is install in default path(C:\Program Files (x86)\Android\android-studio), there has no same error in 0.2.2.
I've figured out the problem.
Open 'local.properties' in your project using a text editor.
sdk.dir=..\\sdk
Save and Close
Now Import your project into Android Studio.
Make sure that the SDK folder you mention exists - I'm not sure if it is a typo or not but the path you specified is a bit weird - it should be
C:\Program Files (x86)\Android\android-studio\sdk
On the menu go to File -> Project Structure, then choose SDKs under Platform Settings. Check that the path for the Android Platform you use is correct, and if not, change it to the correct path. Also make sure that the Project is set to use the correct Android Platform.
I have the same problem.
http://i.stack.imgur.com/pPOOi.png
The SDK is correct in Platform Settings, I have no idea what's causing this problem.
http://puu.sh/3TAFi.png
Related
I know this question has been asked before but I haven't been able to fix the issue. I am running Android Studio version 3.1.4. I am trying to run an app that I cloned from a Github repository. But even before I try to run it, I get this error:
my-app: sync failed
Cause: https://downloads.gradle.org/distributions-snapshots/gradle-4.4-20171031235950+0000-all.zip
How do I fix this error? Thanks in advance.
You can check and change the distribution url in the properties file $rootDir/gradle/wrapper/gradle-wrapper.properties. See property distributionUrl.
Value should be something as follows (update the gradle version depending on your Android Studio version)
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
I've encountered a similar error when I tried importing the Sunshine project from the Udacity Android development course. I fixed the issue by downloading the mentioned zip file and extracted it to the C:\Users\<username>\.gradle\native folder.
Then in Gradle settings, use local Gradle distribution and set the Gradle home path to the downloaded gradle folder.
Check this video for more information
You can fix it by the following steps: (currently using Android 3.6.3)
This worked for me.
Exit android studio then make the below changes.
Go to C:\Users\UserName.android and rename the build-cache folder to build-cache.bak.
Go to C:\Users\UserName.AndroidStudio3.6\system and rename these folders:
caches to caches.bak
compiler to compiler.bak
compile-server to compile-server.bak
conversion to conversion.bak
external_build_system to external_build_system.bak
frameworks to frameworks.bak
gradle to gradle.bak
resource_folder_cache to resource_folder_cache.bak
Open the Android Studio and open your project again.
If the folder is not in the Android3.6 folder, move to the next step.
Find the Gradle version from the gradle-wrapper.properties file
Download the Gradle bin file from internet, then extract it.
File menu-->Settings-->Build & Tools-->Gradle-->Use Gradle from: From
drop down select a specified location and browse to the location
where you have saved the Gradle bin zip file. (Default settings is use from ;gradle-wrapper.properties' file)
4.File menu-->Invalidate caches and re-run
[Gradle properties file]
[Gradle settings]
I have seen this same thing posted quite a few times, but whenever I try to import my project to my new work laptop I keep getting this error.
I have pulled the project from git (which his btw running fine on my old laptop).
Then I went to the sdk manager, downloaded all the tools, and all the SDK's available.
In the welcome screen, I went to Configure -> project Defaults -> Project structure.
Android SDK Tab says the path for projects without local.properties will be /Applications/Android Studio.app/sdk
This is correct.
Under SDKs I have all the available SDK's visible.
Project SDK is set to API 18
Yet still I get this error when trying to build my project.
Can anyone tell me where I havent looked yet?
I am running gradle 1.7 when trying to build which is downloaded from services.gradle.org
I had very similar situation (had a project on another machine and cloned it to my laptop and saw the same issue) and I looked in it.
Error message was coming from Sdk.groovy of Android gradle plugin:
https://android.googlesource.com/platform/tools/build/+/master/gradle/src/main/groovy/com/android/build/gradle/internal/Sdk.groovy
By looking at code, its findLocation needs to set androidSdkDir variable and there are only three ways to do it:
create local.properties file and have either sdk.dir or android.dir line.
have ANDROID_HOME environment variable defined.
System.getProperty("android.home") - I'm not sure how it works, but it seems like a Java thing.
While your Android Studio knows that the SDK is at that place, I doubt that Android Studio is passing that information to gradle and thus we're seeing that error.
I created local.properties file at the project root and put the following line and it compiled the code successfully.
sdk.dir = /Applications/Android Studio.app/sdk/
creating local.properties file in the root directory solved my issue
I somehow lost this file after pulling from GitHub
this is how my local.properties file looks like now:
## This file is automatically generated by Android Studio.
# Do not modify this file -- YOUR CHANGES WILL BE ERASED!
#
# This file must *NOT* be checked into Version Control Systems,
# as it contains information specific to your local configuration.
#
# Location of the SDK. This is only used by Gradle.
# For customization when using a Version Control System, please read the
# header note.
#Sat Feb 06 11:53:03 EST 2016
sdk.dir=/Users/****/Library/Android/sdk
I found the solution here:
http://xinyustudio.wordpress.com/2014/07/02/gradle-sdk-location-not-found-the-problem-and-solution/
Just create a file local.properties and add a line with sdk.dir=SDK_LOCATION
If none of the answers work for you which happened to me on macbook pro in one of the projects you can always try to run Android Studio with an alias command passing sdk.dir with each run:
alias studio='launchctl setenv ANDROID_HOME '\''/Users/username/Library/Android/sdk'\'' && open -a '\''Android Studio'\'''
To fix this problem, I had to define the ANDROID_HOME environment variable in the Windows OS.
To do this, I went to the System control panel.
I selected "Advanced system settings" in the left column.
On the "Advanced" tab, I selected "Environment Variables" at the bottom.
Here, I did not have an ANDROID_HOME variable defined. For this case, I selected "New..." and:
1) for "Variable name" I typed ANDROID_HOME,
2) for "Variable value", I typed the path to my SDK folder, e.g. "C:\...\AppData\Local\Android\sdk".
I then closed Android Studio and reopened, and everything worked.
Thanks to Dibish (https://stackoverflow.com/users/2244411/dibish) for one of his posts that gave me this idea.
Had the same problem in IntelliJ 12, even though I have ANDROID_HOME env variable it still gives the same error. I ended up creating local.properties file under the root of my project (my project has a main project w/ a few submodules in its own directories). This solved the error.
specifying sdk.dir=<SDK_PATH> in local.properties in root folder solved my problem.
I clone libgdx demo, can't import project. it also reminds like this.
Env:
Eclipse(Android-ADT)
window 7
so I create local.properties file at the project root, like following
sdk.dir = D:/adt-bundle-windows-x86/sdk
I hope this can help others!
Copy and paste the local.properties file from a project you created on your new computer to the folder containing the project from your old computer also works too if you don't want to (or know how to) create a new local.properties file.
I noticed that I get this error when I'm working on a new computer if I try to build from the command line first. However, if I build from Android Studio, it retrieves the SDK and creates the directory automatically. Then when I build from the command line it works.
You have also to ensure you have the correct SDK platform version installed in your environment by using SDK Manager.
If you have cloned a project from GitHub for example, and you've tried the methods mentioned here without success including:
Editing sdk.dir in the local.properties
Trying to set ANDROID_HOME environment variable
Or adding an alias as kasiara mentioned
You should try to see if you are trying to build a directory project that is a part within a bigger project, and so it may cause problems.
So load the entire project, and then run the project directory you'd like.
In my specific case I tried to create a React Native app using the react-native init installation process, when I encountered the discussed problem.
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':app'.
> SDK location not found. Define location with an ANDROID_SDK_ROOT environment variable or by setting the sdk.dir path in your project's local properties file at 'C:\Users\***\android\local.properties'.
I add this, because when developing an android app using react native, the 'root directory' to which so many answers refer, is actually the root of the android folder (and not the project's root folder, where App.js resides). This is also made clear by the directory marked in the error message.
To solve it, just add a local.properties file to the android folder, and type:
sdk.dir=C:/Users/{user name}/AppData/Local/Android/Sdk
Be sure to add the local disk's reference ('C:/'), because it did not work otherwise in my case.
I am using Android Studio for development (I/O Preview 0.2.3) and have used AS since I started my current project. Every time I open the project I get the Frameworks detected: Android framework is detected in the project Configure message in the event log. I can click Configure and it sorts things out straight away but its happens every time I open the project.
Its not really causing any issues, more of an annoyance than anything. Is there anyway of making AS remember that this is an Android project?
If Android Studio notices a difference in the path to the android SDK folder on disk and the path mentioned in your local.properties file, it will prompt and upon confirmation update the path in local.properties. I think you local.properties file is not retaining the change in SDK path once you close the project. Check you check if something is reverting the changes.
Also, try saving the local.properties file manually after updating the sdk.dir property with correct path..
It looks like this in the local.properties file.
# change the SDK path below to match the folder on your system
sdk.dir=D\:\\Android\\android-sdk
Try to import projectrather than just opening the project.
File --> New--> Import Project
Try open the SDK Manager and check if Android Support Repository is installed. If not, install if and reopen the project.
Change then name of your project. I had the same problem, because my project had name like "Smile&Smile" and the symbol & crashed normal assembly of my project. Also, don't use symbols like &, !, "",'' in the name of projects.
Just change first row with your build.gradle.
try use
apply plugin: 'com.android.application'
I just install android studio on a VM machine (VM Fusion). When I try to create a new project, I get the message "org.gradle.tooling.GradleConnectionException: Could not install Gradle distribution from 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'.: Could not install Gradle distribution from 'http://services.gradle.org/distributions/gradle-1.6-bin.zip'."
I followed the suggestion found in the page.
Download Gradle directly from
http://services.gradle.org/distributions/gradle-1.6-bin.zip
Copy the contents of gradle-1.6 to
\Android\android-studio\plugins\gradle
Copy gradle.jar to \Android\android-studio\lib\
Restart Android Studio
It did not work. I get the error message
I tried to copy the zip package /gradle-1.6-bin.zip to the following location
C:\Documents and Settings\myusername.gradle\wrapper\dists\gradle-1.6-bin\72srdo3a5eb3bic159kar72vok\
the .gradle file was not there. I look in setting and notice that it under \vmware-host\sharefolders. I went there and the file was still not there. I unhide hidden file and folder with no luck.
In addition, when I create a new project, I notice the project location is \vmware-host\Shared Folders\AndroidStudioProjects\MyApplicationProject.
How can I get a new .gradle file or tell android studio to look at a different folder? How do I change the project location so it does not default to \vmware-host but instead to c:\development.
Any kind of help would be greatly appreciated.
Thanks,
JF
Copying Gradle inside Studio will not help. Just install it somewhere else and after manually creating a project you can import it in Studio and select which installation of Gradle to use.
You have to create the project manually, because right now creating a project from studio always use the wrapper that automatically download gradle from the online repository.
We are working on having an offline mode for project creation, but it's not available yet.
Just edit your System's DNS settings, and redirect services.gradle.com to 127.0.0.1 then use a small web server and serve the file under its appropriate directory (distributions)
As you said,"Copy the contents of gradle-1.6 to \Android\android-studio\plugins\gradle",this folder under the setup path.
Why did you copy it to "Documents and Settings"?
While trying to add android source to eclipse, I am getting the following errors.
Project 'android' is missing required library: 'out/target/common/obj/JAVA_LIBRARIES/gsf-client_intermediates/javalib.jar'
Project 'android' is missing required library: 'out/target/common/obj/JAVA_LIBRARIES/google-common_intermediates/javalib.jar'
FYI, I have built the source successfully with full_maguro-userdebug configuration (for Galaxy Nexus) before adding this to eclipse. Since I couldn't find "create project from existing source" in Eclipse Indigo, I changed the location of the project to the root directory of the source. I refreshed the project several times with same error.
How to solve this issue?
You should go to Project -> Properties -> Java Build Path.
There open tab Libraries.
In this tab out/target/common/obj/JAVA_LIBRARIES/google-common_intermediates/javalib.jar should be changed to out/target/common/obj/JAVA_LIBRARIES/android-common_intermediates/javalib.jar by selecting javalib.jar from google-common_intermediates, pressing Edit and selecting instead android-common_intermediates.
Entry with gsf-client_intermediates javalib.jar can be simply deleted.
A more comprehensive answer at here: https://groups.google.com/forum/?fromgroups=#!topic/android-platform/XIbR8ZKe7Tw
I would not recommend using eclipse for android source. Android is not a single project and it too big for an IDE like eclipse to handle.
Use simpler plain text editors like vim, emacs to browse the code