我在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:at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2817)01-16 16:51:31.586 28823 28823 E AndroidRuntime:at android.app。 ActivityThread.handleLaunchActivity(ActivityThread.java:2892)01-16 16:51:31.586 28823 28823 E AndroidRuntime:at android.app.ActivityThread.-wrap11(Unknown来源: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:at android.os.Handler.dispatchMessage(Handler.java:105)01-16 16 :51:31.586 28823 28823 E AndroidRuntime:at android.os.Looper.loop(Looper.java:164)01-16 16:51:31.586 28823 28823 E AndroidRuntime:at android.app.ActivityThread.main(Act ivityThread.java:6541)01-16 16:51:31.586 28823 28823 E AndroidRuntime:at java.lang.reflect.Method.invoke(Native Method)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:at 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:at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompa tDrawableManager.java:197)01-16 16:51:31.586 28823 28823 E AndroidRuntime:at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:188)01-16 16:51:31.586 28823 28823 E AndroidRuntime :at android.support.v7.widget.AppCompatDrawableManager.checkVectorDrawableSetup(AppCompatDrawableManager.java:755)01-16 16:51:31.586 28823 28823 E AndroidRuntime:at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java: 193)01-16 16:51:31.586 28823 28823 E AndroidRuntime:at android.support.v7.widget.TintTypedArray.getDrawableIfKnown(TintTypedArray.java:88)01-16 16:51:31.586 28823 28823 E AndroidRuntime:at android。 support.v7.app.AppCompatDelegateImplBase。(AppCompatDelegateImplBase.java:128)01-16 16:51:31.586 28823 28823 E AndroidRuntime:at android.support.v7.app.AppCompatDelegateImplV9。(AppCompatDelegateImplV9.java:149)01-16 16 :51:31.586 28823 28823 E AndroidRuntime:在android.support.v7.app.AppCompatDelegateImplV11。(A ppCompatDelegateImplV11.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:at android.support.v7.app.AppCompatDelegateImplN。(AppCompatDelegateImplN.java:31)01 -16 16:51:31.586 28823 28823 E AndroidRuntime:at android.support.v7.app.AppCompatDelegate.create(AppCompatDelegate.java:198)01-16 16:51:31.586 28823 28823 E AndroidRuntime:at android.support.v7 .app.AppCompatDelegate.create(AppCompatDelegate.java:183)01-16 16:51:31.586 28823 28823 E AndroidRuntime:at android.support.v7.app.AppCompatActivity.getDelegate(AppCompatActivity.java:520)01-16 16: 51:31.586 28823 28823 E AndroidRuntime:at 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:at android.app.Activity.performCreate(Activity.java:6975)01-16 16: 51:31.586 28823 28823 E AndroidRuntime:at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1213)01-16 16:51:31.586 28823 28823 E AndroidRuntime:at 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.门口:
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)
有谁能够帮我?
不要在AOSP中使用兼容性库:
AppCompatActivtyi, v4.Fragment