簡體   English   中英

Android Studio 4.2.2 AAR 中的本機依賴項 buildFeatures.prefab=true - 缺少參數“PACKAGE_PATH”

[英]Android Studio 4.2.2 Native dependencies in AARs buildFeatures.prefab=true - Missing argument “PACKAGE_PATH”

安卓工作室 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
    }

然后,您必須在設置該命令后鏈接到現有的預制發布模塊,否則會發生此錯誤

這可以在 Android.mk 或 CMakeLists 中完成

安卓.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

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM