-
Notifications
You must be signed in to change notification settings - Fork 524
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
JetBrains OpenJDK 11 #4567
JetBrains OpenJDK 11 #4567
Conversation
Context: https://issuetracker.google.com/issues/150189789 Context: dotnet/android#4562 Context: dotnet/android#4567 Bumps to xamarin/xamarin-android-tools/master@36d7fee5 Changes: dotnet/android-tools@bfb66f3...36d7fee * dotnet/android-tools@36d7fee: JetBrains OpenJDK 11 detection (dotnet#82) * dotnet/android-tools@12f52ac: Merge pull request dotnet#80 from jonpryor/jonp-drop-net461 * dotnet/android-tools@c7090d0: [Xamarin.Android.Tools.AndroidSdk] Remove net461 JDK 9 -- released 2017-July-27 -- introduced many new features, but broke various Android SDK toolchain programs in various inscrutable ways, so the Android community has been "stuck" on JDK 8 ever since. …until now? A preview version of `apksigner` in the Build-tools 30rc1 package states that it requires Java 9 in order to run, which means we must explore what is required to build under JDK > 8. [JetBrains has an OpenJDK 11.0.4 release for macOS][0], which has a "weird" directory structure but is otherwise workable, so… Will It Build™? $ curl -o jbrsdk-11_0_4-osx-x64-b546.1.tar.gz https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-11_0_4-osx-x64-b546.1.tar.gz # Above doesn't *actually* work; use a browser to appease Akamai $ tar xzf jbrsdk-11_0_4-osx-x64-b546.1.tar.gz $ export JAVA_HOME=$HOME/Downloads/jbrsdk/Contents/Home $ make prepare JI_MAX_JDK=12 $ make all Yes, it builds, but that's *misleading*: it's not actually using `$JAVA_HOME`! …/Java.Interop/build-tools/scripts/jdk.targets(5,5): warning : Not a valid JDK directory: `…/Java.Interop/jbrsdk/Contents/Home`; via locator: $JAVA_HOME System.ArgumentException: Could not find required file `jvm` within `…/Java.Interop/jbrsdk/Contents/Home`; is this a valid JDK? Parameter name: homePath at Xamarin.Android.Tools.JdkInfo.ValidateFile (System.String name, System.String path) at Xamarin.Android.Tools.JdkInfo..ctor (System.String homePath) This is fixed via dotnet/android-tools@36d7fee. Bump xamarin-android-tools, and `make prepare` still works. `make all` fails: $ make all … "…/Java.Interop/jbrsdk/Contents/Home/bin/javac" -parameters -source 1.6 -target 1.6 -bootclasspath "…/Java.Interop/jbrsdk/Contents/Home/bin/../jre/lib/rt.jar" -g -d "obj/Debug/classes" java/android/annotation/NonNull.java java/android/annotation/NonNull.java java/com/xamarin/IJavaInterface.java java/com/xamarin/IParameterInterface.java java/com/xamarin/JavaAnnotation.java java/com/xamarin/JavaType.java java/com/xamarin/NestedInterface.java java/com/xamarin/NotNullClass.java java/com/xamarin/ParameterAbstractClass.java java/com/xamarin/ParameterClass.java java/com/xamarin/ParameterClass2.java java/java/util/Collection.java java/NonGenericGlobalType.java EXEC : warning : [options] source value 6 is obsolete and will be removed in a future release EXEC : warning : [options] target value 1.6 is obsolete and will be removed in a future release EXEC : warning : -parameters is not supported for target value 1.6. Use 1.8 or later. EXEC : warning : [options] To suppress warnings about obsolete options, use -Xlint:-options. 4 warnings EXEC : Fatal error : Unable to find package java.lang in classpath or bootclasspath The problem is that JetBrains' OpenJDK 11 no longer contains a `…/jre/lib/rt.jar` file, so the `-bootclasspath` value is now wrong. Additionally, if you don't use `javac -target`, which implicitly targets JDK 11, `javac` doesn't like that: EXEC : error : option --boot-class-path not allowed with target 11 The solution? Don't Do That™; if `javac` from OpenJDK 11 doesn't want `-bootclasspath`, don't provide it. Update the `<JdkInfo/>` task to check for the existence of the `…/jre/lib/rt.jar` file; if it exists, set `$(JreRtJarPath)`, otherwise the `$(JreRtJarPath)` MSBuild property is empty. Then update `$(_JavacSourceOptions)` so that it *doesn't* provide `-bootclasspath` when `$(JreRtJarPath)` is empty. These three changes -- xamarin-android-tools bump, `<JdkInfo/>` update, and `$(_JavacSourceOptions)` update -- allow `make all` to build successfully. Then we hit *unit* tests. The above `javac` invocation has a warning: EXEC : warning : -parameters is not supported for target value 1.6. Use 1.8 or later. Even though we've been using `javac -target 1.6 -parameters` for *ages*, this combination is no longer supported. In order to use `javac -parameters` now, we need to use `javac -target 1.8`. Update `$(JavacSourceVersion)` to 1.8 so that we can continue using `javac -parameters`, which in turn requires that we update `tests/Xamarin.Android.Tools.Bytecode-Tests` so that we expect the newly updated `.class` file MajorVersion values. [0]: https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-11_0_4-osx-x64-b546.1.tar.gz
Context: https://issuetracker.google.com/issues/150189789 Context: dotnet/android#4562 Context: dotnet/android#4567 Bumps to xamarin/xamarin-android-tools/master@36d7fee5 Changes: dotnet/android-tools@bfb66f3...36d7fee * dotnet/android-tools@36d7fee: JetBrains OpenJDK 11 detection (#82) * dotnet/android-tools@12f52ac: Merge pull request #80 from jonpryor/jonp-drop-net461 * dotnet/android-tools@c7090d0: [Xamarin.Android.Tools.AndroidSdk] Remove net461 JDK 9 -- released 2017-July-27 -- introduced many new features, but broke various Android SDK toolchain programs in various inscrutable ways, so the Android community has been "stuck" on JDK 8 ever since. …until now? A preview version of `apksigner` in the Build-tools 30rc1 package states that it requires Java 9 in order to run, which means we must explore what is required to build under JDK > 8. [JetBrains has an OpenJDK 11.0.4 release for macOS][0], which has a "weird" directory structure but is otherwise workable, so… Will It Build™? $ curl -o jbrsdk-11_0_4-osx-x64-b546.1.tar.gz https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-11_0_4-osx-x64-b546.1.tar.gz # Above doesn't *actually* work; use a browser to appease Akamai $ tar xzf jbrsdk-11_0_4-osx-x64-b546.1.tar.gz $ export JAVA_HOME=`pwd`/jbrsdk/Contents/Home $ make prepare JI_MAX_JDK=12 $ make all Yes, it builds, but that's *misleading*: it's not actually using `$JAVA_HOME`! …/Java.Interop/build-tools/scripts/jdk.targets(5,5): warning : Not a valid JDK directory: `…/Java.Interop/jbrsdk/Contents/Home`; via locator: $JAVA_HOME System.ArgumentException: Could not find required file `jvm` within `…/Java.Interop/jbrsdk/Contents/Home`; is this a valid JDK? Parameter name: homePath at Xamarin.Android.Tools.JdkInfo.ValidateFile (System.String name, System.String path) at Xamarin.Android.Tools.JdkInfo..ctor (System.String homePath) This is fixed via dotnet/android-tools@36d7fee. Bump xamarin-android-tools, and `make prepare` still works. `make all` fails: $ make all … "…/Java.Interop/jbrsdk/Contents/Home/bin/javac" -parameters -source 1.6 -target 1.6 -bootclasspath "…/Java.Interop/jbrsdk/Contents/Home/bin/../jre/lib/rt.jar" -g -d "obj/Debug/classes" java/android/annotation/NonNull.java java/android/annotation/NonNull.java java/com/xamarin/IJavaInterface.java java/com/xamarin/IParameterInterface.java java/com/xamarin/JavaAnnotation.java java/com/xamarin/JavaType.java java/com/xamarin/NestedInterface.java java/com/xamarin/NotNullClass.java java/com/xamarin/ParameterAbstractClass.java java/com/xamarin/ParameterClass.java java/com/xamarin/ParameterClass2.java java/java/util/Collection.java java/NonGenericGlobalType.java EXEC : warning : [options] source value 6 is obsolete and will be removed in a future release EXEC : warning : [options] target value 1.6 is obsolete and will be removed in a future release EXEC : warning : -parameters is not supported for target value 1.6. Use 1.8 or later. EXEC : warning : [options] To suppress warnings about obsolete options, use -Xlint:-options. 4 warnings EXEC : Fatal error : Unable to find package java.lang in classpath or bootclasspath The problem is that JetBrains' OpenJDK 11 no longer contains a `…/jre/lib/rt.jar` file, so the `-bootclasspath` value is now wrong. Additionally, if you don't use `javac -target`, which implicitly targets JDK 11, `javac` doesn't like that: EXEC : error : option --boot-class-path not allowed with target 11 The solution? Don't Do That™; if `javac` from OpenJDK 11 doesn't want `-bootclasspath`, don't provide it. Update the `<JdkInfo/>` task to check for the existence of the `…/jre/lib/rt.jar` file; if it exists, set `$(JreRtJarPath)`, otherwise the `$(JreRtJarPath)` MSBuild property is empty. Then update `$(_JavacSourceOptions)` so that it *doesn't* provide `-bootclasspath` when `$(JreRtJarPath)` is empty. These three changes -- xamarin-android-tools bump, `<JdkInfo/>` update, and `$(_JavacSourceOptions)` update -- allow `make all` to build successfully. Then we hit *unit* tests. The above `javac` invocation has a warning: EXEC : warning : -parameters is not supported for target value 1.6. Use 1.8 or later. Even though we've been using `javac -target 1.6 -parameters` for *ages*, this combination is no longer supported. In order to use `javac -parameters` now, we need to use `javac -target 1.8`. Update `$(JavacSourceVersion)` to 1.8 so that we can continue using `javac -parameters`, which in turn requires that we update `tests/Xamarin.Android.Tools.Bytecode-Tests` so that we expect the newly updated `.class` file MajorVersion values. [0]: https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-11_0_4-osx-x64-b546.1.tar.gz
Depends on: https://github.com/xamarin/monodroid/pull/1083 |
This PR is a test to see what works and what breaks with JetBrains OpenJDK 11 as far as Xamarin.Android is concerned.
Changes: dotnet/java-interop@80b4667...c19794e Changes: dotnet/android-tools@36d7fee...f473ff9 Java.Interop changes are for OpenJDK11 build support
It builds locally! (If that actually means anything.) (Unit tests untested.) Make "global" `$(JavacSourceVersion)` and `$(JavacTargetVersion)` MSBuild properties for great consistency! Use a new `$(JavacTargetVersion)` value for `javac -target` instead of reusing `$(JavacSourceVersion)`, because...why not? Cleanup `build-tools/scripts/Jar.targets` to *not* change the behavior depending on what the installed JDK is. JDK 1.8 is now a *minimum* to *build* xamarin-android...and probably to *run* any Java code that we build. (Maybe.) Various fixes to allow dotnet/java-interop@6d7266dd9 to build.
5929d13
to
3e6af18
Compare
Looks like macOS is able to build, but not Windows:
|
Discussed the Windows failure, and the consensus was that we should |
The AllActivityAttributeProperties("manifestmerger.jar") unit test fails:
It appears that if our Gradle-based projects such as We'll need to update our Gradle projects accordingly. |
Our build outputs still need to be runnable on machines using JDK 1.8. Otherwise, things may break when using those `.jar` files: error AMM0000: java.lang.UnsupportedClassVersionError: com/xamarin/manifestmerger/Main has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0 error AMM0000: at java.lang.ClassLoader.defineClass1(Native Method) error AMM0000: at java.lang.ClassLoader.defineClass(ClassLoader.java:763) error AMM0000: at java.security.SecureClassLoader.defineClass(SecureClassLoader.java:142) error AMM0000: at java.net.URLClassLoader.defineClass(URLClassLoader.java:468) error AMM0000: at java.net.URLClassLoader.access$100(URLClassLoader.java:74) error AMM0000: at java.net.URLClassLoader$1.run(URLClassLoader.java:369) error AMM0000: at java.net.URLClassLoader$1.run(URLClassLoader.java:363) error AMM0000: at java.security.AccessController.doPrivileged(Native Method) error AMM0000: at java.net.URLClassLoader.findClass(URLClassLoader.java:362) error AMM0000: at java.lang.ClassLoader.loadClass(ClassLoader.java:424) error AMM0000: at sun.misc.Launcher$AppClassLoader.loadClass(Launcher.java:349) error AMM0000: at java.lang.ClassLoader.loadClass(ClassLoader.java:357) error AMM0000: at sun.launcher.LauncherHelper.checkAndLoadMain(LauncherHelper.java:495) error AMM0000: Error: A JNI error has occurred, please check your installation and try again error AMM0000: Exception in thread "main" error AMM0000: java.lang.UnsupportedClassVersionError : com/xamarin/manifestmerger/Main has been compiled by a more recent version of the Java Runtime (class file version 55.0), this version of the Java Runtime only recognizes class file versions up to 52.0
`dx` doesn't like OpenJDK 11 on Windows: "C:\Users\dlab14\android-toolchain\sdk\build-tools\29.0.2\dx" --dex --no-strict --output="C:\A\vs2019xam00000H-1\_work\2\s\bin\Release\lib\xamarin.android\xbuild\Xamarin\Android\java_runtime.dex" "C:\A\vs2019xam00000H-1\_work\2\s\bin\Release\lib\xamarin.android\xbuild\Xamarin\Android\java_runtime.jar" ##[debug]Processed: ##vso[task.logdetail id=dffb25d4-cb0b-4e58-94d2-4b9a4f215bed;parentid=;name=EXEC;type=Build;starttime=2020-04-19T01:21:10.0332656Z;state=InProgress;] ##[error]EXEC(0,0): Error : No suitable Java found. In order to properly use the Android Developer ##[debug]Processed: ##vso[task.logissue type=Error;sourcepath=EXEC;linenumber=0;columnnumber=0;code=;]No suitable Java found. In order to properly use the Android Developer ##[debug]Processed: ##vso[task.logdetail id=dffb25d4-cb0b-4e58-94d2-4b9a4f215bed;parentid=;type=Build;result=Failed;finishtime=2020-04-19T01:21:10.0488457Z;progress=100;state=Completed;parentid=;name=;] EXEC : error : No suitable Java found. In order to properly use the Android Developer [C:\A\vs2019xam00000H-1\_work\2\s\src\java-runtime\java-runtime.csproj] Tools, you need a suitable version of Java JDK installed on your system. We recommend that you install the JDK version of JavaSE, available here: http://www.oracle.com/technetwork/java/javase/downloads If you already have Java installed, you can define the JAVA_HOME environment variable in Control Panel / System / Avanced System Settings to point to the JDK folder. You can find the complete Android SDK requirements here: http://developer.android.com/sdk/requirements.html ##[error]src\java-runtime\java-runtime.targets(59,3): Error MSB3073: The command ""C:\Users\dlab14\android-toolchain\sdk\build-tools\29.0.2\dx" --dex --no-strict --output="C:\A\vs2019xam00000H-1\_work\2\s\bin\Release\lib\xamarin.android\xbuild\Xamarin\Android\java_runtime.dex" "C:\A\vs2019xam00000H-1\_work\2\s\bin\Release\lib\xamarin.android\xbuild\Xamarin\Android\java_runtime.jar"" exited with code -1. Use `r8.jar` instead, to hopefully avoid the problem.
Context: https://issuetracker.google.com/issues/150189789 Context: dotnet/android#4562 Context: dotnet/android#4567 Bumps to xamarin/xamarin-android-tools/master@36d7fee5 Changes: dotnet/android-tools@bfb66f3...36d7fee * dotnet/android-tools@36d7fee: JetBrains OpenJDK 11 detection (#82) * dotnet/android-tools@12f52ac: Merge pull request #80 from jonpryor/jonp-drop-net461 * dotnet/android-tools@c7090d0: [Xamarin.Android.Tools.AndroidSdk] Remove net461 JDK 9 -- released 2017-July-27 -- introduced many new features, but broke various Android SDK toolchain programs in various inscrutable ways, so the Android community has been "stuck" on JDK 8 ever since. …until now? A preview version of `apksigner` in the Build-tools 30rc1 package states that it requires Java 9 in order to run, which means we must explore what is required to build under JDK > 8. [JetBrains has an OpenJDK 11.0.4 release for macOS][0], which has a "weird" directory structure but is otherwise workable, so… Will It Build™? $ curl -o jbrsdk-11_0_4-osx-x64-b546.1.tar.gz https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-11_0_4-osx-x64-b546.1.tar.gz # Above doesn't *actually* work; use a browser to appease Akamai $ tar xzf jbrsdk-11_0_4-osx-x64-b546.1.tar.gz $ export JAVA_HOME=`pwd`/jbrsdk/Contents/Home $ make prepare JI_MAX_JDK=12 $ make all Yes, it builds, but that's *misleading*: it's not actually using `$JAVA_HOME`! …/Java.Interop/build-tools/scripts/jdk.targets(5,5): warning : Not a valid JDK directory: `…/Java.Interop/jbrsdk/Contents/Home`; via locator: $JAVA_HOME System.ArgumentException: Could not find required file `jvm` within `…/Java.Interop/jbrsdk/Contents/Home`; is this a valid JDK? Parameter name: homePath at Xamarin.Android.Tools.JdkInfo.ValidateFile (System.String name, System.String path) at Xamarin.Android.Tools.JdkInfo..ctor (System.String homePath) This is fixed via dotnet/android-tools@36d7fee. Bump xamarin-android-tools, and `make prepare` still works. `make all` fails: $ make all … "…/Java.Interop/jbrsdk/Contents/Home/bin/javac" -parameters -source 1.6 -target 1.6 -bootclasspath "…/Java.Interop/jbrsdk/Contents/Home/bin/../jre/lib/rt.jar" -g -d "obj/Debug/classes" java/android/annotation/NonNull.java java/android/annotation/NonNull.java java/com/xamarin/IJavaInterface.java java/com/xamarin/IParameterInterface.java java/com/xamarin/JavaAnnotation.java java/com/xamarin/JavaType.java java/com/xamarin/NestedInterface.java java/com/xamarin/NotNullClass.java java/com/xamarin/ParameterAbstractClass.java java/com/xamarin/ParameterClass.java java/com/xamarin/ParameterClass2.java java/java/util/Collection.java java/NonGenericGlobalType.java EXEC : warning : [options] source value 6 is obsolete and will be removed in a future release EXEC : warning : [options] target value 1.6 is obsolete and will be removed in a future release EXEC : warning : -parameters is not supported for target value 1.6. Use 1.8 or later. EXEC : warning : [options] To suppress warnings about obsolete options, use -Xlint:-options. 4 warnings EXEC : Fatal error : Unable to find package java.lang in classpath or bootclasspath The problem is that JetBrains' OpenJDK 11 no longer contains a `…/jre/lib/rt.jar` file, so the `-bootclasspath` value is now wrong. Additionally, if you don't use `javac -target`, which implicitly targets JDK 11, `javac` doesn't like that: EXEC : error : option --boot-class-path not allowed with target 11 The solution? Don't Do That™; if `javac` from OpenJDK 11 doesn't want `-bootclasspath`, don't provide it. Update the `<JdkInfo/>` task to check for the existence of the `…/jre/lib/rt.jar` file; if it exists, set `$(JreRtJarPath)`, otherwise the `$(JreRtJarPath)` MSBuild property is empty. Then update `$(_JavacSourceOptions)` so that it *doesn't* provide `-bootclasspath` when `$(JreRtJarPath)` is empty. These three changes -- xamarin-android-tools bump, `<JdkInfo/>` update, and `$(_JavacSourceOptions)` update -- allow `make all` to build successfully. Then we hit *unit* tests. The above `javac` invocation has a warning: EXEC : warning : -parameters is not supported for target value 1.6. Use 1.8 or later. Even though we've been using `javac -target 1.6 -parameters` for *ages*, this combination is no longer supported. In order to use `javac -parameters` now, we need to use `javac -target 1.8`. Update `$(JavacSourceVersion)` to 1.8 so that we can continue using `javac -parameters`, which in turn requires that we update `tests/Xamarin.Android.Tools.Bytecode-Tests` so that we expect the newly updated `.class` file MajorVersion values. [0]: https://bintray.com/jetbrains/intellij-jdk/download_file?file_path=jbrsdk-11_0_4-osx-x64-b546.1.tar.gz
java-runtime.targets requires that r8.jar exist in order to run.
Remember commit 6601fbc? Same deal, different file.
Context: dotnet#4567 The Android SDK `lint` utility is now in *two* Android SDK packages: the `tools` package, and the `cmdline-tools` package, e.g. as of commit d99facb, *both* of these exist on e.g. macOS: * `$HOME/android-toolchain/sdk/tools/bin/lint` * `$HOME/android-toolchain/sdk/cmdline-tools/1.0/bin/lint` There are two important differences of interest: 1. `tools/bin/lint` will not run on OpenJDK 11. 2. `cmdline-tools/1.0/bin/lint` has a *lower version* than `tools/bin/lint`. *Much* lower: % ~/android-toolchain/sdk/tools/bin/lint --version lint: version 26.1.1 % ~/android-toolchain/sdk/cmdline-tools/1.0/bin/lint --version lint: version 3.6.0 (1) means that we can't use the previous `lint` in an OpenJDK11 world, and thus we should migrate to the cmdline-tools `lint`. Support this by adding a new `$(AndroidCommandLineToolsVersion)` MSBuild property to `Xamarin.Android.Common.props.in` and `Microsoft.Android.Sdk.props`, which allows controlling which `cmdline-tools` package version to use, if more than one is present. The default value is `1.0`. (2) means that the `<Lint/>` Task is *broken* when using the cmdline-tools version of `lint`, becasuse certain `lint --disable` flags are protected by version checks, which are now all "wrong" when we "expect" >= 26.1.1 and instead get 3.6.0. Attempt to address (2) by assuming that we're using the cmdline-tools package if `ToolPath` contains `cmdline-tools`, in which case we treat `lint` as newer than any previous version. (This may be less than ideal.)
Context: #4567 The Android SDK `lint` utility is now in *two* Android SDK packages: the `tools` package, and the `cmdline-tools` package, e.g. as of commit d99facb, *both* of these exist on e.g. macOS: * `$HOME/android-toolchain/sdk/tools/bin/lint` * `$HOME/android-toolchain/sdk/cmdline-tools/1.0/bin/lint` There are two important differences of interest: 1. `tools/bin/lint` will not run on OpenJDK 11. 2. `cmdline-tools/1.0/bin/lint` has a *lower version* than `tools/bin/lint`. *Much* lower: % ~/android-toolchain/sdk/tools/bin/lint --version lint: version 26.1.1 % ~/android-toolchain/sdk/cmdline-tools/1.0/bin/lint --version lint: version 3.6.0 (1) means that we can't use the previous `lint` in an OpenJDK11 world, and thus we should migrate to the cmdline-tools `lint`. Support this by adding a new `$(AndroidCommandLineToolsVersion)` MSBuild property to `Xamarin.Android.Common.props.in` and `Microsoft.Android.Sdk.props`, which allows controlling which `cmdline-tools` package version to use, if more than one is present. The default value is `1.0`. (2) means that the `<Lint/>` Task is *broken* when using the cmdline-tools version of `lint`, becasuse certain `lint --disable` flags are protected by version checks, which are now all "wrong" when we "expect" >= 26.1.1 and instead get 3.6.0. Attempt to address (2) by assuming that we're using the cmdline-tools package if `ToolPath` contains `cmdline-tools`, in which case we treat `lint` as newer than any previous version. (This may be less than ideal.)
Why is macOS+Designer failing again? It should be using JDK11, for now, yet apparently isn't? No idea why; hoping that `nuget restore -Verbosity detailed` will help.
Context: dotnet#4567 Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3729696&view=ms.vss-test-web.build-test-results-tab&runId=13228096&resultId=100066&paneView=attachments `<CreateMultiDexMainDexClassList/>` fails under JDK11: $ /Users/runner/Library/Android/jdk/bin/java \ -Djava.ext.dirs=/Users/runner/Library/Android/sdk/build-tools/29.0.2/lib \ com.android.multidex.MainDexListBuilder … -Djava.ext.dirs=/Users/runner/Library/Android/sdk/build-tools/29.0.2/lib is not supported. Use -classpath instead. CREATEMULTIDEXMAINDEXCLASSLIST : error : Could not create the Java Virtual Machine. CREATEMULTIDEXMAINDEXCLASSLIST : error : A fatal exception has occurred. Program will exit. The command exited with code 1. Under JDK11, `java` no longer supports `-Djava.ext.dirs`. Update `<CreateMultiDexMainDexClassList/>` so that it constructs a `java -classpath` value and uses that.
…11 (#4782) Context: #4567 Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3729696&view=ms.vss-test-web.build-test-results-tab&runId=13228096&resultId=100066&paneView=attachments `<CreateMultiDexMainDexClassList/>` fails under JDK11: $ /Users/runner/Library/Android/jdk/bin/java \ -Djava.ext.dirs=/Users/runner/Library/Android/sdk/build-tools/29.0.2/lib \ com.android.multidex.MainDexListBuilder … -Djava.ext.dirs=/Users/runner/Library/Android/sdk/build-tools/29.0.2/lib is not supported. Use -classpath instead. CREATEMULTIDEXMAINDEXCLASSLIST : error : Could not create the Java Virtual Machine. CREATEMULTIDEXMAINDEXCLASSLIST : error : A fatal exception has occurred. Program will exit. The command exited with code 1. Under JDK11, `java` no longer supports `-Djava.ext.dirs`. Update `<CreateMultiDexMainDexClassList/>` so that it constructs a `java -classpath` value and uses that.
parameters: | ||
xaSourcePath: $(System.DefaultWorkingDirectory)/xamarin-android | ||
|
||
- script: echo "##vso[task.setvariable variable=JavaSdkDirectory]$HOME/android-toolchain/$($(XA.Jdk11.Folder)" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There are some extra characters in this line that need to be removed.
The Designer currently only supports JDK8, which is why commit c8ab455 installed *both* JDK 1.8 & JDK 11. Revert `$(AndroidSdkBuildToolsVersion)` to 29.0.2 so that JDK 11 is no longer required, and update the Designer builds to use JDK 1.8. This should allow the Designer integration tests to pass.
Context: #4567 We want to support using OpenJDK 11 to build Xamarin.Android projects. For better or worse, we can't "change the entire world," not all at once. In particular, the Android Designer Integration Tests do not currently support building with or running under JDK 11. "Split the difference", kind of: Instead of installing Corretto JDK 8 into `$HOME/android-toolchain/jdk`, install JetBrains OpenJDK 8 and 11 into the new paths: * `$HOME/android-toolchain/jdk-1.8` * `$HOME/android-toolchain/jdk-11` We will continue *using* JDK 1.8 by default, until PR #4567 is ready to completely merge, at which point we'll use JDK 11 to build Xamarin.Android, while continuing to use JDK 1.8 with the Designer. Co-authored-by: Marek Habersack <grendel@twistedcode.net>
Context: #4567 The Android SDK `lint` utility is now in *two* Android SDK packages: the `tools` package, and the `cmdline-tools` package, e.g. as of commit d99facb, *both* of these exist on e.g. macOS: * `$HOME/android-toolchain/sdk/tools/bin/lint` * `$HOME/android-toolchain/sdk/cmdline-tools/1.0/bin/lint` There are two important differences of interest: 1. `tools/bin/lint` will not run on OpenJDK 11. 2. `cmdline-tools/1.0/bin/lint` has a *lower version* than `tools/bin/lint`. *Much* lower: % ~/android-toolchain/sdk/tools/bin/lint --version lint: version 26.1.1 % ~/android-toolchain/sdk/cmdline-tools/1.0/bin/lint --version lint: version 3.6.0 (1) means that we can't use the previous `lint` in an OpenJDK11 world, and thus we should migrate to the cmdline-tools `lint`. Support this by adding a new `$(AndroidCommandLineToolsVersion)` MSBuild property to `Xamarin.Android.Common.props.in` and `Microsoft.Android.Sdk.props`, which allows controlling which `cmdline-tools` package version to use, if more than one is present. The default value is `1.0`. (2) means that the `<Lint/>` Task is *broken* when using the cmdline-tools version of `lint`, becasuse certain `lint --disable` flags are protected by version checks, which are now all "wrong" when we "expect" >= 26.1.1 and instead get 3.6.0. Attempt to address (2) by assuming that we're using the cmdline-tools package if `ToolPath` contains `cmdline-tools`, in which case we treat `lint` as newer than any previous version. (This may be less than ideal.)
…11 (#4782) Context: #4567 Context: https://devdiv.visualstudio.com/DevDiv/_build/results?buildId=3729696&view=ms.vss-test-web.build-test-results-tab&runId=13228096&resultId=100066&paneView=attachments `<CreateMultiDexMainDexClassList/>` fails under JDK11: $ /Users/runner/Library/Android/jdk/bin/java \ -Djava.ext.dirs=/Users/runner/Library/Android/sdk/build-tools/29.0.2/lib \ com.android.multidex.MainDexListBuilder … -Djava.ext.dirs=/Users/runner/Library/Android/sdk/build-tools/29.0.2/lib is not supported. Use -classpath instead. CREATEMULTIDEXMAINDEXCLASSLIST : error : Could not create the Java Virtual Machine. CREATEMULTIDEXMAINDEXCLASSLIST : error : A fatal exception has occurred. Program will exit. The command exited with code 1. Under JDK11, `java` no longer supports `-Djava.ext.dirs`. Update `<CreateMultiDexMainDexClassList/>` so that it constructs a `java -classpath` value and uses that.
Export JavaSdkDirectory to a directory which exists!
JDK 11 is apparently slower than JDK 1.8. :-(
Squash-and-merge summary:
Body:
|
@@ -0,0 +1,18 @@ | |||
### Preliminary JDK 11 Support | |||
|
|||
Xamarin.Android can now use JDK 11 to build libraries and applications. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A question to try to answer briefly in this note is why users would be interested in this change. The answer to that might depend on whether Visual Studio will start installing the JetBrains Runtime OpenJDK 11 by default in the same release that contains this Xamarin.Android change.
Some possibilities:
-
If it's not yet known when Visual Studio will start installing OpenJDK 11 by default, then one idea is to include an HTML comment in this draft release note that says something like:
<!-- This release note might change depending on when Visual Studio starts installing OpenJDK 11 by default for the Mobile development with .NET workload. -->
-
If it is already known that Visual Studio will not install OpenJDK 11 by default alongside the first Xamarin.Android release that contains this change, then if possible, it could be good to add a sentence about when users might want to go to the trouble of finding and installing JDK 11 themselves.
I think the main known reason at this time is for compatibility with Android SDK Build-Tools 30-rc1 and higher, which leads to a question of when users would need to update to that version of Android SDK Build-Tools.
If the majority of users won't care about using Android SDK Build-Tools 30-rc1 or higher yet, the note could mention that, maybe using wording similar to JetBrains OpenJDK 11 #4567 (comment), and add something like:
Future versions of the Android SDK might require JDK 11 for more scenarios. Project authors can try switching to JDK 11 now to prepare early for those potential future requirements.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Visual Studio will start installing the JetBrains Runtime OpenJDK 11 by default in the same release that contains this Xamarin.Android change.
Almost certainly not, not for d16-7 P3 anyway, and I really doubt the likelihood of d16-7 period. For starters, it's only needed if Build-tools r30 is used, and --at present! -- it's not required to target API-R/Android 11.
(Even if it were required, I rather doubt the number of people who will be using Android 11 in the preview this is released in.)
More importantly, the Android Designer doesn't currently work with JDK 11. We can't change the default, even if we wanted to.
Additionally, I don't know what the rest of the VS "ecosystem" looks like, and whether it can be updated to JDK 11.
Finally, let's take a gander at API-29, shall we? That didn't become the default $(TargetFrameworkVersion)
until d16-6, ~9 months after a Xamarin.Android release containing a stable Android 10.0 binding.
I think there is no chance at all of migrating VS to JDK 11 "soon."*
*Definition of "soon" is deliberately undefined.''
If it's not yet known when Visual Studio will start installing OpenJDK 11 by default…
Will do, though I think it'll be "moot." One of the (random) ideas is that we'll delete the Documentation/release-notes
contents when a release note has gone stable. My guess is that XA d16-7 will be stable long before VS adds JDK 11, at which point this release note will likely not exist.
If it is already known that Visual Studio will not install OpenJDK 11 by default
99.99% certain of this.
it could be good to add a sentence about when users might want to go to the trouble of finding and installing JDK 11 themselves.
I'm not sure I can write this, not quickly. The only reason I know of to want/need JDK11 support is for Android SDK Build-tools r30+, but why would anybody want to use that, especially considering that it's still a "release candidate"? I don't know why this would be desirable.
I like the blurb you provided.
Documentation/release-notes/4567.md
Outdated
|
||
To do so: | ||
|
||
1. Install JDK 11 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If Visual Studio will not be installing OpenJDK 11 by default yet in the first release with this change, then I think it would be good to include a link to a suggested download location, such as perhaps https://confluence.jetbrains.com/display/JBR/JetBrains+Runtime.
Documentation/release-notes/4567.md
Outdated
2. Set the `$(JavaSdkDirectory)` MSBuild property to refer to the root | ||
of the JDK installation from (1). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can project authors configure the JDK via the Java Development Kit location setting in Visual Studio options (for example, on Windows: Tools > Options > Xamarin > Android Settings > Java Development Kit Location)? If so, I think it could be good to mention that approach first.
Then, if a different approach might work best on CI systems, such as Azure Pipelines, that could be included as a second option.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looks like these locations have documentation for how to set that value:
Documentation/release-notes/4567.md
Outdated
|
||
#### Known Issues | ||
|
||
When JDK 11 is used, the `@(JavaDocJar)` Build action is not supported, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It could be handy to create a GitHub issue for this known issue so that it will already have a tracking location, but it's OK to skip that for now too.
Documentation/release-notes/4567.md
Outdated
|
||
When JDK 11 is used, the `@(JavaDocJar)` Build action is not supported, | ||
and binding projects will not parse Javadoc to determine parameter names. | ||
This may a change in parameter names. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like there's a word or two missing here unintentionally, probably just due to rearrangements in editing. Maybe this can be something like:
This may result in different parameter names for existing bindings projects.
Authors of bindings projects affected by this change are recommended to continue
to use JDK 8 to build the bindings projects until this issue is resolved.
The additional candidate sentence also helps reinforce the point that this issue is primarily relevant to bindings projects authors and doesn't affect app project authors who are only consuming bindings provided by the Xamarin team.
Context: https://issuetracker.google.com/issues/150189789 Context: https://developer.android.com/preview/features#signature-scheme-v4 Context: https://developer.android.com/preview/features#incremental Preliminary JDK 11 support. The Android SDK Build-tools r30.0.0-rc4 package currently requires JDK 11 in order to use `apksigner.jar`: Task "AndroidApkSigner" Task Parameter:ApkSignerJar=C:\Users\dlab14\android-toolchain\sdk\build-tools\30.0.0-rc4\lib\apksigner.jar … Task Parameter:ToolPath=C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin Task Parameter:ManifestFile=obj\Release\android\AndroidManifest.xml C:\Program Files\Android\jdk\microsoft_dist_openjdk_1.8.0.25\bin\java.exe -jar C:\Users\dlab14\android-toolchain\sdk\build-tools\30.0.0-rc4\lib\apksigner.jar sign --ks "C:\Users\dlab14\AppData\Local\Xamarin\Mono for Android\debug.keystore" --ks-pass pass:android --ks-key-alias androiddebugkey --key-pass pass:android --min-sdk-version 21 --max-sdk-version 29 "C:\A\vs2019xam00000Y-1\_work\1\s\bin\TestRelease\temp\BuildAotApplication AndÜmläüts_x86_64_True_True\bin\Release\UnnamedProject.UnnamedProject-Signed.apk" java.lang.UnsupportedClassVersionError: com/android/apksigner/ApkSignerTool has been compiled by a more recent version of the Java Runtime (class file version 53.0), this version of the Java Runtime only recognizes class file versions up to 52.0 at java.lang.ClassLoader.defineClass1(Native Method) … …\Xamarin.Android.Common.targets(2559,2): error MSB6006: "java.exe" exited with code 1. This could be triggered by using the Android SDK Manager to install Build-tools r30.0.0-rc4, then overriding the `$(AndroidSdkBuildToolsVersion)` MSBuild property in `App.csproj`: <PropertyGroup> <AndroidSdkBuildToolsVersion>30.0.0-rc4</AndroidSdkBuildToolsVersion> </PropertyGroup> Many previous commits have added support for JDK 11, e.g. d99facb, dcee2c8, 4742d50, 89f3dc1, and 895b7bc (among many others). Additionally, c8ab455 updated the build environment so that *both* JetBrains OpenJDK 1.8 and 11 were installed, though 1.8 was still used. Now it's time to "flip the build environment," and use JDK 11 to build the product, installers, and run (most) unit tests: * Update `azure-pipelines.yaml` and `azure-pipelines-oss.yaml` so that JDK 11 is used to build everything. * Update `xaprepare` so that when `$(JavaSdkDirectory)` isn't overridden, JDK 11 is used by default. * Override the `JI_JAVA_HOME` environment variable when preparing `external/Java.Interop` so that it uses the desired JDK. * Update the default `$(LatestSupportedJavaVersion)` value to 11.0.4, the version of the JDK we install. * Update the `<ValidateJavaVersions/>` task so that JDK 11 is required when `$(AndroidSdkBuildToolsVersion)` is >= r30. This will cause an XA0032 error if JDK 1.8 is used to build a project when `$(AndroidSdkBuildToolsVersion)` is >= r30. * `apksigner` from Build-tools r30 creates a new `.idsig` file next to the `.apk`. This is to enable a new `adb install --incremental` feature. Add the `.idsig` file to `@(FileWrites)`. * Update various unit test `.csproj` files to consistently `<Import/>` the `Configuration.props` file and use properties within it for default values. This in particular allowed building e.g. `samples/HelloWorld` to implicitly use JDK 11. * Increase "expected" times in `tests/msbuild-times-reference/MSBuildDeviceIntegration.csv` as JDK 11 appears to be slower than JDK 1.8 (🙁). * *Disable* support for `@(JavaSourceJar)` when JDK 11 is used. JDK 11 changes the HTML generated by the `javadoc` command, and we need to update our HTML parser to handle it. In the interest of expediency, disable this for now. The Android Designer integration tests continue to use JDK 1.8, as the Designer doesn't currently build under JDK 11. TODO: * Fix `@(JavaSourceJar)` support: #4789 * Allow Android Designer to work with JDK 11, run Designer integration tests using JDK 11. * Figure out how to not accidentally bitrot JDK 1.8 support. Co-authored-by: Jonathan Pryor <jonpryor@vt.edu> Co-authored-by: Jonathan Peppers <jonathan.peppers@microsoft.com> Co-authored-by: Jonathan Pobst <jonathan.pobst@microsoft.com> Co-authored-by: Peter Collins <pecolli@microsoft.com>
Moved from: #4562
This PR is a test to see what works and what breaks with JetBrains
OpenJDK 11 as far as Xamarin.Android is concerned.