I have jdk 6 and 7 installed on my PC.
On this link https://developer.android.com/sdk/index.html#ExistingIDE , I read that Android IDE is compatible with jdk 6, but I want to know if Android SDK works also with jdk 7 or if there are problems ?
If there are problems can I mantain the jdk 7 and configure Android sdk to use Jdk 6 ?
You can build a project using JDK 7 in Eclipse with the ADT plugin with no extra configuration and with any version of the ADT plugin, so long as you only use features in JDK 6.
Support for Java 7 language features was added to the Eclipse ADT plugin in March 2014 (ADT 22.6.0 and up). All you need to do is update your application project settings to use JDK 7 and ensure that Eclipse is running on JDK 7 as well.
Note that unless your minSdkVersion is 19+ (KitKat), you cannot use try-with-resources.
From the ADT plugin tools page:
ADT 22.6.0 (March 2014)
General Notes:
Added support for Java 7 language features like multi-catch, try-with-resources, and the diamond operator. These features require
version 19 or higher of the Build Tools. Try-with-resources requires
minSdkVersion 19; the rest of the new language features require
minSdkVersion 8 or higher.
To use the new language features after
installing ADT 22.6.0, ensure that you run Eclipse on JDK 7 and change
your application project settings to use JDK 7.
Yes, you can use Java 1.7 for the android development.
Starting from build tools 19, Android has full support for Java 1.7. So you can set 1.7 as source and target for compilation. Support for this is from Android studio 0.3.2. Android kitkat has full support of JAVA 1.7 API, but most of language features from 1.7, can be used on the older android versions too.
Edit:
You can also mantain the jdk 7 and configure the Android application to use Jdk 6 during compilation.
It's not even necessary to have JDK 6 installed. You can just configure Eclipse to "compile as JDK 6" and it will work.
To change for the whole workspace, enter Window -> Preferences, then Java -> Compiler and set Compiler compliance level to 1.6.
You can also do this in individual projects, if you prefer, in Project -> Properties -> Java Compiler.
I noticed the same problem today http://developer.android.com/sdk/installing/installing-adt.html where the recommended jdk is 1.6 but according to the main bundle Android has full support for 1.7 http://developer.android.com/sdk/installing/index.html?pkg=studio.
So I woudl say...Yes! 8 )
Related
I am a new developer and have recently installed Android studio 3.0 on my Windows 10 device with Java JDK version 9.0.4 installed but after installing, the app shows a problem:
could not determine java version 9.0.4
and shows a Gradle sync problem.
This issue was in gradle version lower than 4.3, so update your gradle.properties to 4.3 or above:
distributionUrl=https://services.gradle.org/distributions/gradle-4.4-all.zip
Why this error occur?: Because of you have different JDK on your system than your android-studio JDK version.
Therefore your JDK should be compatible with each other, and by following this way you can manage that:
File -> Other settings -> Default project structure
You can use embedded JDK or use your own.
I am using JDK8x64 (only) with Android Studio 2.1 and targeting Android 4+.
Here I think this JDK8x64 used for build system itself, not for exporting to Android. (So it is OK, because Java 8 is backward compatible). (OS: Win7x64)
But according to: https://forums.xamarin.com/discussion/48581/use-of-jdk-8-with-xamarin-android
Is it true that Building with JDK8 makes the app not works on older Android OS versions?
Any experience?
And what about JDK 8 with Xamarin Android?
You can use JDK 8 and the compiler will only use the features of Java that are available (you will not be able to use the latest features introduced in JDK 8 such as lambdas, otherwise you will get an error).
However, if you target Android N, you will be able to use OpenJDK 8's features, some of which are backward compatible with previous versions of Android (e.g. lambdas and method references are backwards compatible). To see what's available, check here:
Supported Java 8 Language Features and APIs
We been using v8 since it was released and have not had any problems within Xamarin.Android apps (or Java binding libraries):
>javac -version
javac 1.8.0_92
>java -version
java version "1.8.0_92"
Java(TM) SE Runtime Environment (build 1.8.0_92-b14)
Java HotSpot(TM) 64-Bit Server VM (build 25.92-b14, mixed mode)
That said, Xamarin website does state:
OS-X Requirements
Xamarin.Android requires the following for use with Xamarin Studio on a Mac:
Java JDK 7 (1.7)
If you are developing solely for Android versions older than Android 5.0 Lollipop (API 21), Java JDK 6 (1.6) can still be used. Later versions of the JDK can also be installed to run alongside JDK 6 or JDK 7 if required by your machine.
Windows Requirements:
Xamarin.Android also requires that a 32-bit Java JDK 7 (1.7) be installed.
Later versions of the JDK can also be installed alongside JDK 7, if required by your machine.
To answer your question, yes this is true. But Android Studio tends to handle this for you, as stated by #tyczj. Lets say for example you are building an app from JDK8 for your Android 4+, but I want to run that same app on my Android 2.3, which I still have. It might not work due to compatibility issues. Although Android Studio takes care of this by allowing you to specify which version(s) you would like to support, it wouldn't hurt to look at differences between JDK8 and say, JDK6.
I work on a LibGDX project in Android Studio 1.5 which has an android, core and desktop module. When I change the language level from "LANGUAGE_LEVEL=JDK_1_6" TO "LANGUAGE_LEVEL=JDK_1_8" in the iml files in these respective directories, after restarting the project they changed back to 1.6. However it isn't causing any errors by now and my project is compiling and running
Android Studio does not support Java 8 yet. Level 7 should work.
OS: OSX 10.9.2
build tool: gradle
platform: android
I've recently installed jdk 8 which i use for some side projects. i have 1.6, 1.7 and 1.8 installed at the same time.
The issue that i'm having is when building android projects, in android studio using gradlew its using jdk 8, instead of using the jdk that i've set for the project. This causes issues as one of the gradle plugins i'm using (new relic agent) does not yet support java 8.
I dont know how android studio decides what jdk to use for gradle, but it should use the same as the jdk you set for you project, otherwise what is the point in asking me to set one?
So my question is this. How can i set what jdk to use for gradlew in android studio, or in intellij in general as i'm sure this will affect other projects too
I am trying my hands on Android first time ever, so request you to pardon me if I sound too naive. I read on the ADT system requirements that it needs JDK 1.6 and also some of the tutorials it was said that ADT doesn't support JDK 1.7 yet.
I have both JDK 1.7 and JDK 1.6 ( also the JREs ) on my machine and I have set the JAVA_HOME to JDK 1.6. I tested by typing java -version and it shows me pointed to Java 1.6.
However, when I run the Android SDK Tools Wizard it detects JDK 1.7 instead of 1.6. I am not sure if continuing with JDK 1.7 would lead to future problems during development.
Please advise if this fine. Else, please suggest how can I correctly get this pointed to JDK 1.6. Note: I don't want to uninstall 1.7 as I need it for other development activities.
also some of the tutorials it was said that ADT doesn't support JDK 1.7 yet
ADT supports Java 1.7 (a.k.a., Java 7).
I tested by typing java -version and it shows me pointed to Java 1.6
Note that this is testing the runtime environment, not the development environment. Use javac -version to test what version of the Java compiler you are using.
I am not sure if continuing with JDK 1.7 would lead to future problems during development
That should be fine. I have been using Java 7 for the past 5-6 months without issue, albeit on Linux rather than Windows.
Here is answer to my question:
It seems the wizard was reading the JDK and JRE environment values from the Registry ( on Windows ) i.e HKEY_LOCAL_MACHINE variable. I changed the variable values there from 1.7 to 1.6 and it started picking up 1.6