Extras icon indicating copy to clipboard operation
Extras copied to clipboard

android-sdk: post_install errors

Open redactedscribe opened this issue 3 years ago • 2 comments

Bug Report

Package Name: android-sdk

Current Behaviour

Current manifest post_install:

    "post_install": [
        "if (Test-Path \"$(appdir adb $global)\") {",
        "    cmd /c mklink /j \"$dir\\platform-tools\" \"$(appdir adb $global)\\current\\platform-tools\" | out-null",
        "    attrib \"$(appdir adb $global)\\current\\platform-tools\" +R /L",
        "}",
        "&\"$dir\\tools\\bin\\sdkmanager.bat\" '--install' '\"cmdline-tools;latest\"'"
    ],

The errors on install that I'm getting:

<...>
Running post_install script...

The system cannot find the path specified.
The system cannot find the path specified.
Exception in thread "main" java.lang.NoClassDefFoundError: javax/xml/bind/annotation/XmlSchema
        at com.android.repository.api.SchemaModule$SchemaModuleVersion.<init>(SchemaModule.java:156)
        at com.android.repository.api.SchemaModule.<init>(SchemaModule.java:75)
        at com.android.sdklib.repository.AndroidSdkHandler.<clinit>(AndroidSdkHandler.java:81)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:73)
        at com.android.sdklib.tool.sdkmanager.SdkManagerCli.main(SdkManagerCli.java:48)
Caused by: java.lang.ClassNotFoundException: javax.xml.bind.annotation.XmlSchema
        at java.base/jdk.internal.loader.BuiltinClassLoader.loadClass(BuiltinClassLoader.java:641)
        at java.base/jdk.internal.loader.ClassLoaders$AppClassLoader.loadClass(ClassLoaders.java:188)
        at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521)
        ... 5 more

Trying to run sdkmanager.bat also outputs the above error, so maybe that's directly related?

Expected Behaviour

No errors on install.

System details

Windows version: 11 OS architecture: 64bit

PowerShell version: 7.2.6

Scoop Configuration

{
  "lastupdate": "2022-08-22T23:27:09.7381354+03:00",
  "SCOOP_REPO": "https://github.com/ScoopInstaller/Scoop",
  "SCOOP_BRANCH": "master",
  "aria2-enabled": true,
  "rmsshim": "kiennq",
  "shim": "kiennq",
  "aria2": false
}

redactedscribe avatar Aug 22 '22 23:08 redactedscribe

I ran into this while configuring my environment for building Ionic Cordova apps to target API level 32, where the NPM package cordova-android@11 now requires at least Java 11, but I have now managed to get it sorted..

here is a copy/paste of the SO answer that helped me work it out:

The sdkmanager that comes with the deprecated SDK Tools package doesn't support JDK 8 and is no longer receiving updates since september 2017. More information here and here.

The sdkmanager included in the new Command-Line Tools package supports JDK 11 and it can be downloaded from the Android Studio download page, in the Command line tools only section. There's no need to download any other files or to hack with the sdkmanager script, however you will need to update your PATH setting, e.g. on Linux: $ANDROID_HOME/cmdline-tools/latest/bin instead of $ANDROID_HOME/tools/bin

Although deprecated, the old Tools package is still being installed with Android Studio 4.1.1 by default. This post explains why.


just one note here: it seems that Scoop added the same extra paths to the PATH environment variable for both "system" and "user"... this seems very wrong, especially since they reference things installed to my %USERPROFILE% folder. keep that in mind when updating this.

that's a separate issue though, so I'll dig into that more over the weekend.

hope that helps. 🖖🏼

edit: also keep in mind, the new sdkmanager.bat tool does run with Java 8, so that helps.. but it does not run with Java 7.

ZaLiTHkA avatar Aug 26 '22 09:08 ZaLiTHkA

My solution was to install android-clt instead (the Android command-line tools), then use the sdkmanager.bat installed by it to install everything that android-sdk would've given me. After installing android-clt, use sdkmanager.bat --sdk_root=$env:ANDROID_SDK_ROOT --list and download what you need. I've also added %ANDROID_SDK_ROOT%\cmdline-tools\bin and %ANDROID_SDK_ROOT%\platform-tools to PATH.

Also, I think the lines The system cannot find the path specified. are unrelated to this issue and were instead produced by a cmd.exe autorun misconfiguration caused by Clink (reinstall it and do clink autorun install to resolve that).

redactedscribe avatar Sep 01 '22 22:09 redactedscribe

It is possible to just install oraclejre8 to make it working. With any openjdk (openjre) it could not work.

alealexpro100 avatar Mar 09 '23 01:03 alealexpro100

See #11171

HUMORCE avatar Mar 12 '24 02:03 HUMORCE