Android Tutorial GUI SDK Manager for newer versions of Android tools

Status
Not open for further replies.
Edit: If you are using B4A v7.8+ then a newer version of B4A Sdk Manager is preinstalled. Follow these instructions instead: https://www.b4x.com/b4a.html#installation

The GUI interface of Android SDK Manager has been removed in the latest version of Android SDK.
It was replaced with a command line tool named sdkmanager.bat.

Most developers, including new B4A developers, still use a version which does include the GUI interface, as the B4A download page points to an older version.
You can continue to use the currently installed Android tools.

A custom tool named B4A SDK Manager is provided as an alternative for developers who like to upgrade:

SS-2017-06-06_12.53.22.png


Installation instructions:

1. Download the latest sdk tools: https://developer.android.com/studio/index.html#command-tools
2. Create a folder for Android SDK. Don't put it under Program Files as it is a restricted folder. C:\android-sdk is a good option.
3. Unzip the sdk tools and copy the tools library to android sdk folder. It should look similar to:

SS-2017-05-29_15.44.54.png


4. Download B4ASdkManager.jar and double click on it. It requires Java 8u40+ to be installed.
5. Click on the open folder button and select sdkmanager.bat. It will be under <sdk path>\tools\bin
6. Install all recommended items. It can take a few minutes or more.
Licenses agreements will be printed. Read them and approve.
7. Don't forget to update B4A IDE to use the new SDK (Tools - Configure Paths - android.jar).

Next tutorial: AVD Manager / Emulator

The B4J source code is attached. It depends on jShell v1.5+.

Android SDK currently doesn't support Java 9. Make sure that B4A is configured to use Java 8 (Tools - Configure Paths).
 

Attachments

  • B4A-SdkManager-Source.zip
    63.3 KB · Views: 5,297
Last edited:

Cebuvi

Active Member
Licensed User
Longtime User
This is what gives me



StdOut_StdErr.jpg





Problem solved.
I have configured JAVA_HOME and everything works.
Thank you very much.
 
Last edited:

jimmyF

Active Member
Licensed User
Longtime User
I get this error when I click on AVD Manager:

B4X:
Error occurred on line: 122 (AVDManager)
java.lang.ArrayIndexOutOfBoundsException: 8
    at b4j.example.avdmanager._parseitem(avdmanager.java:1620)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
etc.

This is line 122 mentioned above:
I am not familiar enough with RegEx protocols to spot the actual error in that line of code.
B4X:
Dim m As Matcher = Regex.Matcher("\s+([^:]+):(.*)", Lines(i))

Anybody else run into this problem? Or anyone know the solution?
Thanks
 

Erel

B4X founder
Staff member
Licensed User
Longtime User
Please replace the ParseItem code with this sub:
B4X:
Sub ParseItem(Index() As Int, Lines() As String) As AVD 'ignore
   Dim AV As AVD
   AV.Initialize
   Dim i As Int = Index(0)
   Do While i < Lines.Length
     Log(Lines(i))
     Dim m As Matcher = Regex.Matcher("\s+([^:]+):(.*)", Lines(i))
     If m.Find Then
       Dim field As String = m.Group(1).Trim
       Dim value As String = m.Group(2).Trim
       If field = "Name" Then
         AV.Name = value
       Else If field = "Target" Then
         If value.Length = 0 Then
           value = Lines(i + 1).Trim
         End If
         AV.Target = value
       End If
     Else
       Exit
     End If
     i = i + 1
   Loop
   Index(0) = i - 1
   Return AV
End Sub
Does it work? If not please post the output logs.
 

jimmyF

Active Member
Licensed User
Longtime User
That works just fine. :)
Thank you!
 

jimmyF

Active Member
Licensed User
Longtime User
Yes, I see a list of a grand total of one.
I have installed other platforms and x86 images but I only display one in the list.
Platform 24
Nexus_6P_API_25_b4A

Log:
Name: Nexus_6P_API_25_B4A
Device: Nexus 6P (Google)
Path: C:\Users\James.SEF2\.android\avd\Nexus_6P_API_25_B4A.avd
Target: Google APIs
Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis/x86
Skin: nexus_6p
Sdcard: 100M

My SDK is here:
E:\Android\sdk\
 

jimmyF

Active Member
Licensed User
Longtime User
My only choice of Platform is Platform 24.
I have 25 and 26 installed.
Okay, I can create a new one:
Based on: Android 7.1.1 (Nougat) Tag/ABI: google_apis/x86
Skin: nexus_6p
 

jimmyF

Active Member
Licensed User
Longtime User
This is what I have installed:

DataFolder: C:\Users\James.SEF2\AppData\Roaming\B4ASdkManager
add-ons;addon-google_apis-google-19
build-tools;25.0.2
build-tools;25.0.3
build-tools;26.0.0
cmake;3.6.3155560
docs
emulator
extras;android;gapid;3
extras;android;m2repository
extras;google;auto
extras;google;google_play_services
extras;google;instantapps
extras;google;m2repository
extras;google;market_apk_expansion
extras;google;market_licensing
extras;google;play_billing
extras;google;simulators
extras;google;usb_driver
extras;google;webdriver
extras;intel;Hardware_Accelerated_Execution_Manager
extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.1
extras;m2repository;com;android;support;constraint;constraint-layout-solver;1.0.2
extras;m2repository;com;android;support;constraint;constraint-layout;1.0.2
patcher;v1
patcher;v4
platform-tools
platforms;android-24
platforms;android-25
platforms;android-26
sources;android-24
sources;android-25
system-images;android-17;default;x86
system-images;android-17;google_apis;x86
system-images;android-18;google_apis;x86
system-images;android-21;default;x86
system-images;android-21;default;x86_64
system-images;android-21;google_apis;x86
system-images;android-21;google_apis;x86_64
system-images;android-24;default;x86
system-images;android-24;default;x86_64
system-images;android-24;google_apis;x86
system-images;android-24;google_apis;x86_64
system-images;android-24;google_apis_playstore;x86
system-images;android-25;android-tv;x86
system-images;android-25;android-wear;armeabi-v7a
system-images;android-25;android-wear;x86
system-images;android-25;google_apis;x86
system-images;android-25;google_apis;x86_64
system-images;android-26;google_apis;x86
system-images;android-26;google_apis_playstore;x86
tools
 

iz0ndg

Active Member
Licensed User
Longtime User
Hi, i have this error to install selected :
B4X:
Warning: An error occurred while preparing SDK package Android Support Repository: C:\Windows\PackageOperation01\android_m2repository_r47.zip.
java.nio.file.NoSuchFileException: C:\Windows\PackageOperation01\android_m2repository_r47.zip
   at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
   at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
   at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
   at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(Unknown Source)
   at java.nio.file.spi.FileSystemProvider.newOutputStream(Unknown Source)
   at java.nio.file.Files.newOutputStream(Unknown Source)
   at com.android.repository.io.impl.FileSystemFileOp.newFileOutputStream(FileSystemFileOp.java:247)
   at com.android.repository.io.impl.FileSystemFileOp.newFileOutputStream(FileSystemFileOp.java:235)
   at com.android.sdklib.repository.legacy.LegacyDownloader.downloadFully(LegacyDownloader.java:82)
   at com.android.repository.impl.installer.BasicInstaller.doPrepare(BasicInstaller.java:71)
   at com.android.repository.impl.installer.AbstractPackageOperation.prepare(AbstractPackageOperation.java:243)
   at com.android.sdklib.tool.SdkManagerCli.applyPackageOperation(SdkManagerCli.java:523)
   at com.android.sdklib.tool.SdkManagerCli.installPackages(SdkManagerCli.java:357)
   at com.android.sdklib.tool.SdkManagerCli.run(SdkManagerCli.java:147)
   at com.android.sdklib.tool.SdkManagerCli.main(SdkManagerCli.java:119)
   at com.android.sdklib.tool.SdkManagerCli.main(SdkManagerCli.java:93)
sdkmanager.bat : C:\android-sdk\tools\bin\sdkmanager.bat

on Win7 32bit java 8u131
 

Jaames

Active Member
Licensed User
Longtime User
Hi, i have this error to install selected :
B4X:
Warning: An error occurred while preparing SDK package Android Support Repository: C:\Windows\PackageOperation01\android_m2repository_r47.zip.
java.nio.file.NoSuchFileException: C:\Windows\PackageOperation01\android_m2repository_r47.zip
   at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
   at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
   at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
   at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(Unknown Source)
   at java.nio.file.spi.FileSystemProvider.newOutputStream(Unknown Source)
   at java.nio.file.Files.newOutputStream(Unknown Source)
   at com.android.repository.io.impl.FileSystemFileOp.newFileOutputStream(FileSystemFileOp.java:247)
   at com.android.repository.io.impl.FileSystemFileOp.newFileOutputStream(FileSystemFileOp.java:235)
   at com.android.sdklib.repository.legacy.LegacyDownloader.downloadFully(LegacyDownloader.java:82)
   at com.android.repository.impl.installer.BasicInstaller.doPrepare(BasicInstaller.java:71)
   at com.android.repository.impl.installer.AbstractPackageOperation.prepare(AbstractPackageOperation.java:243)
   at com.android.sdklib.tool.SdkManagerCli.applyPackageOperation(SdkManagerCli.java:523)
   at com.android.sdklib.tool.SdkManagerCli.installPackages(SdkManagerCli.java:357)
   at com.android.sdklib.tool.SdkManagerCli.run(SdkManagerCli.java:147)
   at com.android.sdklib.tool.SdkManagerCli.main(SdkManagerCli.java:119)
   at com.android.sdklib.tool.SdkManagerCli.main(SdkManagerCli.java:93)
sdkmanager.bat : C:\android-sdk\tools\bin\sdkmanager.bat

on Win7 32bit java 8u131
Almost the same here, Windows 10 64, java 8u131
I deleted old sdk and Android Studio, witch was about 35Gb , and downloaded sdk tools from the OP link

B4X:
Info: Parsing E:\Android\sdk\tools\package.xml
Info: Parsing E:\Android\sdk\tools\package.xml
Info: Preparing "Install Android Support Repository (revision: 47.0.0)".
Info: "Install Android Support Repository (revision: 47.0.0)" failed.

Warning: File C:\Users\james\.android\repositories.cfg could not be loaded.
Warning: An error occurred while preparing SDK package Android Support Repository: C:\WINDOWS\PackageOperation01\android_m2repository_r47.zip.
java.nio.file.NoSuchFileException: C:\WINDOWS\PackageOperation01\android_m2repository_r47.zip
    at sun.nio.fs.WindowsException.translateToIOException(Unknown Source)
    at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
    at sun.nio.fs.WindowsException.rethrowAsIOException(Unknown Source)
    at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(Unknown Source)
    at java.nio.file.spi.FileSystemProvider.newOutputStream(Unknown Source)
    at java.nio.file.Files.newOutputStream(Unknown Source)
    at com.android.repository.io.impl.FileSystemFileOp.newFileOutputStream(FileSystemFileOp.java:247)
    at com.android.repository.io.impl.FileSystemFileOp.newFileOutputStream(FileSystemFileOp.java:235)
    at com.android.sdklib.repository.legacy.LegacyDownloader.downloadFully(LegacyDownloader.java:82)
    at com.android.repository.impl.installer.BasicInstaller.doPrepare(BasicInstaller.java:71)
    at com.android.repository.impl.installer.AbstractPackageOperation.prepare(AbstractPackageOperation.java:243)
    at com.android.sdklib.tool.SdkManagerCli.applyPackageOperation(SdkManagerCli.java:523)
    at com.android.sdklib.tool.SdkManagerCli.installPackages(SdkManagerCli.java:357)
    at com.android.sdklib.tool.SdkManagerCli.run(SdkManagerCli.java:147)
    at com.android.sdklib.tool.SdkManagerCli.main(SdkManagerCli.java:119)
    at com.android.sdklib.tool.SdkManagerCli.main(SdkManagerCli.java:93)
 

iz0ndg

Active Member
Licensed User
Longtime User
All log after 'Install Selected':
B4X:
DataFolder: C:\Users\fabio\AppData\Roaming\B4ASdkManager
C:\Users\fabio\AppData\Local\Temp\
tools
tools

In Panel :

B4X:
Info: Parsing C:\android-sdk\tools\package.xml
Info: Parsing C:\android-sdk\tools\package.xml

Warning: An error occurred while preparing SDK package Android Support Repository: C:\Windows\PackageOperation01\android_m2repository_r47.zip.
java.nio.file.NoSuchFileException: C:\Windows\PackageOperation01\android_m2repository_r47.zip
   at sun.nio.fs.WindowsException.translateToIOException(WindowsException.java:79)
   at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:97)
   at sun.nio.fs.WindowsException.rethrowAsIOException(WindowsException.java:102)
   at sun.nio.fs.WindowsFileSystemProvider.newByteChannel(WindowsFileSystemProvider.java:230)
   at java.nio.file.spi.FileSystemProvider.newOutputStream(FileSystemProvider.java:434)
   at java.nio.file.Files.newOutputStream(Files.java:216)
   at com.android.repository.io.impl.FileSystemFileOp.newFileOutputStream(FileSystemFileOp.java:247)
   at com.android.repository.io.impl.FileSystemFileOp.newFileOutputStream(FileSystemFileOp.java:235)
   at com.android.sdklib.repository.legacy.LegacyDownloader.downloadFully(LegacyDownloader.java:82)
   at com.android.repository.impl.installer.BasicInstaller.doPrepare(BasicInstaller.java:71)
   at com.android.repository.impl.installer.AbstractPackageOperation.prepare(AbstractPackageOperation.java:243)
   at com.android.sdklib.tool.SdkManagerCli.applyPackageOperation(SdkManagerCli.java:523)
   at com.android.sdklib.tool.SdkManagerCli.installPackages(SdkManagerCli.java:357)
   at com.android.sdklib.tool.SdkManagerCli.run(SdkManagerCli.java:147)
   at com.android.sdklib.tool.SdkManagerCli.main(SdkManagerCli.java:119)
   at com.android.sdklib.tool.SdkManagerCli.main(SdkManagerCli.java:93)
 
Last edited:

A Z M JANNAT UL KARIM

Member
Licensed User
Hi, using windows 10 here, right click on Start Menu gives you another pop up menu from where you can select Windows PowerShell(Admin). UAC Popup dialog will appear, select Yes. Now suppose you downloaded the Jar file to D: Drive. Write in the PowerShell cd d: and press enter. Now write there B4ASdkManager.jar and hit enter. It will run the JAR file and you can install from there. Hope this will solve your issue.
 
Status
Not open for further replies.
Top