简体   繁体   English

对将第 3 方 android aar 库导入 Delphi 10.x 项目有疑问

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

I have third party library aar.我有第三方库aar。 When I unzip the aar file I find the following files and directories:当我解压缩 aar 文件时,我发现以下文件和目录:

directory /aidl: nothing目录/aidl:无

directory /assets: nothing目录/资产:没有

directory /jni/armeabi-v7a: there are eight.so files.目录/jni/armeabi-v7a:有八个.so文件。

directory /libs: There are five.jar files.目录/libs:有五个.jar个文件。

directory /res: nothing目录/res: 无

directory /: there is the AndroidManifest.xml file and classes.jar目录/:有AndroidManifest.xml文件和classes.jar

Is importing.jar files sufficient or do I also need to import.so files? importing.jar 文件是否足够,还是我还需要 import.so 文件?

Regard.看待。

Ranja兰贾

RAD Studio Requirements for Java Libraries Java 库的 RAD Studio 要求

RAD Studio only supports the Android API level 10 (Android 2.3.3) and later. RAD Studio 仅支持 Android API 级别 10 (Android 2.3.3) 及更高版本。 If your Java libraries use the Android API, they must be compiled using a supported Android API. 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. 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.您需要所有这些 Java 库的 JAR 文件,以便稍后生成有效的 classes.dex文件。

See in the table under Generating a classes.dex File which JAR file belongs to each library.请参阅生成 classes.dex 文件下的表格,其中 JAR 文件属于每个库。

Source: https://docwiki.embarcadero.com/RADStudio/Sydney/en/Using_a_Custom_Set_of_Java_Libraries_In_Your_RAD_Studio_Android_Apps资料来源: 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我刚刚制作了 AndroidMerger 工具: 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. Android 库,也称为 Android 存档,包括构建应用程序所需的一切,如源文件、资源文件、清单等。这就是 AAR 不同于 JARs 的原因。AAR 可以包含资源文件以及编译字节以外的资源文件代码。

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.将此类库添加到 Delphi 项目是一个漫长而复杂的过程,包括从库中提取资源、手动将它们添加到 Delphi 部署文件、编译 R.Java class、检查依赖项等。

With AndroidMerger all of the above can now be done automatically in a single command line.使用 AndroidMerger,以上所有内容现在都可以在单个命令行中自动完成。 In brief AndroidMerger will:简而言之,AndroidMerger 将:

  • Use graddle or internal implementation to list all dependencies.使用 graddle 或内部实现来列出所有依赖项。
  • Download libraries and dependancies from local or central maven从本地或中心下载库和依赖项 maven
  • repository.存储库。 Merge the resources of all AARs inside a single将所有 AAR 的资源合并到一个
  • directory.目录。 Merge the AndroidManifest files of all AARs inside合并里面所有AAR的AndroidManifest文件
  • AndroidManifest.template.xml. AndroidManifest.template.xml。 Merge google-services.json in the合并 google-services.json 在
  • resources of the project.项目的资源。 Create the R.jar with all resource IDs使用所有资源 ID 创建 R.jar
  • using aapt or aapt2.使用 aapt 或 aapt2。 Update the project file (.dproj) to include all更新项目文件 (.dproj) 以包括所有
  • resources.资源。 Generate the Delphi native bridge file from the Java libraries.从 Java 库生成 Delphi 本机桥接文件。

Everything is here (source code included): https://github.com/MagicFoundation/Alcinoe/tree/master/Tools/AndroidMerger一切都在这里(包括源代码): https://github.com/MagicFoundation/Alcinoe/tree/master/Tools/AndroidMerger

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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