Issue
Android Studio 4.2.2
Adding Build Feature Prefab for Prefab AAR Shared Library Android.mk/CMake Build:
https://developer.android.com/studio/build/native-dependencies?buildsystem=cmake&agpversion=4.1
Following Documentation perfectly for Android Studio 4.1+ and using Build Features
android {
buildToolsVersion '30.0.3'
ndkVersion '22.1.7171670'
buildFeatures {
prefab true
}
}
Problem:
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".
Error: Missing argument "PACKAGE_PATH".
Solution
When setting this:
buildFeatures {
prefab true
}
You must then Link to an existing prefab published module after setting that command else this error occurs
If you are not using prefabs at all Remove this line and it will compile
OR either can Link to an Active Prefab via the Android.mk or CMakeLists
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)
If you need to build your module library with type of Prefab set the gradle setting buildFeatures.prefabPublishing true and configure these extra commands
// 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")
}
Example:
https://github.com/android/ndk-samples/tree/main/prefab
More Documentation:
https://developer.android.com/studio/build/native-dependencies?buildsystem=ndk-build&agpversion=4.1
Answered By - Danoli3
Answer Checked By - David Marino (JavaFixing Volunteer)