我的Andr​​oid应用程序依然崩溃 [英] My Android App Keeps Crashing

查看:139
本文介绍了我的Andr​​oid应用程序依然崩溃的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始学习Android的发展,我得到这个SNIPPIT关闭谷歌Android开发的网站,它不断崩溃。

我的规格是:

Android的4.0.3
API 15

code:

 包lewes.android.hello;进口android.app.Activity;
进口android.os.Bundle;
进口android.widget.TextView;公共类HelloAndroid延伸活动{
   / **当第一次创建活动调用。 * /
   @覆盖
   公共无效的onCreate(捆绑savedInstanceState){
       super.onCreate(savedInstanceState);
       TextView的电视=新的TextView(本);
       tv.setText(你好,Android的);
       的setContentView(电视);
   }
}

我得到...

Unfortenualy,HelloAndroid没有响应。

请帮帮我!

我的清单:

 <?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
包=lewes.android.hello
安卓版code =1
机器人:=的versionName1.0><采用-SDK安卓的minSdkVersion =15/><应用
机器人:图标=@绘制/ ic_launcher
机器人:标签=@字符串/ APP_NAME>
<活动
机器人:HelloWorld的名字=
机器人:标签=@字符串/ APP_NAME>
&所述;意图滤光器>
<作用机器人:名字=android.intent.action.MAIN/><类机器人:名字=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT;
< /用途>< /清单>

LogCat中:

  11月3日至十七日:35:19.835:D / AndroidRuntime(562):关闭VM
11月3日至17日:35:19.835:W / dalvikvm(562):主题ID = 1:螺纹未捕获退出
异常(组= 0x409c01f8)
11月3日至17日:35:19.914:E / AndroidRuntime(562):致命异常:主要
11月3日至17日:35:19.914:E / AndroidRuntime(562):了java.lang.RuntimeException:无法
实例活动
ComponentInfo {lewes.android.hello / lewes.android.hello.HelloWorld}:
抛出java.lang.ClassNotFoundException:lewes.android.hello.HelloWorld
11月3日至17日:35:19.914:E / AndroidRuntime(562):在
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
11月3日至17日:35:19.914:E / AndroidRuntime(562):在
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
11月3日至17日:35:19.914:E / AndroidRuntime(562):在
android.app.ActivityThread.access $ 600(ActivityThread.java:123)
11月3日至17日:35:19.914:E / AndroidRuntime(562):在
android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1147)
11月3日至17日:35:19.914:E / AndroidRuntime(562):在
android.os.Handler.dispatchMessage(Handler.java:99)
11月3日至17日:35:19.914:E / AndroidRuntime(562):在android.os.Looper.loop(Looper.java:137)
11月3日至17日:35:19.914:E / AndroidRuntime(562):在
android.app.ActivityThread.main(ActivityThread.java:4424)
11月3日至17日:35:19.914:E / AndroidRuntime(562):在
java.lang.reflect.Method.invokeNative(本机方法)
11月3日至17日:35:19.914:E / AndroidRuntime(562):在
java.lang.reflect.Method.invoke(Method.java:511)
11月3日至17日:35:19.914:E / AndroidRuntime(562):在
com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:784)
11月3日至17日:35:19.914:E / AndroidRuntime(562):在
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
11月3日至17日:35:19.914:E / AndroidRuntime(562):在dalvik.system.NativeStart.main(母语
方法)
11月3日至17日:35:19.914:E / AndroidRuntime(562):产生的原因:
抛出java.lang.ClassNotFoundException:lewes.android.hello.HelloWorld
11月3日至17日:35:19.914:E / AndroidRuntime(562):在
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
11月3日至17日:35:19.914:E / AndroidRuntime(562):在
java.lang.ClassLoader.loadClass(ClassLoader.java:501)
11月3日至17日:35:19.914:E / AndroidRuntime(562):在
java.lang.ClassLoader.loadClass(ClassLoader.java:461)
11月3日至17日:35:19.914:E / AndroidRuntime(562):在
android.app.Instrumentation.newActivity(Instrumentation.java:1023)
11月3日至17日:35:19.914:E / AndroidRuntime(562):在
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
11月3日至17日:35:19.914:E / AndroidRuntime(562):11 ...更多
11月3日至17日:40:20.114:I /流程(562):发送信号。 PID:562 SIG:9


解决方案

删除从你的清单中的应用程序的部分之一。
保持那里的活动对应于您的类的名称之一。

让你的清单看起来完全像这样

 <?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=htt​​p://schemas.android.com/apk/res/android
包=lewes.android.hello
安卓版code =1
机器人:=的versionName1.0><采用-SDK安卓的minSdkVersion =15/><应用
机器人:图标=@绘制/ ic_launcher
机器人:标签=@字符串/ APP_NAME>
<活动
机器人:HelloAndroidNAME =
机器人:标签=@字符串/ APP_NAME>
&所述;意图滤光器>
    <作用机器人:名字=android.intent.action.MAIN/>    <类机器人:名字=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT;
< /用途>< /清单>

I've started to learn Android Development and I got this snippit off of google android development site, it keeps on crashing.

My specs are:

Android 4.0.3 API 15

Code:

package lewes.android.hello;

import android.app.Activity;
import android.os.Bundle;
import android.widget.TextView;

public class HelloAndroid extends Activity {
   /** Called when the activity is first created. */
   @Override
   public void onCreate(Bundle savedInstanceState) {
       super.onCreate(savedInstanceState);
       TextView tv = new TextView(this);
       tv.setText("Hello, Android");
       setContentView(tv);
   }
}

I get...

Unfortenualy, HelloAndroid is not responding.

Please help me!

MY MANIFEST:

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

<uses-sdk android:minSdkVersion="15" />

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".HelloWorld"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />

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

</manifest>

LogCat:

03-17 11:35:19.835: D/AndroidRuntime(562): Shutting down VM
03-17 11:35:19.835: W/dalvikvm(562): threadid=1: thread exiting with uncaught 
exception (group=0x409c01f8) 
03-17 11:35:19.914: E/AndroidRuntime(562): FATAL EXCEPTION: main
03-17 11:35:19.914: E/AndroidRuntime(562): java.lang.RuntimeException: Unable to 
instantiate activity 
ComponentInfo{lewes.android.hello/lewes.android.hello.HelloWorld}: 
java.lang.ClassNotFoundException: lewes.android.hello.HelloWorld
03-17 11:35:19.914: E/AndroidRuntime(562):  at 
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1880)
03-17 11:35:19.914: E/AndroidRuntime(562):  at 
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1981)
03-17 11:35:19.914: E/AndroidRuntime(562):  at 
android.app.ActivityThread.access$600(ActivityThread.java:123)
03-17 11:35:19.914: E/AndroidRuntime(562):  at  
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1147)
03-17 11:35:19.914: E/AndroidRuntime(562):  at 
android.os.Handler.dispatchMessage(Handler.java:99)
03-17 11:35:19.914: E/AndroidRuntime(562):  at android.os.Looper.loop(Looper.java:137)
03-17 11:35:19.914: E/AndroidRuntime(562):  at 
android.app.ActivityThread.main(ActivityThread.java:4424)
03-17 11:35:19.914: E/AndroidRuntime(562):  at 
java.lang.reflect.Method.invokeNative(Native Method)
03-17 11:35:19.914: E/AndroidRuntime(562):  at 
java.lang.reflect.Method.invoke(Method.java:511)
03-17 11:35:19.914: E/AndroidRuntime(562):  at 
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
03-17 11:35:19.914: E/AndroidRuntime(562):  at 
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
03-17 11:35:19.914: E/AndroidRuntime(562):  at dalvik.system.NativeStart.main(Native 
Method)
03-17 11:35:19.914: E/AndroidRuntime(562): Caused by: 
java.lang.ClassNotFoundException: lewes.android.hello.HelloWorld
03-17 11:35:19.914: E/AndroidRuntime(562):  at 
dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
03-17 11:35:19.914: E/AndroidRuntime(562):  at 
java.lang.ClassLoader.loadClass(ClassLoader.java:501)
03-17 11:35:19.914: E/AndroidRuntime(562):  at  
java.lang.ClassLoader.loadClass(ClassLoader.java:461)
03-17 11:35:19.914: E/AndroidRuntime(562):  at 
android.app.Instrumentation.newActivity(Instrumentation.java:1023)
03-17 11:35:19.914: E/AndroidRuntime(562):  at  
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1871)
03-17 11:35:19.914: E/AndroidRuntime(562):  ... 11 more
03-17 11:40:20.114: I/Process(562): Sending signal. PID: 562 SIG: 9

解决方案

Delete one of the application sections from your manifest. Keep the one where the activity corresponds to the name of your class.

make your manifest look exactly like this

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

<uses-sdk android:minSdkVersion="15" />

<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name" >
<activity
android:name=".HelloAndroid"
android:label="@string/app_name" >
<intent-filter>
    <action android:name="android.intent.action.MAIN" />

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

</manifest>

这篇关于我的Andr​​oid应用程序依然崩溃的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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