不幸的是app已停止在android模拟器中

时间:2015-02-22 18:27:29

标签: android

我的应用程序在打开模拟器中的第一个屏幕时没有问题。但是当我单击第一页的按钮进入nect页面-screen2时,我收到错误“不幸的是myapp已经停止”。请帮助我

这是screen1.java

package com.example.library;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
public class Screen1 extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_screen1);
        Button login=(Button)findViewById(R.id.loginBtn);

        login.setOnClickListener(new View.OnClickListener() {
            public void onClick(View view) {
                Intent screen1i= new Intent(Screen1.this, Screen2.class);           
                startActivity(screen1i);
                        }
                    });

    }

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.screen1, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.
        int id = item.getItemId();
        if (id == R.id.action_settings) {
            return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

Screen2.java

package com.example.library;

import android.app.Activity;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.Bundle;
import android.preference.PreferenceManager;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.TextView;

public class Screen2 extends Activity {



    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_screen2);



    Button orderButton1=(Button)findViewById(R.id.mpBtn);

    orderButton1.setOnClickListener(new View.OnClickListener() {


        @Override
        public void onClick(View view) {

Intent intent1= new Intent(Screen2.this, Screen3.class);            
startActivity(intent1);
        }
    });
}

    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
        // Inflate the menu; this adds items to the action bar if it is present.
        getMenuInflater().inflate(R.menu.screen2, menu);
        return true;
    }

    @Override
    public boolean onOptionsItemSelected(MenuItem item) {
        // Handle action bar item clicks here. The action bar will
        // automatically handle clicks on the Home/Up button, so long
        // as you specify a parent activity in AndroidManifest.xml.

        int id = item.getItemId();
        if (id == R.id.action_settings) {
    return true;
        }
        return super.onOptionsItemSelected(item);
    }
}

android manifest

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

    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/icon"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name=".Screen1"
            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=".Screen2"
            android:label="@string/title_activity_screen2"
            android:parentActivityName=".Screen1" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.
                library.Screen1" />
        </activity>
        <activity
            android:name=".Screen3"
            android:label="@string/title_activity_screen3"
            android:parentActivityName=".Screen2" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.library.Screen2" />
        </activity>
        <activity
            android:name=".Second"
            android:label="@string/title_activity_second" >
        </activity>
        <activity
            android:name=".Screen4"
            android:label="@string/title_activity_screen4"
            android:parentActivityName=".Screen3" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.library.Screen3" />
        </activity>
        <activity
            android:name=".Screen5"
            android:label="@string/title_activity_screen5"
            android:parentActivityName=".Screen4"
            android:screenOrientation="portrait" >
            <meta-data
                android:name="android.support.PARENT_ACTIVITY"
                android:value="com.example.library.Screen4" />
        </activity>


    </application>

</manifest>

logcat的

02-22 13:45:31.631: E/AndroidRuntime(1115): Process: com.example.library, PID: 1115
02-22 13:45:31.631: E/AndroidRuntime(1115): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.library/com.example.library.Screen2}: android.view.InflateException: Binary XML file line #19: Error inflating class textview
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.app.ActivityThread.access$800(ActivityThread.java:135)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.os.Handler.dispatchMessage(Handler.java:102)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.os.Looper.loop(Looper.java:136)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.app.ActivityThread.main(ActivityThread.java:5017)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at java.lang.reflect.Method.invokeNative(Native Method)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at java.lang.reflect.Method.invoke(Method.java:515)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at dalvik.system.NativeStart.main(Native Method)
02-22 13:45:31.631: E/AndroidRuntime(1115): Caused by: android.view.InflateException: Binary XML file line #19: Error inflating class textview
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:707)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.app.Activity.setContentView(Activity.java:1929)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at com.example.library.Screen2.onCreate(Screen2.java:22)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.app.Activity.performCreate(Activity.java:5231)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
02-22 13:45:31.631: E/AndroidRuntime(1115):     ... 11 more
02-22 13:45:31.631: E/AndroidRuntime(1115): Caused by: java.lang.ClassNotFoundException: Didn't find class "android.view.textview" on path: DexPathList[[zip file "/data/app/com.example.library-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.library-2, /system/lib]]
02-22 13:45:31.631: E/AndroidRuntime(1115):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.view.LayoutInflater.createView(LayoutInflater.java:559)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:652)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:66)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
02-22 13:45:31.631: E/AndroidRuntime(1115):     at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
02-22 13:45:31.631: E/AndroidRuntime(1115):     ... 22 more
02-22 13:45:31.891: W/ActivityManager(387):   Force finishing activity com.example.library/.Screen2
02-22 13:45:32.001: W/ActivityManager(387):   Force finishing activity com.example.library/.Screen1
02-22 13:45:32.791: W/ActivityManager(387): Activity pause timeout for ActivityRecord{b30ff8b0 u0 com.example.library/.Screen2 t3 f}
02-22 13:45:33.011: I/Choreographer(387): Skipped 30 frames!  The application may be doing too much work on its main thread.
02-22 13:45:33.771: I/Choreographer(1036): Skipped 46 frames!  The application may be doing too much work on its main thread.
02-22 13:45:34.181: W/EGL_emulation(1036): eglSurfaceAttrib not implemented
02-22 13:45:35.291: D/AlertService(946): No fired or scheduled alerts
02-22 13:45:35.351: D/AlertService(946): Scheduling next alarm with AlarmScheduler. sEventReminderReceived: null
02-22 13:45:35.411: D/AlarmScheduler(946): No events found starting within 1 week.
02-22 13:45:35.421: I/ActivityManager(387): Resuming delayed broadcast
02-22 13:45:36.061: I/ActivityManager(387): Delay finish: com.android.providers.calendar/.CalendarProviderBroadcastReceiver
02-22 13:45:36.501: I/ActivityManager(387): Resuming delayed broadcast
02-22 13:45:36.661: I/ActivityManager(387): Delay finish: com.android.mms/.transaction.SmsReceiver
02-22 13:45:36.731: V/SmsReceiverService(919): onStart: #1 mResultCode: -1 = Activity.RESULT_OK
02-22 13:45:37.081: E/SoundPool(387): error loading /system/media/audio/ui/Effect_Tick.ogg
02-22 13:45:37.081: W/AudioService(387): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
02-22 13:45:37.101: E/SoundPool(387): error loading /system/media/audio/ui/Effect_Tick.ogg
02-22 13:45:37.101: W/AudioService(387): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
02-22 13:45:37.121: E/SoundPool(387): error loading /system/media/audio/ui/Effect_Tick.ogg
02-22 13:45:37.121: W/AudioService(387): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
02-22 13:45:37.161: E/SoundPool(387): error loading /system/media/audio/ui/Effect_Tick.ogg
02-22 13:45:37.161: W/AudioService(387): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
02-22 13:45:37.471: D/dalvikvm(387): GC_FOR_ALLOC freed 618K, 18% free 6322K/7676K, paused 259ms, total 267ms
02-22 13:45:37.471: E/SoundPool(387): error loading /system/media/audio/ui/Effect_Tick.ogg
02-22 13:45:37.481: W/AudioService(387): Soundpool could not load file: /system/media/audio/ui/Effect_Tick.ogg
02-22 13:45:37.481: E/SoundPool(387): error loading /system/media/audio/ui/KeypressStandard.ogg
02-22 13:45:37.481: W/AudioService(387): Soundpool could not load file: /system/media/audio/ui/KeypressStandard.ogg
02-22 13:45:37.481: E/SoundPool(387): error loading /system/media/audio/ui/KeypressSpacebar.ogg
02-22 13:45:37.501: W/AudioService(387): Soundpool could not load file: /system/media/audio/ui/KeypressSpacebar.ogg
02-22 13:45:37.501: E/SoundPool(387): error loading /system/media/audio/ui/KeypressDelete.ogg
02-22 13:45:37.501: W/AudioService(387): Soundpool could not load file: /system/media/audio/ui/KeypressDelete.ogg
02-22 13:45:37.501: E/SoundPool(387): error loading /system/media/audio/ui/KeypressReturn.ogg
02-22 13:45:37.501: W/AudioService(387): Soundpool could not load file: /system/media/audio/ui/KeypressReturn.ogg
02-22 13:45:37.521: I/Process(1115): Sending signal. PID: 1115 SIG: 9
02-22 13:45:37.661: E/SoundPool(387): error loading /system/media/audio/ui/KeypressInvalid.ogg
02-22 13:45:37.661: W/AudioService(387): Soundpool could not load file: /system/media/audio/ui/KeypressInvalid.ogg
02-22 13:45:37.671: W/AudioService(387): onLoadSoundEffects(), Error -1 while loading samples
02-22 13:45:37.881: I/Choreographer(387): Skipped 48 frames!  The application may be doing too much work on its main thread.
02-22 13:45:38.941: I/ActivityManager(387): Process com.example.library (pid 1115) has died.
02-22 13:45:38.971: I/WindowState(387): WIN DEATH: Window{b3003ac0 u0 com.example.library/com.example.library.Screen1}
02-22 13:45:39.551: D/dalvikvm(919): GC_FOR_ALLOC freed 340K, 13% free 2872K/3284K, paused 97ms, total 118ms
02-22 13:45:39.601: E/StrictMode(919): A resource was acquired at attached stack trace but never released. See java.io.Closeable for information on avoiding resource leaks.
02-22 13:45:39.601: E/StrictMode(919): java.lang.Throwable: Explicit termination method 'release' not called
02-22 13:45:39.601: E/StrictMode(919):  at dalvik.system.CloseGuard.open(CloseGuard.java:184)
02-22 13:45:39.601: E/StrictMode(919):  at android.drm.DrmManagerClient.<init>(DrmManagerClient.java:258)
02-22 13:45:39.601: E/StrictMode(919):  at com.google.android.mms.pdu.PduPersister.<init>(PduPersister.java:288)
02-22 13:45:39.601: E/StrictMode(919):  at com.google.android.mms.pdu.PduPersister.getPduPersister(PduPersister.java:296)
02-22 13:45:39.601: E/StrictMode(919):  at com.android.mms.transaction.TransactionService.onNewIntent(TransactionService.java:224)
02-22 13:45:39.601: E/StrictMode(919):  at com.android.mms.transaction.TransactionService$ServiceHandler.handleMessage(TransactionService.java:621)
02-22 13:45:39.601: E/StrictMode(919):  at android.os.Handler.dispatchMessage(Handler.java:102)
02-22 13:45:39.601: E/StrictMode(919):  at android.os.Looper.loop(Looper.java:136)
02-22 13:45:39.601: E/StrictMode(919):  at android.os.HandlerThread.run(HandlerThread.java:61)
02-22 13:45:39.831: I/ActivityManager(387): Resuming delayed broadcast
02-22 13:45:40.041: I/ActivityManager(387): Delay finish: com.android.providers.calendar/.CalendarProviderBroadcastReceiver
02-22 13:45:40.151: I/ActivityManager(387): Resuming delayed broadcast
02-22 13:45:40.231: V/AlarmClock(967): AlarmInitReceiver android.intent.action.TIME_SET
02-22 13:45:41.161: I/AlarmClock(967): Displaying next alarm time: ''
02-22 13:45:41.291: V/AlarmClock(967): AlarmInitReceiver finished
02-22 13:45:41.751: I/MediaFocusControl(387):  AudioFocus  abandonAudioFocus() from android.media.AudioManager@b2d25998com.android.music.MediaPlaybackService$3@b2d24818
02-22 13:47:37.971: D/dalvikvm(515): GC_FOR_ALLOC freed 530K, 16% free 3300K/3900K, paused 227ms, total 238ms

1 个答案:

答案 0 :(得分:0)

  

引起:android.view.InflateException:二进制XML文件行#19:错误导致类textview

     

...

     

引起:java.lang.ClassNotFoundException:没有找到类“android.view.textview”

您对“textview”的错误引用是布局XML第19行的元素,可能是Screen2的元素。

要工作,需要使用正确的大小写,即“TextView”