英文:
AAR in AOSP Project
问题
我一直在尝试将一个aar文件添加到使用AOSP开发的应用程序中,使用我的Android.mk
文件中的以下部分:
...
LOCAL_STATIC_JAVA_AAR_LIBRARIES := \
aar-lib
LOCAL_AAPT_FLAGS := --auto-add-overlay \
--extra-packages com.mypackage.name
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
aar-libr:libs/aarname.aar
...
许多中间文件被创建在out/target/common/obj/JAVA_LIBRARIES
和out/target/common/R
文件夹中。然而,我似乎无法真正导入aar中的包。例如,aar本身包含一个带有classes.jar
存档的libs
文件夹。但导入包含的类的导入语句在构建时引发错误。
我正在使用目标SDK版本28进行工作。是否有方法解决这些依赖关系问题?
英文:
I have been trying to add an aar file to my application developed with the AOSP using the following section of my Android.mk
:
...
LOCAL_STATIC_JAVA_AAR_LIBRARIES := \
aar-lib
LOCAL_AAPT_FLAGS := --auto-add-overlay \
--extra-packages com.mypackage.name
include $(BUILD_PACKAGE)
include $(CLEAR_VARS)
LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
aar-libr:libs/aarname.aar
...
A bunch of immediates are created in the out/target/common/obj/JAVA_LIBRARIES
and in the out/target/common/R
folder. However, I do not seem to be able to actually import the packages contained in the aar. For example, the aar itself contains a libs
folder with a classes.jar
archive. But the import statements for contained classes cause errors when building.
I am working with the target sdk version 28.
Is there a way to resolve these dependency issues?
答案1
得分: 1
如果您倾向于在您的应用中使用 Android.bp,可以尝试以下方法来定义库:
android_library_import {
name: "your-lib-name",
aars: ["your-lib-file-name.aar"],
sdk_version: "current",
min_sdk_version: "28", // 可选
}
然后在您的 android_app
的 static_libs
中添加上述定义的名称。
英文:
If you tend to use Android.bp for your app, try this approach for defining the library:
android_library_import {
name: "your-lib-name",
aars: ["your-lib-file-name.aar"],
sdk_version: "current",
min_sdk_version: "28", // optional
}
and add the name defined above in your android_app
's static_libs
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论