我正在尝试将应用程序添加到自定义 android 构建中,但它无法理解 Theme.AppCompat.Light.DarkActionBar 和 colorPrimary 和 colorAccent 等资源,这让我相信它在读取和构建 R.java 时遇到了问题。
我的错误
target R.java/Manifest.java: MyApplication21 (out/target/common/obj/APPS/MyApplication21_intermediates/src/R.stamp)
packages/apps/MyApplication21/res/values/styles.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'.
packages/apps/MyApplication21/res/values/styles.xml:8: error: Error: No resource found that matches the given name: attr 'colorAccent'.
packages/apps/MyApplication21/res/values/styles.xml:6: error: Error: No resource found that matches the given name: attr 'colorPrimary'.
packages/apps/MyApplication21/res/values/styles.xml:7: error: Error: No resource found that matches the given name: attr 'colorPrimaryDark'.
build/core/package_internal.mk:236: recipe for target 'out/target/common/obj/APPS/MyApplication21_intermediates/src/R.stamp' failed
make: *** [out/target/common/obj/APPS/MyApplication21_intermediates/src/R.stamp] Error 1
make: Leaving directory '/home/mkemp/android'
#### make failed to build some targets ####
我做了什么:
- 创建了一个安卓应用。这个应用程序在 android studio 中编译。
- 将清单、java(重命名为 src)和 res 目录复制到我的自定义构建中:
android/packages/apps/MyApplication21
创建了一个 Android.mk 文件
LOCAL_PATH:= $(call my-dir) include $(CLEAR_VARS) LOCAL_MODULE_TAGS := optional # Java sources are in src LOCAL_SRC_FILES := $(call all-java-files-under, src) # Resources are in res LOCAL_RESOURCE_DIR := $(LOCAL_PATH)/res # These jars are needed LOCAL_STATIC_JAVA_LIBRARIES += android-support-v7-appcompat \ android-support-v4 # The name of this application LOCAL_PACKAGE_NAME := MyApplication21 # No proguard LOCAL_PROGUARD_ENABLED := disabled
到目前为止,我已经解决了包括无法理解 Java 类(如 ActionBarActivity 和 TaskStackBuilder)的错误,方法android-support-v7-appcompat
是android-support-v4
按顺序将其包含到 Android.mk 文件中,但我不知道应该调用哪个 Java 库来生成 R .java 文件。
任何人都可以帮忙吗?
编辑:
我注意到没有在 中创建 R.stamp 文件android/out/target/common/obj/APPS/MyApplication21/src
,根据 APPS 文件夹中的其他应用程序判断,它应该在那里构建......再次让我相信罪魁祸首是 R.java 文件没有正确生成。