android studio - set gradlew/gradle jdk - android

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

Related

Could not determine Java version 9.0.4

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.

Error when building android APK

I have Android-studio 2.3.2 (which is android-studio-ide-162.3934792-linux.zip) installed, which is the latest stable version. I am using fedora 24. I am using meteor 1.4.4.2
When I build an APK using "meteor build" I get this error:
While building Cordova app for
platform Android: Could not find gradle wrapper within Android SDK.
Might need to update your Android SDK. Looked here: ~/Android/Sdk/tools/templates/gradle/wrapper
It seems to me the path to gradle wrapper has changed on the latest version of Android-studio. I don't have a previous version of Android-studio to prove this though. I've searched for previous versions of Android-studio and could not find them. I have searched for a solution but there is no one out there who seems to be solving this issue.
You will find a solution in this other thread and some explanation in this answer
The explanation is that the linux version of cordova does not search for gradle in the Android studio install folders like for Windows (and even for windows it does not find it if android studion is not installed in c:\program files\android\android studio) or Mac .
On Linux (and maybe for Mac&Windows in future versions of Cordova), you have to install a version of gradle and add it to your path (way to install gradle depends on the version of Linux you're using)
The behaviour was different in the past because android sdk was not inside Android studio like it is now. You could find gradle in the ANDROID_HOME/tools folder.
With recent upgrades, Android SDK structure has changed and it is now part of android studio.
Installing android-sdk_r24.4.1-linux.tgz which installs version 25 or higher version by default solved the problem for me. Because I could not find a way to uninstall Android Studio I had to uninstall and re-install my linux.
See https://gist.github.com/rolandboon/0a5abe1d9c6c515c59ec for downloading and installing the sdk

Why does Android Studio resets the LANGUAGE_LEVEL to JDK 1.6 after restart of the project when I manually changed it to JDK 1.8

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.

Compiling AOSP and running Android Studio on the same machine, a possible scenario?

I'm trying to get my Fedora 22 machine to be able to both compile AOSP, which requires OpenJDK 1.7, and run Android Studio, which requires OpenJDK 1.8 (for Gradle).
Is there a way to make them both work correctly and live happily together on the same OS?
You can have as many JDK versions (OpenJDK, Oracle, 6, 7, 8) installed as you want.
The make process for the AOSP project will probably pick up the version form the JAVA_HOME variable (perhaps you can even supply one yourself?).
In Android Studio you can select the JDK per module with right click on module -> open module settings -> SDK location.
I haven't tried it myself but I don't see any reason why this wouldn't work.

Having problems downloading Android Development Tools for Eclipse 4.1.0

I tried to download the Development tools for the Android SDK last night and have been getting this error every time I try to download it ever since:
Cannot complete the install because one or more required items could
not be found. Software being installed: Android Development Tools
16.0.1.v201112150204-238534 (com.android.ide.eclipse.adt.feature.group 16.0.1.v201112150204-238534)
I've tried running Eclipse as an administrator, downloading the Google Plugin for Eclipse Galileo, and many assortment of things, but nothing seems to work. Is there a Google plugin for 4.1.0, would I have to reinstall an earlier version of Eclipse, or am I missing something else entirely?
NB: I've been using Windows 7 64-bit Eclipse 4.1.0, as well as the 64-bit version of JDK 1.7.
android sdk dosen't support JDK 1.7, use 1.6.
you should use Eclipse 3.7. Eclipse 4.* is a work in progress and shouldn't be used in production environments yet.
You did not mention anything about the Android Development Tool (ADT) which is required to develop Android apps.
You can get it from here, http://developer.android.com/sdk/eclipse-adt.html
You will need Android SDK r16
Does my answer to this question help?
Also note that there have been some documented bugs with running Eclipse in JDK 1.7 - make sure you have the very latest updates to JDK or use 1.6 instead.

Categories

Resources