简体   繁体   中英

Have a question about importing 3rd party android aar library into Delphi 10.x project

I have third party library aar. When I unzip the aar file I find the following files and directories:

directory /aidl: nothing

directory /assets: nothing

directory /jni/armeabi-v7a: there are eight.so files.

directory /libs: There are five.jar files.

directory /res: nothing

directory /: there is the AndroidManifest.xml file and classes.jar

Is importing.jar files sufficient or do I also need to import.so files?

Regard.

Ranja

RAD Studio Requirements for Java Libraries

RAD Studio only supports the Android API level 10 (Android 2.3.3) and later. If your Java libraries use the Android API, they must be compiled using a supported Android API.

If your Java library depends on other Java libraries, you must have the JAR files of both your Java library and the libraries that your library depends on. You need the JAR files of all those Java libraries to generate a valid classes.dex file later.

See in the table under Generating a classes.dex File which JAR file belongs to each library.

Source: https://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_a_Custom_Set_of_Java_Libraries_In_Your_RAD_Studio_Android_Apps

I have just made the AndroidMerger Tool: Integrate AAR SDK in FMX Android app

An Android library, also called as Android Archive, includes everything you need to build an app like source files, resource files, manifest etc. This is the reason why AARs are different from JARs. AARs can contain resource files as well other than compiled byte code.

Adding such library to Delphi project is long and convoluted process consisting of extracting resources from library, manually adding them to Delphi deployment files, compiling R.Java class, checking dependancies, etc.

With AndroidMerger all of the above can now be done automatically in a single command line. In brief AndroidMerger will:

  • Use graddle or internal implementation to list all dependencies.
  • Download libraries and dependancies from local or central maven
  • repository. Merge the resources of all AARs inside a single
  • directory. Merge the AndroidManifest files of all AARs inside
  • AndroidManifest.template.xml. Merge google-services.json in the
  • resources of the project. Create the R.jar with all resource IDs
  • using aapt or aapt2. Update the project file (.dproj) to include all
  • resources. Generate the Delphi native bridge file from the Java libraries.

Everything is here (source code included): https://github.com/MagicFoundation/Alcinoe/tree/master/Tools/AndroidMerger

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM