我正在开发一个app-project,但突然间它总是立即崩溃。我不知道原因。这里是崩溃日志:
03-24 00:16:27.050: E/AndroidRuntime(533): FATAL EXCEPTION: main
03-24 00:16:27.050: E/AndroidRuntime(533): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.lexoffice.android/com.lexoffice.android.Login}: android.view.InflateException: Binary XML file line #54: Error inflating class android.widget.Button
03-24 00:16:27.050: E/AndroidRuntime(533): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1956)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.app.ActivityThread.access$600(ActivityThread.java:123)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.os.Handler.dispatchMessage(Handler.java:99)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.os.Looper.loop(Looper.java:137)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.app.ActivityThread.main(ActivityThread.java:4424)
03-24 00:16:27.050: E/AndroidRuntime(533): at java.lang.reflect.Method.invokeNative(Native Method)
03-24 00:16:27.050: E/AndroidRuntime(533): at java.lang.reflect.Method.invoke(Method.java:511)
03-24 00:16:27.050: E/AndroidRuntime(533): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-24 00:16:27.050: E/AndroidRuntime(533): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-24 00:16:27.050: E/AndroidRuntime(533): at dalvik.system.NativeStart.main(Native Method)
03-24 00:16:27.050: E/AndroidRuntime(533): Caused by: android.view.InflateException: Binary XML file line #54: Error inflating class android.widget.Button
03-24 00:16:27.050: E/AndroidRuntime(533): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
03-24 00:16:27.050: E/AndroidRuntime(533): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
03-24 00:16:27.050: E/AndroidRuntime(533): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.app.Activity.setContentView(Activity.java:1835)
03-24 00:16:27.050: E/AndroidRuntime(533): at com.lexoffice.android.Login.onCreate(Login.java:21)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.app.Activity.performCreate(Activity.java:4465)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
03-24 00:16:27.050: E/AndroidRuntime(533): ... 11 more
03-24 00:16:27.050: E/AndroidRuntime(533): Caused by: java.lang.reflect.InvocationTargetException
03-24 00:16:27.050: E/AndroidRuntime(533): at java.lang.reflect.Constructor.constructNative(Native Method)
03-24 00:16:27.050: E/AndroidRuntime(533): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
03-24 00:16:27.050: E/AndroidRuntime(533): ... 26 more
03-24 00:16:27.050: E/AndroidRuntime(533): Caused by: android.content.res.Resources$NotFoundException: File res/layout/activity_login.xml from color state list resource ID #0x7f030000
03-24 00:16:27.050: E/AndroidRuntime(533): at android.content.res.Resources.loadColorStateList(Resources.java:2053)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.content.res.TypedArray.getColorStateList(TypedArray.java:342)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.widget.TextView.<init>(TextView.java:782)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.widget.Button.<init>(Button.java:108)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.widget.Button.<init>(Button.java:104)
03-24 00:16:27.050: E/AndroidRuntime(533): ... 29 more
03-24 00:16:27.050: E/AndroidRuntime(533): Caused by: org.xmlpull.v1.XmlPullParserException: Binary XML file line #2: invalid drawable tag ScrollView
03-24 00:16:27.050: E/AndroidRuntime(533): at android.content.res.ColorStateList.createFromXmlInner(ColorStateList.java:146)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.content.res.ColorStateList.createFromXml(ColorStateList.java:129)
03-24 00:16:27.050: E/AndroidRuntime(533): at android.content.res.Resources.loadColorStateList(Resources.java:2050)
03-24 00:16:27.050: E/AndroidRuntime(533): ... 33 more
答案 0 :(得分:1)
当您尝试访问XML文件中定义的onCreate()
个对象之一时,您的应用程序在Button
失败。根据我的经验,当您在findViewById()
值中指定错误的资源ID时,R.id.whatever
可能会发生此失败。
如果一切都结束,通常完全刷新,清理和重建可以解决问题。