gpt4 book ai didi

android - 错误 : missing android-support-constraint-layout in AOSP but prebuilts/sdk/current/extras has it

转载 作者:行者123 更新时间:2023-11-30 04:59:02 27 4
gpt4 key购买 nike

我的 Android 源代码库已经有两个 jar 文件 android-support-constraint-layout.jarandroid-support-constraint-layout-solver.jar 分别在 prebuilts/sdk/current/extras/constraint-layout/libs/prebuilts/sdk/current/extras/constraint-layout-solver/。现在,我在 packages/app 中有一个应用程序,其中有一个 app/src/main/Android.mk:

LOCAL_STATIC_ANDROID_LIBRARIES := \
...
android-support-constraint-layout \
android-support-constraint-layout-solver

编译Android后仍然出现以下错误:

error: FirstApp (APPS android-x86) missing android-support-constraint-layout (JAVA_LIBRARIES android-x86)
You can set ALLOW_MISSING_DEPENDENCIES=true in your environment if this is intentional, but that may defer real problems until later in the build.
error: FirstApp (APPS android-x86) missing android-support-constraint-layout-solver (JAVA_LIBRARIES android-x86)

除了第一个,this link 中没有任何方法致力于在 AOSP 中添加约束布局。

最佳答案

我在 AOSP for Android-Oreo (v8.1) 的一个包中添加了约束布局。

下载constraint-layout (.aar) 和constraint-layout-solver (.jar)来自 Maven 存储库:https://mvnrepository.com/artifact/com.android.support.constraint/constraint-layout/1.0.2 , https://mvnrepository.com/artifact/com.android.support.constraint/constraint-layout-solver/1.0.2将它们放在应用程序主目录 (packages/apps/AnotherFirstApp/) 的 libs/ 文件夹中。

Android.mk中:

LOCAL_PATH:= $(call my-dir)
include $(CLEAR_VARS)

LOCAL_PACKAGE_NAME := AnotherFirstApp
LOCAL_MODULE_TAGS := optional
LOCAL_DEX_PREOPT := false

LOCAL_SRC_FILES := $(call all-java-files-under, src)

LOCAL_PROGUARD_FLAG_FILES := ../../../frameworks/support/design/proguard-rules.pro


ifeq ($(TARGET_BUILD_APPS),)
support_library_root_dir := frameworks/support
else
support_library_root_dir := prebuilts/sdk/current/support
endif

LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res \
$(support_library_root_dir)/design/res \
$(support_library_root_dir)/v7/cardview/res \
$(support_library_root_dir)/v7/recyclerview/res \
$(support_library_root_dir)/v7/appcompat/res

LOCAL_AAPT_FLAGS := \
--auto-add-overlay \
--extra-packages android.support.design \
--extra-packages android.support.v7.cardview \
--extra-packages android.support.constraint \
--extra-packages android.support.v7.recyclerview \
--extra-packages android.support.v7.appcompat

LOCAL_STATIC_JAVA_LIBRARIES := \
android-support-design \
android-support-v7-recyclerview \
android-support-v4 \
android-support-v7-cardview \
android-support-v7-appcompat \
constraint-layout-solver \

LOCAL_STATIC_JAVA_AAR_LIBRARIES := \
constraint-layout

include $(BUILD_PACKAGE)

include $(CLEAR_VARS)

LOCAL_PREBUILT_STATIC_JAVA_LIBRARIES := \
constraint-layout:libs/constraint-layout-1.0.2.aar \
constraint-layout-solver:libs/constraint-layout-solver-1.0.2.jar

include $(BUILD_MULTI_PREBUILT)

include $(call all-makefiles-under,$(LOCAL_PATH))

现在,没有问题了。该应用程序构建并运行良好。可能存在一个问题,因为没有以共享 jar 的方式添加约束求解器,以防其他应用程序也尝试使用此 jar。这需要通过在 frameworkexternal 中添加此 jar 来处理。

我从以下博客中获得了帮助:

  1. > https://sites.google.com/site/sbobovyc/home/Programming/a/creating-system-app
  2. > http://saurabhsharma123k.blogspot.com/2017/03/add-and-use-external-library-or-jar.html
  3. > https://kevinaboos.wordpress.com/2016/10/29/adding-an-external-library-or-jarfile-to-android-frameworks/
  4. > https://github.com/BrahmaOS/brahmaos-packages-apps-GoodWeather/blob/master/Android.mk

关于android - 错误 : missing android-support-constraint-layout in AOSP but prebuilts/sdk/current/extras has it,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58563453/

27 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com