Minimum API level issue

I am now using the extension template to write an extension. But it needs external libraries to work. So I downloaded and placed those libraries into the respective directory. But when I try to compile my codes using ant, one library's method fails. After some investigation, that method seems require a minimum api level 23 to call it.

So, I would like to know what minimum api level is currently set in an AppInventor app? And could I change this minimum level so I can compile it successfully?

just set the min sdk in the definition of the extension...
example:

@DesignerComponent(version = 1,
    description = "your description",
    category = ComponentCategory.EXTENSION,
    nonVisible = true,
    androidMinSdk = 23,
    iconName = ...",
    helpUrl = "...")
@SimpleObject(external = true)

Taifun


Trying to push the limits! Snippets, Tutorials and Extensions from Pura Vida Apps by icon24 Taifun.

2 Likes

Thanks for the reply. Your answer seems solve the issue partially, but the compilation still fails. After further investigation, I think I've discovered a new problem.

The class that causes this problem is "NotificationCompat.Builder". I've found out actually there is an older version of it resides in the core.jar of App Inventor's internal library. I've downloaded a newer version that has the new method I would like to use. As the standard procedure, I use the @UsesLibraries annotation, but it seems my external library cannot override the internal library. So, does anyone know how to solve this?

I've got the similar issue some months ago while compiling my extension.

Temporarily remove older jar.

Thank you for the suggestion. I removed the jar of the old version, but now the compiler simply told me couldn't find the classes:

[javac] D:\VSCodes_Projects\notification1Test-extension\src\com\extensions\Notification.java:6: error: package androidx.core.graphics.drawable does not exist
[javac] import androidx.core.graphics.drawable.IconCompat;
[javac]                                       ^
[javac] D:\VSCodes_Projects\notification1Test-extension\src\com\extensions\Notification.java:26: error: package androidx.core.app does not exist
[javac] import androidx.core.app.NotificationCompat;
[javac]                         ^
[javac] D:\VSCodes_Projects\notification1Test-extension\src\com\extensions\Notification.java:27: error: package androidx.core.app does not exist
[javac] import androidx.core.app.NotificationManagerCompat;
[javac]                         ^
[javac] 3 errors

It seems not able to locate my new jar files. I am using the extension template from this place: https://github.com/mit-cml/extension-template . Are the procedures (such as the location of placing the external library files) not the same as building from the App Inventor source? For example, inside that template repository site, it tells me: " Any libraries you need should be placed under lib/deps/ ."

Did you remove jar from /appinventor or /deps folder?
Also, I think androidx libs are already available in Extension Template.

I removed the core.jar (this jar houses the androidx classes) and others inside the /lib/appinventor folder, and try to replace them with the my external libraries. But the compiler seems still can't find the external libraries, that's why those 3 errors occur.

By the way, is the following the correct way to add external libraries in the build.xml of the extension template?

  <target name="CopyComponentLibraries">
    <copy toFile="${public.deps.dir}/core.aar" file="${lib.dir}/androidx.core_core/core-1.6.0.aar" />
    <copy toFile="${public.deps.dir}/core.jar" file="${lib.dir}/androidx.core_core/core-1.6.0.jar" />
  </target>

where I placed my jar & aar files inside the /lib/androidx.core_core folder, as I assume the ${lib.dir} here points to the /lib folder.