Android应用程序没有理由停止工作

时间:2013-05-22 12:49:42

标签: android debugging logcat

我的android应用程序字面上决定不会无缘无故地工作,我会发疯。我希望你能找到错误。请帮我。

我在一分钟前在虚拟设备上打开了应用程序并注意到我忘了尝试一项功能,并试图再次运行它,但在开始时,它给了我“GoogleSearch已停止”。我可以发布你想要的任何活动。这是LogCat的结果:

05-22 12:47:29.179: E/AndroidRuntime(1952): FATAL EXCEPTION: main
05-22 12:47:29.179: E/AndroidRuntime(1952): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.googlesearch/com.example.googlesearch.Spash}: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.os.Handler.dispatchMessage(Handler.java:99)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.os.Looper.loop(Looper.java:137)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.app.ActivityThread.main(ActivityThread.java:5039)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at java.lang.reflect.Method.invokeNative(Native Method)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at java.lang.reflect.Method.invoke(Method.java:511)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at dalvik.system.NativeStart.main(Native Method)
05-22 12:47:29.179: E/AndroidRuntime(1952): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class <unknown>
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.view.LayoutInflater.createView(LayoutInflater.java:613)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:660)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:685)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.view.LayoutInflater.inflate(LayoutInflater.java:466)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:270)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.app.Activity.setContentView(Activity.java:1881)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at com.example.googlesearch.Spash.onCreate(Spash.java:18)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.app.Activity.performCreate(Activity.java:5104)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
05-22 12:47:29.179: E/AndroidRuntime(1952):     ... 11 more
05-22 12:47:29.179: E/AndroidRuntime(1952): Caused by: java.lang.reflect.InvocationTargetException
05-22 12:47:29.179: E/AndroidRuntime(1952):     at java.lang.reflect.Constructor.constructNative(Native Method)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.view.LayoutInflater.createView(LayoutInflater.java:587)
05-22 12:47:29.179: E/AndroidRuntime(1952):     ... 23 more
05-22 12:47:29.179: E/AndroidRuntime(1952): Caused by: java.lang.OutOfMemoryError
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:502)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:355)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:785)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.content.res.Resources.loadDrawable(Resources.java:1965)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.view.View.<init>(View.java:3328)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.view.ViewGroup.<init>(ViewGroup.java:431)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.widget.LinearLayout.<init>(LinearLayout.java:176)
05-22 12:47:29.179: E/AndroidRuntime(1952):     at android.widget.LinearLayout.<init>(LinearLayout.java:172)
05-22 12:47:29.179: E/AndroidRuntime(1952):     ... 26 more

编辑:以下是主要活动的活动和布局。

public class Spash extends Activity {

    private final int SPLASH_DISPLAY_LENGHT = 2000;

    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle icicle) {
        super.onCreate(icicle);
        this.requestWindowFeature(Window.FEATURE_NO_TITLE);
        setContentView(R.layout.spash);

        /* New Handler to start the Menu-Activity 
         * and close this Splash-Screen after some seconds.*/
        new Handler().postDelayed(new Runnable(){
            @Override
            public void run() {
                /* Create an Intent that will start the Menu-Activity. */
                Intent mainIntent = new Intent(Spash.this, MainActivity.class);
                Spash.this.startActivity(mainIntent);
                Spash.this.finish();
            }
        }, SPLASH_DISPLAY_LENGHT);
    }
}

<?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:background="@drawable/first_page"
    android:orientation="vertical" >

</LinearLayout>

EDIT2:清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.googlesearch"
    android:versionCode="1"
    android:versionName="1.0" >
    <uses-permission android:name="android.permission.INTERNET"></uses-permission>

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="17"
        android:debuggable="true" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >

        <activity
            android:name="com.example.googlesearch.Spash"
            android:label="@string/app_name" android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name="com.example.googlesearch.MainActivity"
            android:label="@string/app_name" android:screenOrientation="portrait">
            <intent-filter>
                <action android:name="android.intent.action.PARENT_ACTIVITY" />

                <category android:name="android.intent.category.Spash" />
            </intent-filter>
        </activity>

        <activity
        android:name="com.example.googlesearch.AuxilaryVerbs"
        android:label="@string/title_auxilary"
        android:parentActivityName="com.example.googlesearch.MainActivity" android:screenOrientation="portrait">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.googlesearch.MainActivity" />
        </activity>

        <activity
        android:name="com.example.googlesearch.Results"
        android:label="@string/title_result"
        android:parentActivityName="com.example.googlesearch.AuxilaryVerbs" android:screenOrientation="portrait">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.googlesearch.AuxilaryVerbs" />
        </activity>

        <activity
        android:name="com.example.googlesearch.InfoPage"
        android:label="@string/title_result"
        android:parentActivityName="com.example.googlesearch.MainActivity" android:screenOrientation="portrait">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.googlesearch.MainActivity" />
        </activity>

        <activity
        android:name="com.example.googlesearch.InternetPage"
        android:label="@string/title_result"
        android:parentActivityName="com.example.googlesearch.Results" android:screenOrientation="portrait">
        <meta-data
            android:name="android.support.PARENT_ACTIVITY"
            android:value="com.example.googlesearch.Results" />
        </activity>
    </application>

</manifest>

1 个答案:

答案 0 :(得分:0)

我发现了错误。我不小心保存了所有PNG文件2667x4734,正如我的设计师发给我的那样。因此devnull是正确的,我将它们缩小为我的屏幕并且现在正在运行。谢谢大家。