Visual Studio Xamarin on Windows 10: Cannot determine Java Version - java

I've been trying to get started with Xamarin on Visual Studio Community 2019, but every time a new Android project is created and run, deployment is aborted and the warning below appears. I've already uninstalled and reinstalled both Java and VS, modified and repaired VS, and tried out different versions of the JDK, yielding no results. Any ideas on why this may be happening and how can it be fixed?
The current version of the JDK I'm using is 17.0.1

You can recheck if you have set up the Android SDK for Xamarin.Android correctly.
Xamarin.Android uses the Java Development Kit (JDK) and the Android SDK to build apps. During installation, the Visual Studio installer places these tools in their default locations and configures the development environment with the appropriate path configuration.
And for most users these default locations will work without further changes.
Xamarin.Android uses JDK 11, which is required for API 31 and greater, JDK 8, which is required if you are developing for API level 24 to 30 (JDK 8 also supports API levels earlier than 24).
For example:
For most users these default locations will work without further changes.
For more, you can check: https://learn.microsoft.com/en-us/xamarin/android/get-started/installation/windows#configuration
For how to set up the Android SDK for Xamarin.Android, you can check: Setting up the Android SDK for Xamarin.Android .
Note:
I recommend that you remove the older sdk and jdk files and use the latest version of Visual Studio with the default JDK and SDK Settings.

Related

will java17 work on older version of Android studio (specifically Android studio 1.5.1)

I have a system of 2ig ram so I was recommended to download and install Android studio 1.5.1 with java 7...
But I already have java17 installed..
Any Reason why won't java17 work on older version of Android studio specifically Android studio 1.5.1
Each version of Android Studio is designed to support a specific (maximum) version of Android.
That version of Android requires a specific version of the Java compiler to create its packages.
Java 17 (and indeed all versions from 9 and up) aren't (fully) backwards compatible with Java 8 and below.
It's not that you couldn't run the later versions of Android Studio without having an older Java SDK installed (it comes with its own built-in Java runtime for that), but you won't be able to successfully compile things.
Recommending Java 1.7 however is a big nono, that version has been out of support for years. At the very least you want Java 8.

Android development requires JDK 8(1.8)64-bit

I use unity 2020.3.13, i start to work with android game. I try to set the JDK with JDK that I got from Android Studio, but i get this error:
Incompatible Java version '16'
Android development requires JDK 8(1.8)64-bit. Having Java Runtime Environment(JRE) installed is not sufficient.
I'm confused because my JDK version is more than 8 but still can't. Do I have to install the exact JDK version 8? And is it better to use Unity's provided JDK, SDK, NDK, and Gradle or the ones from Android Studio?
Finally, it turned out that the problem was with my JDK installation. i re-installed the android module in unity and used the jdk given by unity and everything worked fine

How to add Java 9 to Android Studio?

I am using Robolectric library and the latest version of it v4.3.1 requires Java 9 to run. I am trying to point JRE on edit configurations but I am not finding Java 9 in the drop-down, even though I have already installed it.
Please check Java 9 installed.
The only workaround to run Robolectric test in the Android Studio is to change JRE for the test task.
Select IDE menu Run -> Edit Configuration and then change the option from the picture to the location of JDK9:
Tests can run on prior versions as a temporary workaround
You will not be able to run Robolectric against SDK 29 for now (27 April 2020), but this will likely be updated in the future. Currently, as all of the answers before me pointed out, there is no support of Java 9 or later in Android Studio.
But if you are here to make your Robolectic tests run you could simply avoid SDK 29 by setting the Robolectric #Config annotation for your class. Robolectric will simply run your tests against all of the supported SDK versions of your app except 29.
Implement
Set the maxSdk and minSdk versions to run on. This can be based on the app's min and max SDK versions, or set to one version like below in order to make tests faster.
import androidx.test.ext.junit.runners.AndroidJUnit4
import org.robolectric.annotation.Config
import org.junit.runner.RunWith
import android.os.Build
#RunWith(AndroidJUnit4::class)
#Config(maxSdk = Build.VERSION_CODES.P, minSdk = Build.VERSION_CODES.P) // Value of Build.VERSION_CODES.P is 28
class TestClass {
...
}
Of course it is just another "ugly" patch, but it will get you going until you'll be able to run tests against all of the desired SDKs, or at least SDK 29 and all below.
So far Android doesn't support Java 9. As per documentation, Android supports all Java 7 features and a part of Java 8 features.
When developing apps for Android, using Java 8 language features is
optional. You can keep your project's source and target compatibility
values set to Java 7, but you still need to compile using JDK 8.
I don't guarantee that it will work but you can set JDK to any version from the project Structure Option
File>Project Structure>SDK Location>'change JDK location here'
sorry but it's not working either i have tried to select JDK9 but i got a prompt like this
You can't use Java 9, Android only supports till Java 8.
You should use the JDK version that comes with Android Studio, no need for side alone JDK. The current JDK version is based on OpenJDK 8.
In Android Studio, under "Build, Execution, Deployment => Gradle => Gradle JDK", you can choose the JDK version. In newer versions of Android Studio like Artic Fox, it comes with JDK11.

How to configure Unity 2017.4 to target Android and avoid build failures on OSX?

I have been struggling with several build failures after installing a fresh/new system with the latest version of Android Studio (3.1) and Unity (2017.4). Failures like: CommandInvokationFailure: Unable to list target platforms. Please make sure the android sdk path is correct that span multiple duplicates since offered solutions are workarounds and do not explain the root problem well and how to gracefully solve this on Mac.
In Unity -> Preferences -> External
Tools I have properly set the Android SDK path to point to the one installed by Android Studio and also the JDK to point to a JDK 8 version (I know that right now the Android tools do not work with Java 9+) but I still get the build failures.
I'm looking for a solution that:
allows me to keep multiple java versions (I use jenv)
does not mess with symlinks in my java setup
allows me to use my android sdk installation (I use the one in Android Studio) and does not require me to mess with it (e.g downgrading Android Tools) except by officially installing any missing module
It seems that in order to do the Android builds the current version of Unity not only relies on the JDK set up in Preferences -> External Tools but also on the global java home as returned by the command /usr/libexec/java_home on Macs. So both must point to a JDK 8 version (v 9 or 10 won't work).
So, if it's not an option for you to remove Java 9/10 from the system, you will have to make sure /usr/libexec/java_home points to the JDK 8 installation.
Unfortunately this command does not allow you to set or configure a specific JDK - it returns the highest version by default, based on sorting the info provided in Info.plist under Contents in each VM.
Prerequisite: make sure you have downloaded all necessary modules for your build via Android Studio's SDK manager
Solution: In order to fix this gracefully you can go to /Library/Java/JavaVirtualMachines, locate the VMs equal to 9 or greater (right now either 9 or 10) and in their Contents directory rename Info.plist to Info.plist.off or similar. That JDK can still be used when $JAVA_HOME points to it, or is explicitly referenced in a script or configuration (e.g. used with jenv). After you do this /usr/libexec/java_home will point to a JDK 8 VM and your build will succeed.
Hopefully this will be a non issue once Google makes sure the Android tools work with the latest versions of Java, and once Unity relies completely on the configured SDK instead of also using the system-wide/global Java system arbitrarily.

Setting up Eclipse for Android Development and testing

As the title suggests, the issue I am having is in setting up Eclipse for Android Development and testing. There are two installations that need to be in sync. There is the ADT and there is the SDK. The problem I seem to be having stems from the fact that the latest version of the ADT is not compliant with what I need to do. I cannot use the ADT version 23. Instead, I need to use version 22.
The problem is in the fact that the SDK and the ADT have to be the same versions. How do I get and use version 22 of the SDK for android development for Eclipse?
clean out the ADT install features ( DDMS, traceview, etc ) by displaying Help installed features then hilite them and press the 'uninstall' button.
ANDROID ADT etc now cleaned out of eclipse.
download install from archive the following link:
dl.google.com/android/android-sdk_r22.6.2-linux.tgz
That will install correct SDK.
Then you have to add ADT to eclipse without it default to R 23 where you will get the 'incompatible ' message list......
I think this will help you with the last item on reverting ADT to R 22

Categories

Resources