Android Tutorial AndroidX SDK

Status
Not open for further replies.
Android Support Library was implemented and maintained in the last 8 years by Google. It includes a wide range of features and it hides many of the differences between the various Android versions.

Android Support Library was replaced by AndroidX SDK. It is no longer maintained and new versions of Firebase SDK depend on AndroidX. This is a good time to switch to AndroidX.

It is simple to switch to AndroidX as the IDE takes care of most of the things:

- Libraries references (DependsOn / #AdditionalJar) are updated automatically.
- The compiler automatically chooses the androidx libraries if such are available.
- References to support classes in #Extends declarations, JavaObject calls and to a less extent in the manifest editor code are converted during compilation.

Most of the libraries will work as-is, however libraries that directly call methods from the support library need to be "jetified". This is done with the Jetifier tool (Tools - Jetifier). It will go over all the additional libraries and will jetify all the libraries that need to be jetified. The output of this tool is libraries with .androidx.jar (or .androidx.aar) extension.
The B4A compiler will then use those libraries automatically.

Note that the internal libraries already include the jetified versions.

To conclude:

1. Open Tools - B4A Sdk manager.
2. Install all recommended items. This will make the switch to AndroidX. You can always go back to the previous SDK.
3. Open Tools - Jetifier.
4. Click on Jetify. It is possible that the jetifier will fail to jetify a few libraries. In most cases you can ignore it as those libraries don't need to be jetified.
5. Clean the project (Ctrl + P)
6. Run your project. The compilation dialog will tell you which SDK was used:

B4A Version: 9.30 BETA #2
Java Version: 11
Parsing code. (0.00s)
Building folders structure. (0.01s)
Compiling code. (0.02s)
Compiling layouts code. (0.01s)
Organizing libraries. (0.00s)
(AndroidX SDK)
Generating R file. (0.96s)
Compiling debugger engine code. (0.73s)
Compiling generated Java code. (1.36s)
Convert byte code - optimized dex. (1.06s)
Packaging files. (0.83s)
Copying libraries resources (0.01s)
Signing package file (private key). (0.61s)
ZipAlign file. (0.04s)
Installing file to device. (0.03s)
Installing with B4A-Bridge.
Completed successfully.
 
Last edited:

dcoun

Member
Licensed User
Longtime User
What is the "jetifier.map" that can not be written in "c:\program files\..." if you do not run b4a as administrator?
 

stanks

Active Member
Licensed User
Longtime User
i have no jetifier.map in any folder on disk and nothing is happening when i run Jetifier Android (Android X) from Tools menu and b4xdrawer is still crushing when i run it and my additional libraries is in root c:\...
 
Status
Not open for further replies.
Top