Android项目在模拟器上工作但在移动设备上没有

时间:2013-10-14 03:06:31

标签: android

正如问题标题所述。我收到此logcat错误:

10-14 15:57:54.319: E/AndroidRuntime(771): FATAL EXCEPTION: main
10-14 15:57:54.319: E/AndroidRuntime(771): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.contactmanager/com.example.contactmanager.HomeScreenActivity}: android.view.InflateException: Binary XML file line #49: Error inflating class <unknown>
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1651)
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1667)
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.app.ActivityThread.access$1500(ActivityThread.java:117)
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:935)
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.os.Handler.dispatchMessage(Handler.java:99)
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.os.Looper.loop(Looper.java:130)
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.app.ActivityThread.main(ActivityThread.java:3687)
10-14 15:57:54.319: E/AndroidRuntime(771):  at java.lang.reflect.Method.invokeNative(Native Method)
10-14 15:57:54.319: E/AndroidRuntime(771):  at java.lang.reflect.Method.invoke(Method.java:507)
10-14 15:57:54.319: E/AndroidRuntime(771):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:867)
10-14 15:57:54.319: E/AndroidRuntime(771):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:625)
10-14 15:57:54.319: E/AndroidRuntime(771):  at dalvik.system.NativeStart.main(Native Method)
10-14 15:57:54.319: E/AndroidRuntime(771): Caused by: android.view.InflateException: Binary XML file line #49: Error inflating class <unknown>
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.view.LayoutInflater.createView(LayoutInflater.java:518)
10-14 15:57:54.319: E/AndroidRuntime(771):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
10-14 15:57:54.319: E/AndroidRuntime(771):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:209)
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.app.Activity.setContentView(Activity.java:1657)
10-14 15:57:54.319: E/AndroidRuntime(771):  at com.example.contactmanager.HomeScreenActivity.onCreate(HomeScreenActivity.java:58)
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1615)
10-14 15:57:54.319: E/AndroidRuntime(771):  ... 11 more
10-14 15:57:54.319: E/AndroidRuntime(771): Caused by: java.lang.reflect.InvocationTargetException
10-14 15:57:54.319: E/AndroidRuntime(771):  at java.lang.reflect.Constructor.constructNative(Native Method)
10-14 15:57:54.319: E/AndroidRuntime(771):  at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.view.LayoutInflater.createView(LayoutInflater.java:505)
10-14 15:57:54.319: E/AndroidRuntime(771):  ... 22 more
10-14 15:57:54.319: E/AndroidRuntime(771): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x2/d=0x10102fd a=-1}
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.content.res.Resources.loadDrawable(Resources.java:1681)
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.view.View.<init>(View.java:1951)
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.view.View.<init>(View.java:1899)
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.view.ViewGroup.<init>(ViewGroup.java:286)
10-14 15:57:54.319: E/AndroidRuntime(771):  at android.widget.RelativeLayout.<init>(RelativeLayout.java:173)
10-14 15:57:54.319: E/AndroidRuntime(771):  ... 25 more

为什么不起作用?

1 个答案:

答案 0 :(得分:2)

您的Android手机可能阻止该应用执行,请检查调试权限。此外,为了以防万一,检查您的项目的目标平台和手机上的Android版本是否对应(至少不应该在手机上运行较低版本。)这些只是基本检查,您可能已经完成了这些已经,即便如此,也没有伤害提醒:)