Android AAR 中的 Studio 4.2.2 本机依赖项 buildFeatures.prefab=true - 缺少参数 "PACKAGE_PATH"
Android Studio 4.2.2 Native dependencies in AARs buildFeatures.prefab=true - Missing argument "PACKAGE_PATH"
Android Studio 4.2.2
为预制 AAR 共享库添加构建功能预制 Android。mk/CMake 构建:
https://developer.android.com/studio/build/native-dependencies?buildsystem=cmake&agpversion=4.1
完全遵循 Android Studio 4.1+ 的文档并使用构建功能
android {
buildToolsVersion '30.0.3'
ndkVersion '22.1.7171670'
buildFeatures {
prefab true
}
}
问题:
Error while executing java process with main class com.google.prefab.cli.AppKt with arguments {--build-system ndk-build --platform android --abi armeabi-v7a --os-version 21 --stl c++_static --ndk-version 22 --output /Users/~var/Documents/project/.cxx/ndkBuild/debug/prefab/armeabi-v7a/prefab}
Usage: prefab [OPTIONS] [PACKAGE_PATH]...
Error: Missing argument "PACKAGE_PATH".
错误:缺少参数“PACKAGE_PATH”。
设置时:
buildFeatures {
prefab true
}
然后您必须 Link 在设置该命令后到现有的预制发布模块,否则会发生此错误
如果你根本不使用预制件删除这一行,它会编译
或者可以通过 Android.mk 或 CMakeLists
Link 到活动预制件
Android.mk
include $(CLEAR_VARS)
$(call import-add-path, $(LOCAL_PATH)/modulePath)
$(call import-add-path, /../../anotherModulePath)
# If you don't need your project to build with NDKs older than r21, you can omit
# this block.
ifneq ($(call ndk-major-at-least,21),true)
$(call import-add-path,$(NDK_GRADLE_INJECTED_IMPORT_PATH))
Endif
# the linked prefab published module project location
$(call import-module, openFrameworksAndroid)
如果您需要使用 Prefab 类型构建模块库,请设置 gradle 设置 buildFeatures.prefabPublishing true 并配置这些额外的命令
// Enable generation of Prefab packages and include them in the library's AAR.
buildFeatures {
prefabPublishing true
}
// Include the "mylibrary" module from the native build system in the AAR,
// and export the headers in src/main/cpp/include to its consumers
prefab {
openFrameworksAndroid {
//headers "src/main/cpp/include"
}
}
// Avoid packing the unnecessary libraries into final AAR. For details
// refer to https://issuetracker.google.com/issues/168777344#comment5
// Note that if your AAR also contains Java/Kotlin APIs, you should not
// exclude libraries that are used by those APIs.
packagingOptions {
exclude("**/libopenFrameworksAndroid.so")
exclude("**/classes.jar")
}
示例:
https://github.com/android/ndk-samples/tree/main/prefab
更多文档:
https://developer.android.com/studio/build/native-dependencies?buildsystem=ndk-build&agpversion=4.1
Android Studio 4.2.2
为预制 AAR 共享库添加构建功能预制 Android。mk/CMake 构建:
https://developer.android.com/studio/build/native-dependencies?buildsystem=cmake&agpversion=4.1
完全遵循 Android Studio 4.1+ 的文档并使用构建功能
android {
buildToolsVersion '30.0.3'
ndkVersion '22.1.7171670'
buildFeatures {
prefab true
}
}
问题:
Error while executing java process with main class com.google.prefab.cli.AppKt with arguments {--build-system ndk-build --platform android --abi armeabi-v7a --os-version 21 --stl c++_static --ndk-version 22 --output /Users/~var/Documents/project/.cxx/ndkBuild/debug/prefab/armeabi-v7a/prefab}
Usage: prefab [OPTIONS] [PACKAGE_PATH]...
Error: Missing argument "PACKAGE_PATH".
错误:缺少参数“PACKAGE_PATH”。
设置时:
buildFeatures {
prefab true
}
然后您必须 Link 在设置该命令后到现有的预制发布模块,否则会发生此错误
如果你根本不使用预制件删除这一行,它会编译
或者可以通过 Android.mk 或 CMakeLists
Link 到活动预制件Android.mk
include $(CLEAR_VARS)
$(call import-add-path, $(LOCAL_PATH)/modulePath)
$(call import-add-path, /../../anotherModulePath)
# If you don't need your project to build with NDKs older than r21, you can omit
# this block.
ifneq ($(call ndk-major-at-least,21),true)
$(call import-add-path,$(NDK_GRADLE_INJECTED_IMPORT_PATH))
Endif
# the linked prefab published module project location
$(call import-module, openFrameworksAndroid)
如果您需要使用 Prefab 类型构建模块库,请设置 gradle 设置 buildFeatures.prefabPublishing true 并配置这些额外的命令
// Enable generation of Prefab packages and include them in the library's AAR.
buildFeatures {
prefabPublishing true
}
// Include the "mylibrary" module from the native build system in the AAR,
// and export the headers in src/main/cpp/include to its consumers
prefab {
openFrameworksAndroid {
//headers "src/main/cpp/include"
}
}
// Avoid packing the unnecessary libraries into final AAR. For details
// refer to https://issuetracker.google.com/issues/168777344#comment5
// Note that if your AAR also contains Java/Kotlin APIs, you should not
// exclude libraries that are used by those APIs.
packagingOptions {
exclude("**/libopenFrameworksAndroid.so")
exclude("**/classes.jar")
}
示例:
https://github.com/android/ndk-samples/tree/main/prefab
更多文档:
https://developer.android.com/studio/build/native-dependencies?buildsystem=ndk-build&agpversion=4.1