AOSP android.content.res.Resources $ NotFoundException:资源ID#0x0

时间:2019-01-16 09:22:30

标签: android android-source

我在AOSP中构建了一个apk,然后我将其推入电话,发生了错误。

  

01-16 16:51:31.586 28823 28823 E AndroidRuntime:java.lang.RuntimeException:无法启动活动ComponentInfo {com.smartcloud.test / com.smartcloud.test.MainActivity}:android.content.res.Resources $ NotFoundException:资源ID#0x0   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2892)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.app.ActivityThread.-wrap11(未知来源:0)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1593)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.os.Handler.dispatchMessage(Handler.java:105)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.os.Looper.loop(Looper.java:164)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.app.ActivityThread.main(ActivityThread.java:6541)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:at java.lang.reflect.Method.invoke(本机方法)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:at com.android.internal.os.Zygote $ MethodAndArgsCaller.run(Zygote.java:240)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:767)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:由以下原因引起:android.content.res.Resources $ NotFoundException:资源ID#0x0   01-16 16:51:31.586 28823 28823 E AndroidRuntime:at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:195)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:at android.content.res.Resources.getValue(Resources.java:1315)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.support.v7.widget.AppCompatDrawableManager.createDrawableIfNeeded(AppCompatDrawableManager.java:234)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:197)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:188)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:755)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:88)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.support.v7.app.AppCompatDelegateImplBase。(AppCompatDelegateImplBase.java:128)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.support.v7.app.AppCompatDelegateImplV9。(AppCompatDelegateImplV9.java:149)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.support.v7.app.AppCompatDelegateImplV11。(AppCompatDelegateImplV11.java:29)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.support.v7.app.AppCompatDelegateImplV14。(AppCompatDelegateImplV14.java:54)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.support.v7.app.AppCompatDelegateImplV23。(AppCompatDelegateImplV23.java:31)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.support.v7.app.AppCompatDelegateImplN。(AppCompatDelegateImplN.java:31)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:198)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:183)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:520)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.support.v7.app.AppCompatActivity.onCreate(AppCompatActivity.java:71)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:在com.smartcloud.test.MainActivity.onCreate(MainActivity.java:10)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:在android.app.Activity.performCreate(Activity.java:6975)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:位于android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2770)   01-16 16:51:31.586 28823 28823 E AndroidRuntime:...还有9个

我的活动:

public class MainActivity extends AppCompatActivity {

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_main);
}

}

Android.mk:

LOCAL_PATH := $(call my-dir)

include $(CLEAR_VARS)

LOCAL_MODULE_TAGS := optional

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

#LOCAL_SDK_VERSION := current

LOCAL_STATIC_ANDROID_LIBRARIES := \
    android-support-v7-appcompat \
    android-support-v4

LOCAL_PACKAGE_NAME := TestHello

LOCAL_CERTIFICATE := platform
LOCAL_DEX_PREOPT := false

LOCAL_MANIFEST_FILE := app/src/main/AndroidManifest.xml
LOCAL_RESOURCE_DIR := \
    $(LOCAL_PATH)/app/src/main/res \
    frameworks/support/v7/appcompat/res

LOCAL_AAPT_FLAGS := \
    --auto-add-overlay

include $(BUILD_PACKAGE)

有人可以帮助我吗?

1 个答案:

答案 0 :(得分:0)

不要在AOSP中使用兼容性库:

AppCompatActivtyi, v4.Fragment