Android应用在启动时崩溃

时间:2013-09-10 10:46:27

标签: android camera android-camera camera-flash

我正在尝试为Android应用程序制作一个Flash应用程序。但是,当我启动我的应用程序时,它会崩溃并记录以下崩溃日志。

09-10 14:42:20.354: D/AndroidRuntime(14025): Shutting down VM
09-10 14:42:20.354: W/dalvikvm(14025): threadid=1: thread exiting with uncaught exception (group=0x4001d648)
09-10 14:42:20.414: E/AndroidRuntime(14025): FATAL EXCEPTION: main
09-10 14:42:20.414: E/AndroidRuntime(14025): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.flashlightapp/com.example.flashlightapp.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1872)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1893)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.app.ActivityThread.access$1500(ActivityThread.java:135)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1054)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.os.Handler.dispatchMessage(Handler.java:99)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.os.Looper.loop(Looper.java:150)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.app.ActivityThread.main(ActivityThread.java:4385)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at java.lang.reflect.Method.invokeNative(Native Method)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at java.lang.reflect.Method.invoke(Method.java:507)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:849)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:607)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at dalvik.system.NativeStart.main(Native Method)
09-10 14:42:20.414: E/AndroidRuntime(14025): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.view.LayoutInflater.createView(LayoutInflater.java:518)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:250)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.app.Activity.setContentView(Activity.java:1711)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at com.example.flashlightapp.MainActivity.onCreate(MainActivity.java:34)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1072)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1836)
09-10 14:42:20.414: E/AndroidRuntime(14025):    ... 11 more
09-10 14:42:20.414: E/AndroidRuntime(14025): Caused by: java.lang.reflect.InvocationTargetException
09-10 14:42:20.414: E/AndroidRuntime(14025):    at java.lang.reflect.Constructor.constructNative(Native Method)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.view.LayoutInflater.createView(LayoutInflater.java:505)
09-10 14:42:20.414: E/AndroidRuntime(14025):    ... 21 more
09-10 14:42:20.414: E/AndroidRuntime(14025): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f050000 a=-1 r=0x7f050000}
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.content.res.Resources.loadDrawable(Resources.java:1707)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.view.View.<init>(View.java:1999)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.view.View.<init>(View.java:1947)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.view.ViewGroup.<init>(ViewGroup.java:308)
09-10 14:42:20.414: E/AndroidRuntime(14025):    at android.widget.RelativeLayout.<init>(RelativeLayout.java:173)
09-10 14:42:20.414: E/AndroidRuntime(14025):    ... 24 more
09-10 14:42:28.021: D/Process(14025): killProcess, pid=14025
09-10 14:42:28.071: D/Process(14025): dalvik.system.VMStack.getThreadStackTrace(Native Method)
09-10 14:42:28.071: D/Process(14025): java.lang.Thread.getStackTrace(Thread.java:745)
09-10 14:42:28.071: D/Process(14025): android.os.Process.killProcess(Process.java:797)
09-10 14:42:28.071: D/Process(14025): com.android.internal.os.RuntimeInit$UncaughtHandler.uncaughtException(RuntimeInit.java:108)
09-10 14:42:28.071: D/Process(14025): java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:854)
09-10 14:42:28.081: D/Process(14025): java.lang.ThreadGroup.uncaughtException(ThreadGroup.java:851)

1 个答案:

答案 0 :(得分:1)

您无法将主题设置为视图背景。在下面的代码中,行可能会导致问题。

android:background="@style/AppBaseTheme"

而不是你应该使用drawable。 ˚F

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    android:id="@+id/viewBackground"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:background="@android:color/white"
    tools:context=".MainActivity" >
    <TextView android:id="@+id/textTitle"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_alignParentTop="true"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="86dp"
        android:text="@string/hello_world" />
    <Button android:id="@+id/buttonFlashlight"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:layout_below="@+id/textTitle"
        android:layout_centerHorizontal="true"
        android:layout_marginTop="36dp"
        android:text="@string/hello_world" />
</RelativeLayout>