I had installed OpenJDK7 in my machine for Java programming. Then I removed it and installed Oracle 1.7Jdk. But the problem is Android Studio isn't taking the new JDK. It gives the following error:
Cannot run program "/usr/lib/jvm/java-7-openjdk-i386/bin/java" (in directory "/home/pranay/.AndroidStudioPreview/system/compile-server"): error=2, No such file or directory
How can I run Android Studio?
Android-Studio may stores the location of Java in $HOME/.AndroidStudioPreview/config/options/jdk.table.xml
Delete this file and restart Android-Studio, it should now prompt you for your new Java location.
Cheers
Seems that Android Studio can't find your JDK, probably your system installed it on a different location (and not in "/usr/lib/jvm/java-7-openjdk-i386/bin/java").
I had another problem with Java and Android Studio, but I think the soulution could also work for you. IntelliJ needs a fixed installation of the JDK in one of these locations (found it here):
/usr/java
/opt/java
/usr/lib/jvm
My JDK was in another folder, so I moved it to /usr/java and now it works fine :)
The location is now:
~/.AndroidStudio/config/options
not
~/.AndroidStudioPreview/config/options
since AS has been officially released.
Related
I've downloaded Android Studio from the official website, the one for M1 chip (arm).
Basically running it for the first time, the error is the following:
An error occurred while trying to compute required packages
I was searching about it the whole day to figure out a way to make Android Studio work, but that error keeps showing. Not completely sure if it's related to M1 Macbook, as on my Intel one it works as expected.
What I already tried to do:
Installing the command line tools, then placing it on SDK folder (Users/user/Library/Android/sdk). Then added the bin to the PATH (Reference)
After doing that, when executing the sdkmanager on terminal I get the following message Could not find or load main class com.android.sdklib.tool.sdkmanager.SdkManagerCli
Then I searched again and it leaded me to this thread, then as on the answers I tried to rename the folder, then other tries not related. I fell into many links and references that did not work at all.
After that I try to check what happens if I click on New Project, then the following is shown:
The Android SDK location cannot be at the filesystem root
As the message indicates, the issue is The Android SDK location cannot be at the filesystem root, so I searched again about it
I looked into that and got to a few links, for example this one and this one. Before doing that search I clicked on the Edit button, which lead me to the Android SDK to be updated/installed (Nice!), so I had to delete the content I had on Android folder (inside Library) and clicked next...then, I got the same message An error occurred while trying to compute required packages.
Then I thought "ok, maybe if I change the SDK location", so I changed to ../Documents/sdk, which ended up in the same result
Seems like no matter what I do, it ends up showing up that same message.
When I run java -version that's what I see:
java version "1.8.0_311"
Java(TM) SE Runtime Environment (build 1.8.0_311-b11)
Java HotSpot(TM) 64-Bit Server VM (build 25.311-b11, mixed mode)
Did anyone have the same issue? Am I doing something wrong? Not sure how to proceed from here, despite of the Android Studio version I download it's always the same result.
Any help is appreciated.
This is what solved it for me on my M1.
Go to Android Studio Preview and download the latest Canary build for Apple chip (Chipmunk). Don't worry this is just to get through the initial setup.
Unpack it, run it, let it install all the SDK components, accept licenses, etc as usual.
Once it's done, simply close it and delete it.
Now when you start your stable Android Studio (Arctic Fox) you should not see the error.
I tried over a dozen 2021 stable and Canary builds from https://developer.android.com/studio/archive and couldn't get any of them to work.
This is the only thing I could find that worked:
Download, unpackage and run Android Studio 3.6.3 android-studio-ide-192.6392135-mac.zip from here.
Proceed through the initial setup and let it download and install the SDK. Ignore any errors at the end.
Delete this version and open the stable Android Studio like normal.
You can now proceed through setup!
I also faced this issue a couple days and I changed my mind to not use Android Studio. And It's fixed!
My alternative option is to download IntelliJ community edition and install Android SDK to your machine.
Image for IntelliJ Download Page
After (IntelliJ) installation is complete,
You need also to create new project, select android then download SDK. (thanks for #SteveRoger 's comment)
then open Android Studio again and follow its setup wizard. It will show that my machine has been already installed Android SDK and it can run perfectly at this time.
Hope this is an alternative solution for you.
Have a great day.
I solved the problem with these steps:
Install the old Android Studio 3.6.3 (find the old Android Studio at https://developer.android.com/studio/archive)
Install the Android SDK
Overwrite the installation with the Apple Chip version of Android Studio
I had the same problem with my MacBook air(m1 chip) as you mentioned.
How did I solve it?
Just download the IDE - Intellij IDEA and create a new project, select Android Project and there download Android SDK, now you can install android studio again and the sdk is installed.
I've also had this exact same issue when downloading Android Studio 7.0.3. Here's what helped me.
Download the command line tools, place them in the SDK folder (e.g., on mac: /Users/user/Library/Android/sdk), and then add the bin folder to the PATH.
Install the latest platform: in a terminal, execute ./sdkmanager "platforms;android-31"
Next up execute this command ./sdkmanager --channel=3 emulator (this switches the channel from stable=0 to canary=3 )
Open Android Studio, and go to the SDK Manager (Appearance and Behavior > System Settings > Android SDK)
Click on "Edit", and then select the sdk folder. Then "Next" > "Next" > "Finish".
Now restart Android Studio and everything should work
I had the exact same error as OP. Follow what Art Fedorychak mentioned, it worked for me as well. It seems like the current stable build of the Apple M1 android studio version doesn't actually initialize an SDK if one doesn't already exist, but it seems to be able to update and or / initialize one that does as long as the same folder is being referenced, so we just need to use a working SDK for M1 on the initial run and then revert back to the stable AS
This is what solved it for me:
Download & install IntelliJ IDEA. https://www.jetbrains.com/idea/download/#section=mac
Open IntelliJ IDEA and create New Android Project
Download sdk success
Open Android Studio & checked it worked
My solution to this problem is simply to put the SDK in another location. For myself, I put the SDK folder to subfolders in Documents. The SDK download will initiate.
I'm on windows7 x64, installed today's latest stable release of android sdk studio (through android studio bundle, since it's shipped together now apparently). I have properly configured the environment variables as you'll see above.
This is what I get when issuing the following command
$ cordova build android
ANDROID_HOME=G:\installs\Android\sdk
JAVA_HOME=C:\Program Files\Java\jdk1.8.0_121
Error: Could not find gradle wrapper within Android SDK. Might need to update your Android SDK.
Looked here: G:\installs\Android\sdk\tools\templates\gradle\wrapper
And indeed, the "templates" directory doesn't even exist in my sdk install.
I've already tried the suggestions (setting the right path, uninstall/reinstall) of this question here but nothing applies to my case, and I find that manually copying and pasting packages is not really a solution, since there's a package manager in place.
If anybody has an answer as of today's android install, would be very much appreciated.
If still not working then copy all file from gradle\wrapper from Android Studio installation folder
C:\Program Files\Android\Android
Studio\plugins\android\lib\templates\gradle\wrapper
and paste it in your Android SDK gradle\wrapper then run same command.
E:\android-sdk\tools\templates\gradle\wrapper
This is a known issue; see CB-12544. For now you'll need to downgrade.
I downloaded Android SDK r25 manually and placed templates folder inside Android/sdk/tools. This solved the issue for me.
You can get it from https://dl.google.com/android/repository/tools_r25.2.3-macosx.zip
For Windows:
https://developer.android.com/studio/index.html
Go to the section :"Get just the command line tools"
There is a link 'sdk-tools-darwin-3859397.zip' for Mac, Unfortunately that didn't have the templates folder with Gradle Wrapper. So for Mac users, i will suggest not to go for this zip.
Being new in Android devopmnet, I have been using Android Studio for development, but suddenly it doesn't work anymore.
The program doesn't launch anymore, and If I execute the studio.bat from Command Prompt, I get the following error:
Error: Could not find or load main class com.intellij.idea.Main
I have seen other posts about Android Studio not launching (e.g. this and this), but neither of them solve my problem. I have set PATH variables for both JAVA_HOME and JDK_HOME correctly to C:\Program Files\Java\jdk1.7.0_07
As I have mentioned, Android Studio used to work and I don't have any idea why it has stopped working. Any clue?
For android studio 1.3.1
go to environment variable and create new variable and give it a name JAVA_HOME and in path use this C:\Progra~1\Java\jdk1.7.0_71.
I hope that can help you.
if you have just used copy paste of exe file it will show this message so go in Program Files\Android\Android Studio\bin and click on exe file.
I had the same issue after updating the Android studio. I was not able to launch it from click on Android Studio icon and after running ./studio.sh it was giving me same error
I follow the below step and solved the problem.
I downloaded the studio and install it in the new directory.
After installation success, copy all the files & folders and paste and replace it into old location where studio was installed.
Having JAVA_HOME set to point latest JDK version (C:\Program Files\Java\jdk1.7.0_79) will make the Android studio work. Make sure the path is correct. Seems that JDK_HOME is not needed.
can refer Installing Android Studio (Not working)
If you have recently uninstalled and reinstalled Android Studio and had previously pinned the Android Studio icon to your Task Bar or Start Menu, it may be that this icon no longer looks for the new installation.
Delete it and re-pin it and all will be fine.
I faced the same issue while launching the studio.exe file. The actual problem was I have downloaded the 64-bit version of Android studio. But my computer supports only 32 bit.
So I downloaded 32-bit version and installed.
Now it is working fine.
Well after searching allover the web, failed to get solution till i decided to reinstall android studio. same folder changed nothing didn't delete anything just reinstalled and boom works as before
This happens when you update Studio and new version is installed and previous one is in process of deletion: at the main time if PC shut down or suddenly crashed due to power cut etc. Then this problem will appear:
could not find main class com/intellij/idea/main
Solution:
Go to this path "C:\Program Files\Android", there you will find two Android Studio Folders.
Find which one is latest: (Latest name wold be "Android Studio1") && (Old version would be Android Studio)
Delete old one(if you don't need it any more) and launch latest exe on this path:
C:\Program Files\Android\Android Studio1\bin
Open the Installer and download it again and you can select delete previous versions to clear confusion.
Open studio64 instead of studio
I found Answer: you just make wrong shortcut(just ctrl+C ctrl+v) for launchfile(exe). You must make shortcut following this method:
Right mouse click and select make shortcut menu.
Please follow the below steps,
Go to My Computer -> Properties -> Advance System Settings
System properties window will appear
Go to Advance tab -> Environment Variables -> New
Add or update JAVA_HOME path as expected.
Optionally you can also add or update JDK_HOME if you have JDK installed in your PC
I'm just trying out Android Studio. I imported a project from Eclipse, but every time I try
to run it I get this error:
"Cannot run program
"Library/JavaVirtualMachines?jdk1.7.0_10.jdk/Contents/Home/bin/java"
(in directory
"/Users/myname/Library/Caches/AndroidStudioPreview/compile-server"):
error=2, No such file or directory.
I just installed the latest JDK using the JDK 7 Update 21 dmg. Is it installing the jdk in a place where Android Studio won't find it? The dmg didn't have any options for where to install the jdk other than "Install for all users of this computer," which I did.
When I was using Eclipse I had no problems with running my programs.
Furthermore, the Project Structure option was no longer available after I updated earlier today. Instead I just get the message, We will provide a UI to configure project settings later. Until then, please manually edit your build.gradle file(s.)"
I'm not sure what to do to get my programs running again. Do I need to locate the jdk files and move them? Could I tell Android Studio where the files are actually installed?
The solution was easier than I thought: just go to File/Other Settings/Default Project Structure and click SDKs. There the JDK home path can be changed.
Yes changing the JDK path will work. If that doesn't fix your problem, as it didn't for me at first, uninstall your JDK and redownload and install it. Once I reinstalled mine, it worked flawlessly.
The new Android Studio has a strange problem when you run the installer in Windows 8. Even after installing the Java SDK and setting JAVA_HOME it still complains that it cannot find Java, which it is looking for under C:\windows\system32. The only solution I've found is to delete java*.exe from system32, but obviously this is not ideal (although you can replace them from the sdk dir afterwards). Is there something I'm missing? Also does anyone know why those 3 java exe files end up in System32 in the first place?
I had exactly the same problem.
Probably, you have java.exe in C:\Windows\System32 folder.
Rename this file and try installing again.
BTW, there are few related posts to check out.
Android SDK installation doesn't find JDK
Android studio doesn't start
Try opening Android Studio through the App menu instead of the file manager.