1
每當我嘗試運行仿真程序時,它都會崩潰。這裏是logcat的我收到:應用仿真程序崩潰
10-31 09:09:59.104: W/dalvikvm(1840): threadid=1: thread exiting with uncaught exception (group=0x414c4700)
10-31 09:09:59.453: E/AndroidRuntime(1840): FATAL EXCEPTION: main
10-31 09:09:59.453: E/AndroidRuntime(1840): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.secondapp/com.example.secondapp.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.app.ActivityThread.access$600(ActivityThread.java:141)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.os.Handler.dispatchMessage(Handler.java:99)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.os.Looper.loop(Looper.java:137)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.app.ActivityThread.main(ActivityThread.java:5103)
10-31 09:09:59.453: E/AndroidRuntime(1840): at java.lang.reflect.Method.invokeNative(Native Method)
10-31 09:09:59.453: E/AndroidRuntime(1840): at java.lang.reflect.Method.invoke(Method.java:525)
10-31 09:09:59.453: E/AndroidRuntime(1840): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
10-31 09:09:59.453: E/AndroidRuntime(1840): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-31 09:09:59.453: E/AndroidRuntime(1840): at dalvik.system.NativeStart.main(Native Method)
10-31 09:09:59.453: E/AndroidRuntime(1840): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class <unknown>
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.view.LayoutInflater.createView(LayoutInflater.java:620)
10-31 09:09:59.453: E/AndroidRuntime(1840): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.view.LayoutInflater.inflate(LayoutInflater.java:469)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
10-31 09:09:59.453: E/AndroidRuntime(1840): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:267)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.app.Activity.setContentView(Activity.java:1895)
10-31 09:09:59.453: E/AndroidRuntime(1840): at com.example.secondapp.MainActivity.onCreate(MainActivity.java:19)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.app.Activity.performCreate(Activity.java:5133)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
10-31 09:09:59.453: E/AndroidRuntime(1840): ... 11 more
10-31 09:09:59.453: E/AndroidRuntime(1840): Caused by: java.lang.reflect.InvocationTargetException
10-31 09:09:59.453: E/AndroidRuntime(1840): at java.lang.reflect.Constructor.constructNative(Native Method)
10-31 09:09:59.453: E/AndroidRuntime(1840): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.view.LayoutInflater.createView(LayoutInflater.java:594)
10-31 09:09:59.453: E/AndroidRuntime(1840): ... 23 more
10-31 09:09:59.453: E/AndroidRuntime(1840): Caused by: java.lang.OutOfMemoryError
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:503)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:356)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:800)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.content.res.Resources.loadDrawable(Resources.java:2105)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.view.View.<init>(View.java:3364)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.view.ViewGroup.<init>(ViewGroup.java:457)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.widget.LinearLayout.<init>(LinearLayout.java:176)
10-31 09:09:59.453: E/AndroidRuntime(1840): at android.widget.LinearLayout.<init>(LinearLayout.java:172)
10-31 09:09:59.453: E/AndroidRuntime(1840): ... 26 more
10-31 09:09:59.643: D/dalvikvm(1840): GC_FOR_ALLOC freed 62704K, 96% free 2693K/65536K, paused 164ms, total 166ms
10-31 09:10:22.983: I/Process(1840): Sending signal. PID: 1840 SIG: 9
這是我的Java代碼:
package com.example.secondapp;
import android.app.Activity;
import android.content.Intent;
import android.media.MediaPlayer;
import android.os.Bundle;
public class Splash extends Activity {
MediaPlayer ourSong;
@Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
setContentView(R.layout.splash);
ourSong = MediaPlayer.create(Splash.this, R.raw.happyman);
ourSong.start();
Thread timer = new Thread(){
public void run(){
try{
sleep(1000);
} catch (InterruptedException e){
e.printStackTrace();
}finally{
Intent startMain = new Intent("com.example.secondapp.MainActivity");
startActivity(startMain);
}
}
};
timer.start();
}
@Override
protected void onPause() {
// TODO Auto-generated method stub
super.onPause();
ourSong.release();
finish();
}
}
我已經試過各種壽修復它,但我似乎無法找到問題。任何人都可以幫助我嗎?
佈局:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
android:background="@drawable/background1"
>
問題在您的xml文件中發佈.. –
不,您需要發佈「splash」佈局的xml文件。 –
不是清單。但佈局文件.. –