我的Andr​​oid应用程序启动画面中的Andr​​oid模拟器启动,但随后的实际应用从未展示 [英] My Android app splash screen launches in the android emulator, but then the actual app never shows

查看:151
本文介绍了我的Andr​​oid应用程序启动画面中的Andr​​oid模拟器启动,但随后的实际应用从未展示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我尝试运行我的应用程序,在启动画面出现正确,和它关闭之后,弹出一个消息,说:不幸的是,第一个应用程序已停止工作我已经尝试了不同的每吨解决我的已经找到,但我相信我的情况下,它与模拟器中测试一种新的Hello World应用程序后,我的code的一个问题。这里是我的Andr​​oidManifest.xml的副本

 <?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
    包=com.examle.firstapp
    安卓版code =1
    机器人:=的versionName1.0>    <用途-SDK
        安卓的minSdkVersion =8
        机器人:targetSdkVersion =17/>    <应用
        机器人:allowBackup =真
        机器人:图标=@绘制/ ic_launcher
        机器人:标签=@字符串/ APP_NAME
        机器人:主题=@风格/ AppTheme>
        <活动
            扑通一声:Android的名称=机器人:标签=@字符串/ APP_NAME>
            &所述;意图滤光器>
                <作用机器人:名字=com.example.firstapp.MAIN/>
                <类机器人:名字=android.intent.category.LAUNCHER/>
            &所述; /意图滤光器>
        < /活性GT;        <活动
            MainActivity:机器人名=机器人:标签=@字符串/ APP_NAME>
            &所述;意图滤光器>
                <作用机器人:名字=android.intent.action.MAINACTIVTY/>
                <类机器人:名字=android.intent.category.DEFAULT/>
            &所述; /意图滤光器>
        < /活性GT;    < /用途>< /清单>

下面是日志猫尝试一些解决方案之后,会发生什么吧。

  06-08 16:12:06.849:E / AndroidRuntime(2821):致命异常:主要
06-08 16:12:06.849:E / AndroidRuntime(2821):了java.lang.RuntimeException:无法实例活动ComponentInfo {com.example.firstapp / com.example.firstapp.Splash}:抛出java.lang.ClassNotFoundException:没找不到路径上类com.example.firstapp.Splash:/data/app/com.example.firstapp-1.apk
06-08 16:12:06.849:E / AndroidRuntime(2821):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
06-08 16:12:06.849:E / AndroidRuntime(2821):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-08 16:12:06.849:E / AndroidRuntime(2821):在android.app.ActivityThread.access $ 600(ActivityThread.java:141)
06-08 16:12:06.849:E / AndroidRuntime(2821):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1234)
06-08 16:12:06.849:E / AndroidRuntime(2821):在android.os.Handler.dispatchMessage(Handler.java:99)
06-08 16:12:06.849:E / AndroidRuntime(2821):在android.os.Looper.loop(Looper.java:137)
06-08 16:12:06.849:E / AndroidRuntime(2821):在android.app.ActivityThread.main(ActivityThread.java:5041)
06-08 16:12:06.849:E / AndroidRuntime(2821):在java.lang.reflect.Method.invokeNative(本机方法)
06-08 16:12:06.849:E / AndroidRuntime(2821):在java.lang.reflect.Method.invoke(Method.java:511)
06-08 16:12:06.849:E / AndroidRuntime(2821):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:793)
06-08 16:12:06.849:E / AndroidRuntime(2821):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-08 16:12:06.849:E / AndroidRuntime(2821):在dalvik.system.NativeStart.main(本机方法)
06-08 16:12:06.849:E / AndroidRuntime(2821):抛出java.lang.ClassNotFoundException:产生的原因没有找到路径级com.example.firstapp.Splash:/data/app/com.example .firstapp-1.apk
06-08 16:12:06.849:E / AndroidRuntime(2821):在dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
06-08 16:12:06.849:E / AndroidRuntime(2821):在java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-08 16:12:06.849:E / AndroidRuntime(2821):在java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-08 16:12:06.849:E / AndroidRuntime(2821):在android.app.Instrumentation.newActivity(Instrumentation.java:1054)
06-08 16:12:06.849:E / AndroidRuntime(2821):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
06-08 16:12:06.849:E / AndroidRuntime(2821):11 ...更多

我真的很新到Android编程,因此,如果协助我时,那将是极大的AP preciated可以是具体的。


解决方案

 公共类SplashScreenActivity延伸活动{
    / **当第一次创建活动调用。 * /
    @覆盖    公共无效的onCreate(捆绑savedInstanceState){
        super.onCreate(savedInstanceState);
        的setContentView(R.layout.main);
        定时器定时器=新的Timer();
        timer.schedule(新MyTask(),5000);
    }
    类MyTask扩展的TimerTask {        @覆盖
        公共无效的run(){
            意向意图=新意图(SplashScreenActivity.this,SecondActivity.class);
            完();
            startActivity(意向);
        }    }}

在清单

 <意向滤光器>
  <作用机器人:名字=android.intent.action.MAIN/>
  <类机器人:名字=android.intent.category.LAUNCHER/>
  < /意向滤光器>进入`code here`
  < /活性GT;
  <活动机器人:名字=。SecondActivity/>

When i try to run my app, the splash screen comes up correctly, and right after it closes, a message pops up that says "Unfortunatly, First app has stopped working" I've tried a ton of different solutions I've found but i believe in my case, it's a problem with my code after testing a new "Hello World" app within the emulator. Here's a copy of my androidmanifest.xml

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

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

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


        <activity
            android:name=".Splash" android:label="@string/app_name" >
            <intent-filter>
                <action android:name="com.example.firstapp.MAIN" />
                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>

        <activity
            android:name=".MainActivity" android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAINACTIVTY" />
                <category android:name="android.intent.category.DEFAULT" />
            </intent-filter>
        </activity>

    </application>

</manifest>

Here is what comes up in log cat after trying some of the solutions

    06-08 16:12:06.849: E/AndroidRuntime(2821): FATAL EXCEPTION: main
06-08 16:12:06.849: E/AndroidRuntime(2821): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.firstapp/com.example.firstapp.Splash}: java.lang.ClassNotFoundException: Didn't find class "com.example.firstapp.Splash" on path: /data/app/com.example.firstapp-1.apk
06-08 16:12:06.849: E/AndroidRuntime(2821):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2106)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at android.os.Handler.dispatchMessage(Handler.java:99)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at android.os.Looper.loop(Looper.java:137)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at android.app.ActivityThread.main(ActivityThread.java:5041)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at java.lang.reflect.Method.invokeNative(Native Method)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at java.lang.reflect.Method.invoke(Method.java:511)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at dalvik.system.NativeStart.main(Native Method)
06-08 16:12:06.849: E/AndroidRuntime(2821): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.example.firstapp.Splash" on path: /data/app/com.example.firstapp-1.apk
06-08 16:12:06.849: E/AndroidRuntime(2821):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at android.app.Instrumentation.newActivity(Instrumentation.java:1054)
06-08 16:12:06.849: E/AndroidRuntime(2821):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2097)
06-08 16:12:06.849: E/AndroidRuntime(2821):     ... 11 more

I'm really quite new to android programming, so if you could be specific when assisting me it would be greatly appreciated.

解决方案

 public class SplashScreenActivity extends Activity {
    /** Called when the activity is first created. */
    @Override

    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.main);
        Timer timer=new Timer();
        timer.schedule(new MyTask(), 5000);
    }


    class MyTask extends TimerTask{

        @Override
        public void run() {
            Intent intent=new  Intent(SplashScreenActivity.this,SecondActivity.class);
            finish();
            startActivity(intent);
        }

    }

}

in manifest

<intent-filter>
  <action android:name="android.intent.action.MAIN" /> 
  <category android:name="android.intent.category.LAUNCHER" /> 
  </intent-filter>`enter code here`
  </activity>
  <activity android:name=".SecondActivity" /> 

这篇关于我的Andr​​oid应用程序启动画面中的Andr​​oid模拟器启动,但随后的实际应用从未展示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆