有谁知道这个日志是什么意思,我该如何修复它?
04-16 08:02:39.624: E/AndroidRuntime(20819): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.logoquiz/com.example.logoquiz.ChooseScreen}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
这是整个日志
04-16 08:18:38.494: E/AndroidRuntime(22245): FATAL EXCEPTION: main
04-16 08:18:38.494: E/AndroidRuntime(22245): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.logoquiz/com.example.logoquiz.ChooseScreen}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2355)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2391)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.app.ActivityThread.access$600(ActivityThread.java:151)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1335)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.os.Handler.dispatchMessage(Handler.java:99)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.os.Looper.loop(Looper.java:155)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.app.ActivityThread.main(ActivityThread.java:5520)
04-16 08:18:38.494: E/AndroidRuntime(22245): at java.lang.reflect.Method.invokeNative(Native Method)
04-16 08:18:38.494: E/AndroidRuntime(22245): at java.lang.reflect.Method.invoke(Method.java:511)
04-16 08:18:38.494: E/AndroidRuntime(22245): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1029)
04-16 08:18:38.494: E/AndroidRuntime(22245): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:796)
04-16 08:18:38.494: E/AndroidRuntime(22245): at dalvik.system.NativeStart.main(Native Method)
04-16 08:18:38.494: E/AndroidRuntime(22245): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.view.LayoutInflater.createView(LayoutInflater.java:613)
04-16 08:18:38.494: E/AndroidRuntime(22245): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
04-16 08:18:38.494: E/AndroidRuntime(22245): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:324)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.app.Activity.setContentView(Activity.java:1912)
04-16 08:18:38.494: E/AndroidRuntime(22245): at com.example.logoquiz.ChooseScreen.onCreate(ChooseScreen.java:25)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.app.Activity.performCreate(Activity.java:5066)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1101)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2311)
04-16 08:18:38.494: E/AndroidRuntime(22245): ... 11 more
04-16 08:18:38.494: E/AndroidRuntime(22245): Caused by: java.lang.reflect.InvocationTargetException
04-16 08:18:38.494: E/AndroidRuntime(22245): at java.lang.reflect.Constructor.constructNative(Native Method)
04-16 08:18:38.494: E/AndroidRuntime(22245): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.view.LayoutInflater.createView(LayoutInflater.java:587)
04-16 08:18:38.494: E/AndroidRuntime(22245): ... 23 more
04-16 08:18:38.494: E/AndroidRuntime(22245): Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x5/d=0x1001 a=4 r=0x7f040000}
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.content.res.Resources.loadDrawable(Resources.java:1927)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.view.View.<init>(View.java:3354)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.view.ViewGroup.<init>(ViewGroup.java:438)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.widget.LinearLayout.<init>(LinearLayout.java:176)
04-16 08:18:38.494: E/AndroidRuntime(22245): at android.widget.LinearLayout.<init>(LinearLayout.java:172)
04-16 08:18:38.494: E/AndroidRuntime(22245): ... 26 more
这是主要活动:
package com.example.logoquiz;
import android.os.Bundle;
import android.app.Activity;
import android.content.Intent;
import android.view.Menu;
import android.view.View;
import android.widget.Button;
import android.widget.TextView;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
public void start(View v){
Intent intent = new Intent (MainActivity.this, ChooseScreen.class);
startActivity(intent);
}
public void quit(View v){
System.exit(0);
}
@Override
public boolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
return true;
}
}
这很明显:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.logoquiz"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
android:targetSdkVersion="18" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.logoquiz.MainActivity"
android:label="@string/app_name"
>
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.logoquiz.ChooseScreen"
android:label="@string/app_name"
>
</activity>
<activity
android:name="com.example.logoquiz.LevelMenu"
>
</activity>
<activity
android:name="com.example.logoquiz.LogoHall"
>
</activity>
<activity
android:name="com.example.logoquiz.quizscreen"
>
</activity>
</application>
</manifest>
当应用程序运行并且它进入newq意图部分时它突然崩溃并且我已经在清单中的新活动上声明了你能看到这里有什么问题吗?
答案 0 :(得分:0)
你在ChooseScreen类中膨胀任何xml。
如果是,那么你是否使用getApplication()进行膨胀,如果是,则将其更改为此。 我有同样的问题,并且在膨胀时将getApplication()更改为此,并且此问题已得到解决..
希望它也能帮到你......请尝试......