- Install Android Development Tools
- Before You Begin
- Background
- What Do You Need?
- Install and Set Up Android Studio
- Install an Android SDK Platform Package
- Create and Start an Android Virtual Device
- Install the Java SE Development Kit 8
- Create Environment Variables
- How to set Java SDK path in AndroidStudio?
- 9 Answers 9
- Up to Android Studio 4.2
- Android Studio Arctic Fox (2020.3.1)
- Older Versions
- Using JDK that is bundled inside Android Studio as JAVA_HOME on Mac
- 4 Answers 4
Install Android Development Tools
Before You Begin
This 15-minute tutorial shows you how to install Android Studio, which includes the Android SDK, and create an Android Virtual Device (AVD) on which you install an Oracle JavaScript Extension Toolkit (Oracle JET) hybrid mobile application during a later tutorial. The time to complete doesn’t include processing time as a result of your activities.
Background
The Oracle JET command-line interface invokes the Android SDK that you install with Android Studio to build an Android application package (APK) file from the source files of your hybrid mobile application. This APK file is installed on an AVD to enable you to test the hybrid mobile application.
What Do You Need?
- A computer that meets the system requirements to install Android Studio. See System requirements at https://developer.android.com/studio/
Install and Set Up Android Studio
Depending on the operating system of your computer, the Android Studio installation wizard prompts you with dialogs where you choose between standard or custom install types. Choose the options recommended by the Android Studio installation wizard as these options include the components that you require to create and install a hybrid mobile application on an AVD. They also include an Android emulator and an emulator accelerator appropriate for your computer, be that Windows, Mac, or Linux.
- Go to the Download page for Android Studio on the Android Developer’s website at https://developer.android.com/studio/ and click DOWNLOAD ANDROID STUDIO.
- Review and accept the terms and conditions in the Download Android Studio dialog that appears and click DOWNLOAD ANDROID STUDIO FOR PLATFORM where PLATFORM refers to the operating system of your machine, such as Windows, Mac, or Linux.
- Go to the Install Android Studio guide at https://developer.android.com/studio/install and follow the instructions for your operating system to install and start Android Studio.
- If you run Android Studio behind a firewall or secure network, an Android Studio First Run dialog appears which displays a button (Setup Proxy) that you click to enter the proxy server settings for your environment. This allows Android Studio to complete the download of the components for a standard install.
- In the Welcome to Android Studio dialog, select Start a new Android Studio project, and then, in the Create New Project wizard, accept the default options to progress to the final screen in the wizard and click Finish.
This enables the Android Studio toolbar with the options that you need to create an AVD. It also downloads and configures the Gradle build tool that the Android SDK invokes to build the APK file when you complete the creation of your Oracle JET hybrid mobile application.
If you run Android Studio behind a firewall or secure network, a Proxy Settings dialog appears that enables you to configure proxy settings for the Gradle build tool that Android Studio downloads and configures. Provide the proxy settings for your environment to ensure that the Gradle build tool functions correctly.
Install an Android SDK Platform Package
- In the Android Studio toolbar, click the SDK Manager icon (
) to open the Android SDK page in the Default Settings dialog.
- In the SDK Platforms tab, select Android 8.0 (Oreo) with an API Level value of 26, and click Apply.
Description of the illustration sdkmgrdialog.png
- Click OK in the confirmation dialog that appears and accept the license agreement to proceed with the installation.
- Once the installation completes, click Finish and then click OK to close the Default Settings dialog.
Create and Start an Android Virtual Device
- In the Android Studio toolbar, click the AVD Manager icon ( ) and click Create Virtual Device in the Android Virtual Device Manager dialog that opens.
- In the Phone category of the Choose a device definition page of the Virtual Device Configuration dialog, select Nexus 5X and click Next.
- In the Recommended tab of the Select a system image page, click Download for the Oreo entry with an API Level of 26.
Description of the illustration downloadoreo.png The SDK Quickfix Installation wizard opens.
- Accept the license agreement to proceed with the download of the system image for Android 8.0 with API Level 26. Once the installation completes, click Finish and then click Next in the Select a system page.
- In the Verify Configuration page, review and accept the default settings such as the AVD Name value of Nexus 5X API 26, then click Finish.
- In the Android Virtual Device Manager dialog, click the Launch this AVD in the emulator icon (
) under the Actions column for the newly-created Nexus 5X API 26 AVD.
The Android emulator starts and loads the Nexus 5X API 26 AVD. A toolbar appears to the right of the AVD that provides UI controls to interact with the AVD.
Description of the illustration sdkmgrdialog.png
Install the Java SE Development Kit 8
- Go to the Java SE Development Kit 8 Downloads page at http://www.oracle.com/technetwork/java/javase/downloads/jdk8-downloads-2133151.html, accept the license agreement, and download the Java SE Development Kit installation file for your platform.
- Follow the JDK installation instructions for your platform at https://docs.oracle.com/javase/8/docs/technotes/guides/install/toc.html.
Create Environment Variables
To function correctly, the Apache Cordova command-line interface that the Oracle JET command-line interface communicates with requires that you configure environment variables. These environment variables reference the installation location of the Android SDK that is installed by Android Studio and the Java SE Development Kit 8.
- For Windows.
- Open the Environment Variables dialog from the System Properties dialog by navigating Control Panel >System and Security >System >Advanced System Settings >Environment Variables.
- Click New in the Environment Variables dialog and set the values of the variables to the location of the JDK and Android SDK locations, as shown in the following image. You can obtain the Android SDK location from the Android SDK page of the Default Settings dialog that you access in Android Studio by clicking Tools >SDK Manager.
Description of the illustration envvar.png
- For Mac and Linux-type systems, the settings depend upon your default shell. For example, on a Mac system using the Bash shell, add the following lines in
Источник
How to set Java SDK path in AndroidStudio?
I had Java 1.7.0_21 installed and I installed 1.7.0_45 today after uninstalling the previous version. Now Android Studio has stopped compiling projects and says that it cant locate the 1.7.0_21 folder. How can I set the new path for Java SDK? I have changed the environment variables also but didn’t work.
9 Answers 9
Up to Android Studio 4.2
Go to File > Project Structure > SDK Location. The third field is «JDK Location» where you can set it. This will set it for the current project.
To set the default for new projects, go to File > Other Settings > Default Project Structure > SDK Location and set the «JDK Location».
Android Studio Arctic Fox (2020.3.1)
In the Canary 14 of Android Studio Arctic Fox (2020.3.1), the JDK Location setting is moved to:
Older Versions
Go to File > Project Structure > [Platform Settings] > SDKs. You’ll need to either update you current SDK configuration to use the new directory, or define a new one and then change your project’s settings to use the new one. This will set it for the current project.
To set the default for new projects, go to File > Other Settings > Structure for New Projects > [Platform Settings] > SDKs and set the SDK to use when creating a new project.
Go to File> Project Structure (or press Ctrl+Alt+Shift+S), A popup will open now go to SDK Location Tab you will find JDK Location there refer this image to be more clear.
I tried updating all of my SDKs by just going into the Project Structure > Platform Settings > SDKs and changing the Java SDK, but that didn’t work, so I had to recreate the configurations from scratch.
Here’s how to create your SDKs with the latest Java:
- In Project Structure > Platform Settings > SDKs, click the «+» button to add a new SDK.
- In the pop-up, go into your Android SDK folder and click «Choose»
- Another pop-up will appear asking for which SDK and JDK you want to use. Choose any Android SDK and the 1.7 JDK.
- Go to Project Structure > Project Settings > Project and change your Project SDK to the one you just created. You should see the name of the SDK contain the new Java version that you installed.
Источник
Using JDK that is bundled inside Android Studio as JAVA_HOME on Mac
I tried to open Android Device Monitor and the Studio showed me this message =-O :
It surprised me, because how have I been able to develop Android apps if I didn’t have any Java installed?! Actually, Android Studio comes with bundled JDK/JRE (located in /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home ), but it is not found by the system: executed usr/libexec/java_home gives
Setting $JAVA_HOME to /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home did not help — source .bash_profile doesn’t like that it’s a directory.
QUESTION: I don’t want to install new JDK if I already have one inside Android Studio. How do I set it as system default?
4 Answers 4
Add the correct string to .bash_profile (and reload with source .bash_profile ):
- MacOS versions before Big Sur: export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/jdk/Contents/Home/ .
- Catalina, Big Sur, Mentere and above: export JAVA_HOME=/Applications/Android\ Studio.app/Contents/jre/Contents/Home
If you’re using Catalina and above, you most probably use zsh as a shell instead of bash. In that case, add it to .zshrc or .zprofile instead of .bash_profile in your home directory.
Don’t forget to restart the operating system after.
After that, running java -version gave this output and Java started to execute normally:
As for the Android Device Monitor — it still demands this ancient JRE version 6.
/.zshrc file) worked for me: export JAVA_HOME=»/Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/»
I just did a fresh install of Android Studio Arctic Fox 2020.3.1 on Big Sur, and I had to use the following.
On a slightly different topic, even with the correct JAVA_HOME ,
/Library/Android/sdk/tools/bin/sdkmanager wouldn’t start. I had to install «Android SDK Command-line Tools (latest)» (from Android Studio) and use
The core problem is that starting from Android Studio Arctic Fox the destination of bundled java has been changed from: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/ to: /Applications/Android Studio.app/Contents/jre/Contents/Home/
You just need to change JAVA_HOME env variable in .bash_profile to the new correct path (be careful with space character, easiest way just to specify path in doubled quotes). And either restart terminal or run source
As pointed out by dimezis, JAVA_HOME might be working but the /user/libexec/java_home is still broken.
This is because in Mac, java_home and JAVA_HOME are different. JAVA_HOME is the environment variable / path that will be used in most applications and environment while java_home is the actual executable that is being used by the system to run java. Apparently, some Mac applications (like Xcode) will just ignore the JAVA_HOME path and make use of the java_home executable
So in order to use the Android Studio Embedded JDK as default Java to be used in Mac, copy the entire embedded jdk folder /Applications/Android Studio.app/Contents/jre/jdk to the default Java library folder /Library/Java/JavaVirtualMachines/
After this, set your .bash_profile or .zshrc with this: export JAVA_HOME=$(/usr/libexec/java_home)
This will make sure that your JAVA_HOME and java_home is pointing to the same java installation.
Источник