AndroidX library out of date

I tried some methods available in AndroidX classes. Unfortunately, it seems that some newer classes are not available in the compiled AppInventor libraries. Is it possible to update AndroidX libraries to the latest?

Well, Indeed that's something not available in Ai2. The versions of all Androidx Libraries are almost initial or atleast 1-2 years old.

If I update the library in the sources where it builds extensions and I get missing methods, will such an extension work in companion and compiled APK? Should the library be up to date on the AppInventor server side?

Hi, This can be acheived by :slightly_smiling_face: -

  1. Updating android.jar from the One from Android Studio.
  2. Updating all dependencies (Appcompat, etc etc) to latest versions.
  3. Changing the target sdk version to latest (Api 33).
  4. Update the build tools like aapt, zipalign, aapt2 etc to use the latest Build Tools from Android.
  5. Update the Compiler to D8. (Obviously latest AndroidX libraries depend upon lambda features so you need a dexer that has the ability to dex lambda files)

Here's how it all can be acheived. Otherwise, MIT works on a (Don't touch until it works) moto so you don't get libraries updated often.

1 Like

You can compile the latest library in your extension and build your extension with rush optimization(proguard). This method works atleast for jar.

1 Like

Uhm. Will this work because it changes the package name of library and avoids both errors of DX and conflicting of libraries?

with proguard ??. i have used an runtime android x library but compiled apk doesnt have that latest version library inside apk. it replaced by old version of library. :slightly_smiling_face:

i have not used the proguard.

how can be done by proguard??

Yes, that's why it works.

Yes, because it changes the package and class names of the library compiled in your extension.

Add the proguard rules in your extension and compile the extension with proguard. You can find the proguard rules in AAR file. Sometimes, we need to add our custom rules to make complex library works such as firebase.

I pulled jar libraries from android studio. Core and appcompat and replaced in app inventor sources. Will it work? I'm getting an error in the app but I don't know if it's because of the wrong method usage or just the old libraries are still in the compiled app. Maybe the new androidx library should be added to the extension as an external jar to be added to the project.

So local update won't do anything? AppInventor should update the library?

@Patryk_F As far as I'm concerned, the update requires the update of almost all libraries.

The android x libraries are divided into modules. Appcompat, core, etc. I updated those that differed from the latest.

My question still stands, does a local update make sense? Because from what I can see, no androidx libraries are added to the when building the apk on the appinventor server, the old version of the android x library will be used anyway? Do I think right? It would only make sense to add the library in the "@UsesLibraries" annotation, which would add the library to the extension.

to prevent this.

use these rules in proguard :

-keep class androidx.example.files.** { *; }
-repackageclasses 'androidx/example/files/repack'

replace androidx.example.files with your library package name.

I check the library .class in dex file of apk it has the new version library class.

edit : You need to add the proguard rules of library also. In my case the library doesn't have any proguard rules inside.

1 Like

Oh didn't realize you were saying about extension :sweat_smile:, i though since your aix didn't work on ai2, you were planning to use on local ai2 instance.


Yes, it's about building extensions. I don't plan to create a local AI2 instance, I just want the extension to be compiled with the latest androidx libraries and used to build apps on Mit Ai2 servers.

Perhaps the method from @Shreyaa will be ok.


Kinda succeeded in updating of AndroidX libraries, I guess I can PR but it won't be accepted any soon due to some major changes :sweat_smile:

1 Like

Could you tell me how to add it in rush? For the guava library. is it possible to replace the entire library in this way?

This is my proguard file:

# Add any ProGuard configurations specific to this
# extension here.

-keep public class pl.patryk_f.Ai2ExoPlayer.Ai2ExoPlayer {
    public *;
-keeppackagenames gnu.kawa**, gnu.expr**

-optimizationpasses 4

-repackageclasses 'pl/patryk_f/Ai2ExoPlayer/repack'

Is there a particular library you're looking to have updated?

In fact, a lot of libraries are already too old to want to implement extensions with some latest sdk. Now I was working on ExoPlayer. Running x ExoPlayer from Media3 probably has no chance. Trying version 2.15.1. It works somehow, but in the compiled apk it shows an error of a certain class from the guava library. It is true that after adding this library to the extension, the apk starts, but the extension is already 6mb and does not load into the project. Earlier I had a problem with other classes from the androidx common and core library. I understand that the problem with updates is that newer libraries use java8 expressions that are not supported?

You can split the libs into dummy extensions.