如何在自定义的android构建中包含R.java?

时间:2017-03-29 13:17:34

标签: java android r.java-file custom-build

我正在尝试将应用程序添加到自定义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  ####

我做了什么:

  1. 创建了一个Android应用。这个应用程序在android studio中编译。
  2. 将清单,java(重命名的src)和res目录复制到我的自定义构建中:android/packages/apps/MyApplication21
  3. 创建了一个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
    
  4. 到目前为止,我已经解决了错误,包括无法通过将android-support-v7-appcompatandroid-support-v4按顺序包含在Android.mk文件中来理解ActionBarActivity和TaskStackBuilder等Java类,但我没有想知道我应该调用什么Java库来生成R.java文件。

    有人可以帮忙吗?

    编辑:

    我注意到android/out/target/common/obj/APPS/MyApplication21/src中没有创建R.stamp文件,应该根据APPS文件夹中的其他应用程序来构建这个文件...并再次让我相信罪魁祸首是R .java文件未正确生成。

0 个答案:

没有答案