该应用程序已停止意外〜 [英] The application has stopped unexpectedly ~
问题描述
所以我在之后的 http://www.androidhive.info/2011/10/android-login-and-registration-screen-design/ (在那一刻之前,我们得到的数据库实际上起来),我有一切放置在Eclipse中没有错误。是否有人可以看看我的code和告诉我什么导致应用程序意外停止?提前致谢!
LoginActivity.java
包com.example.loginactivity; 进口android.app.Activity;
进口android.content.Intent;
进口android.os.Bundle;
进口android.view.View;
进口android.widget.TextView;
公共类LoginActivity延伸活动{
@覆盖
公共无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
//设置默认的屏幕login.xml
的setContentView(com.example.loginactivity.R.layout.login);
TextView的registerScreen =(的TextView)findViewById(com.example.loginactivity.R.id.link_to_register); //倾听注册新帐户链接
registerScreen.setOnClickListener(新View.OnClickListener(){ 公共无效的onClick(视图v){
//切换到屏幕注册
意图I =新意图(getApplicationContext(),RegisterActivity.class);
startActivity(ⅰ);
}
});
}
}
Register.java
包com.example.loginactivity;
进口android.app.Activity;
进口android.os.Bundle;
进口android.view.View;
进口android.widget.TextView;
公共类RegisterActivity延伸活动{
@覆盖
公共无效的onCreate(捆绑savedInstanceState){
super.onCreate(savedInstanceState);
//设置视图register.xml
的setContentView(com.example.loginactivity.R.layout.register); TextView的loginScreen =(的TextView)findViewById(com.example.loginactivity.R.id.link_to_login); //倾听登录屏幕链接
loginScreen.setOnClickListener(新View.OnClickListener(){ 公共无效的onClick(查看为arg0){
//关闭注册画面
//切换到登录屏幕/关闭登记画面
完();
}
});
}
}
login.xml
<?XML版本=1.0编码=UTF-8&GT?;
<滚动型
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:fillViewport =真正的>
< RelativeLayout的
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT机器人:背景=#FFFFFF> <! - 头开始 - >
<的LinearLayout机器人:ID =@ + ID /头
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:背景=@布局/ header_gradient
机器人:paddingTop =5dip
机器人:paddingBottom会=5dip>
<! - 标识开始 - >
< ImageView的机器人:SRC =@绘制/ ic_launcher
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginLeft =10dip/>
<! - 标志完 - >
< / LinearLayout中>
<! - 标题结束 - >
&所述;! - 页脚开始 - >
<的LinearLayout机器人:ID =@ + ID /页脚
机器人:layout_width =FILL_PARENT
机器人:layout_height =90dip
机器人:背景=@布局/ footer_repeat
机器人:layout_alignParentBottom =真
机器人:方向=横向>
< / LinearLayout中>
<! - 页脚完 - > <! - 登录表单 - >
<的LinearLayout
机器人:方向=垂直
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:填充=10dip
机器人:layout_below =@ ID /头>
<! - 电子邮件标签 - >
<的TextView的android:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:文字颜色=#372c24
机器人:文字=电子邮件/>
< EditText上的android:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =5dip
机器人:layout_marginBottom =20dip
机器人:单线=真/>
<! - 密码标签 - >
<的TextView的android:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:文字颜色=#372c24
机器人:文字=密码/>
< EditText上的android:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =5dip
机器人:单线=真
机器人:密码=真/>
<! - 登录按钮 - >
<按钮机器人:ID =@ + ID / btnLogin
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =10dip
机器人:文字=登录/>
<! - 链接注册屏幕 - >
< TextView的机器人:ID =@ + ID / link_to_register
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =40dip
机器人:layout_marginBottom =40dip
机器人:文字=新来Twitter注册在这里?
机器人:比重=中心
机器人:TEXTSIZE =20dip
机器人:文字颜色=#0b84aa/> < / LinearLayout中>
<! - 登录表单完 - >
< / RelativeLayout的>
< /滚动型>
Register.xml
<?XML版本=1.0编码=UTF-8&GT?;
<滚动型
的xmlns:机器人=http://schemas.android.com/apk/res/android
机器人:layout_width =FILL_PARENT
机器人:layout_height =FILL_PARENT
机器人:fillViewport =真正的>
< RelativeLayout的
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT机器人:背景=#FFF> <! - 头开始 - >
<的LinearLayout机器人:ID =@ + ID /头
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:背景=@布局/ header_gradient
机器人:paddingTop =5dip
机器人:paddingBottom会=5dip>
<! - 标识开始 - >
< ImageView的机器人:SRC =@绘制/ ic_launcher
机器人:layout_width =WRAP_CONTENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginLeft =10dip/>
<! - 标志完 - >
< / LinearLayout中>
<! - 标题结束 - >
&所述;! - 页脚开始 - >
<的LinearLayout机器人:ID =@ + ID /页脚
机器人:layout_width =FILL_PARENT
机器人:layout_height =90dip
机器人:背景=@布局/ footer_repeat
机器人:layout_alignParentBottom =真
机器人:方向=横向>
< / LinearLayout中>
<! - 页脚完 - > <! - 报名表 - >
<的LinearLayout
机器人:方向=垂直
机器人:layout_width =match_parent
机器人:layout_height =WRAP_CONTENT
机器人:填充=10dip
机器人:layout_below =@ ID /头>
<! - 姓名标签 - >
<的TextView的android:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:文字颜色=#372c24
机器人:文字=全名/>
< EditText上机器人:ID =@ + ID / reg_fullname
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =5dip
机器人:单线=真
机器人:layout_marginBottom =20dip/>
<! - 电子邮件标签 - >
<的TextView的android:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:文字颜色=#372c24
机器人:文字=电子邮件/>
< EditText上机器人:ID =@ + ID / reg_email
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =5dip
机器人:单线=真
机器人:layout_marginBottom =20dip/>
<! - 密码标签 - >
<的TextView的android:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:文字颜色=#372c24
机器人:文字=密码/>
< EditText上机器人:ID =@ + ID / reg_password
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:密码=真
机器人:单线=真
机器人:layout_marginTop =5dip/>
<! - 注册按钮 - >
<按钮机器人:ID =@ + ID / btnRegister
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =10dip
机器人:文字=注册新帐户/>
<! - 链接登录屏幕 - >
< TextView的机器人:ID =@ + ID / link_to_login
机器人:layout_width =FILL_PARENT
机器人:layout_height =WRAP_CONTENT
机器人:layout_marginTop =40dip
机器人:layout_marginBottom =40dip
机器人:文字=已经有账号登入这里!
机器人:比重=中心
机器人:TEXTSIZE =20dip
机器人:文字颜色=#025f7c/> < / LinearLayout中>
<! - 报名表完 - >
< / RelativeLayout的>
< /滚动型>
下面是logcat的:
08-26 17:21:14.818:D / AndroidRuntime(17713):关闭VM
08-26 17:21:14.818:W / dalvikvm(17713):主题ID = 1:螺纹未捕获的异常(组= 0x4001d5a0)退出
08-26 17:21:14.818:E / AndroidRuntime(17713):致命异常:主要
08-26 17:21:14.818:E / AndroidRuntime(17713):了java.lang.RuntimeException:无法实例活动ComponentInfo {com.example.loginactivity / com.example.loginactivity.MainActivity}:抛出java.lang.ClassNotFoundException:COM .example.loginactivity.MainActivity装载机dalvik.system.PathClassLoader [/data/app/com.example.loginactivity-2.apk]
08-26 17:21:14.818:E / AndroidRuntime(17713):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1746)
08-26 17:21:14.818:E / AndroidRuntime(17713):在android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1854)
08-26 17:21:14.818:E / AndroidRuntime(17713):在android.app.ActivityThread.access $ 1500(ActivityThread.java:135)
08-26 17:21:14.818:E / AndroidRuntime(17713):在android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1041)
08-26 17:21:14.818:E / AndroidRuntime(17713):在android.os.Handler.dispatchMessage(Handler.java:99)
08-26 17:21:14.818:E / AndroidRuntime(17713):在android.os.Looper.loop(Looper.java:150)
08-26 17:21:14.818:E / AndroidRuntime(17713):在android.app.ActivityThread.main(ActivityThread.java:4333)
08-26 17:21:14.818:E / AndroidRuntime(17713):在java.lang.reflect.Method.invokeNative(本机方法)
08-26 17:21:14.818:E / AndroidRuntime(17713):在java.lang.reflect.Method.invoke(Method.java:507)
08-26 17:21:14.818:E / AndroidRuntime(17713):在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:839)
08-26 17:21:14.818:E / AndroidRuntime(17713):在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-26 17:21:14.818:E / AndroidRuntime(17713):在dalvik.system.NativeStart.main(本机方法)
08-26 17:21:14.818:E / AndroidRuntime(17713):抛出java.lang.ClassNotFoundException:致com.example.loginactivity.MainActivity装载机dalvik.system.PathClassLoader [/data/app/com.example.loginactivity -2.apk]
08-26 17:21:14.818:E / AndroidRuntime(17713):在dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
08-26 17:21:14.818:E / AndroidRuntime(17713):在java.lang.ClassLoader.loadClass(ClassLoader.java:551)
08-26 17:21:14.818:E / AndroidRuntime(17713):在java.lang.ClassLoader.loadClass(ClassLoader.java:511)
08-26 17:21:14.818:E / AndroidRuntime(17713):在android.app.Instrumentation.newActivity(Instrumentation.java:1040)
08-26 17:21:14.818:E / AndroidRuntime(17713):在android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1738)
08-26 17:21:14.818:E / AndroidRuntime(17713):... 11个
下面是AndroidManifest.xml中
<?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=http://schemas.android.com/apk/res/android
包=com.example.loginactivity
安卓版code =1
机器人:=的versionName1.0><用途-SDK
安卓的minSdkVersion =8
机器人:targetSdkVersion =17/><应用
机器人:allowBackup =真
机器人:图标=@绘制/ ic_launcher
机器人:标签=@字符串/ APP_NAME
机器人:主题=@风格/ AppTheme>
<活动
机器人:名字=com.example.loginactivity.MainActivity
机器人:标签=@字符串/ APP_NAME>
&所述;意图滤光器>
<作用机器人:名字=android.intent.action.MAIN/> <类机器人:名字=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT;
< /用途>
<应用机器人:图标=@绘制/ ic_launcher机器人:标签=@字符串/ APP_NAME>
<活动机器人:名字=。LoginActivity
机器人:标签=登录您的账户>
&所述;意图滤光器>
<作用机器人:名字=android.intent.action.MAIN/>
<类机器人:名字=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT; <! - 入境RegisterActivity.class - >
<活动机器人:名字=。RegisterActivity
机器人:标签=注册新帐号>< /活性GT;< /用途>
< /清单>
更新:
问题是,该活动在清单中不是注册
请在AndroidManifest.xml中添加活动。
当你想要做新的活动,你应该在你的AndroidManifest.xml中注册。
恩。
<活动
机器人:名字=x.x.x.Register
机器人:标签=@字符串/ APP_NAME>
&所述;意图滤光器>
<作用机器人:名字=android.intent.action.REGISTER/>
<类机器人:名字=android.intent.category.DEFAULT/>
&所述; /意图滤光器>
< /活性GT;
的manifest.xml
<?XML版本=1.0编码=UTF-8&GT?;
<清单的xmlns:机器人=http://schemas.android.com/apk/res/android
包=com.example.loginactivity
安卓版code =1
机器人:=的versionName1.0><用途-SDK
安卓的minSdkVersion =8
机器人:targetSdkVersion =17/> <应用
机器人:图标=@绘制/ ic_launcher
机器人:标签=@字符串/ APP_NAME
机器人:allowBackup =真
机器人:主题=@风格/ AppTheme> <活动机器人:名字=com.example.loginactivity.LoginActivity
机器人:标签=登录您的账户>
&所述;意图滤光器>
<作用机器人:名字=android.intent.action.MAIN/>
<类机器人:名字=android.intent.category.LAUNCHER/>
&所述; /意图滤光器>
< /活性GT; <活动
机器人:名字=com.example.loginactivity.RegisterActivity
机器人:标签=@字符串/ APP_NAME>
&所述;意图滤光器>
<作用机器人:名字=android.intent.action.REGISTERACTIVITY/>
<类机器人:名字=android.intent.category.DEFAULT/>
&所述; /意图滤光器>
< /活性GT;< /用途>
< /清单>
So I am following the user login and registration walkthrough at http://www.androidhive.info/2011/10/android-login-and-registration-screen-design/ (for at the moment before we get the database actually up) and I have everything in place with no errors in eclipse. Can someone please take a look at my code and tell me what's causing the app to stop unexpectedly? Thanks in advance! LoginActivity.java
package com.example.loginactivity;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class LoginActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// setting default screen to login.xml
setContentView(com.example.loginactivity.R.layout.login);
TextView registerScreen = (TextView) findViewById(com.example.loginactivity.R.id.link_to_register);
// Listening to register new account link
registerScreen.setOnClickListener(new View.OnClickListener() {
public void onClick(View v) {
// Switching to Register screen
Intent i = new Intent(getApplicationContext(), RegisterActivity.class);
startActivity(i);
}
});
}
}
Register.java
package com.example.loginactivity;
import android.app.Activity;
import android.os.Bundle;
import android.view.View;
import android.widget.TextView;
public class RegisterActivity extends Activity {
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
// Set View to register.xml
setContentView(com.example.loginactivity.R.layout.register);
TextView loginScreen = (TextView) findViewById(com.example.loginactivity.R.id.link_to_login);
// Listening to Login Screen link
loginScreen.setOnClickListener(new View.OnClickListener() {
public void onClick(View arg0) {
// Closing registration screen
// Switching to Login Screen/closing register screen
finish();
}
});
}
}
login.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="#ffffff">
<!-- Header Starts-->
<LinearLayout android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@layout/header_gradient"
android:paddingTop="5dip"
android:paddingBottom="5dip">
<!-- Logo Start-->
<ImageView android:src="@drawable/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"/>
<!-- Logo Ends -->
</LinearLayout>
<!-- Header Ends -->
<!-- Footer Start -->
<LinearLayout android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="90dip"
android:background="@layout/footer_repeat"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
</LinearLayout>
<!-- Footer Ends -->
<!-- Login Form -->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dip"
android:layout_below="@id/header">
<!-- Email Label -->
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#372c24"
android:text="Email"/>
<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:layout_marginBottom="20dip"
android:singleLine="true"/>
<!-- Password Label -->
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#372c24"
android:text="Password"/>
<EditText android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:singleLine="true"
android:password="true"/>
<!-- Login button -->
<Button android:id="@+id/btnLogin"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="Login"/>
<!-- Link to Registration Screen -->
<TextView android:id="@+id/link_to_register"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dip"
android:layout_marginBottom="40dip"
android:text="New to Twitter? Register here"
android:gravity="center"
android:textSize="20dip"
android:textColor="#0b84aa"/>
</LinearLayout>
<!-- Login Form Ends -->
</RelativeLayout>
</ScrollView>
Register.xml
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:fillViewport="true">
<RelativeLayout
android:layout_width="fill_parent"
android:layout_height="wrap_content" android:background="#fff">
<!-- Header Starts-->
<LinearLayout android:id="@+id/header"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@layout/header_gradient"
android:paddingTop="5dip"
android:paddingBottom="5dip">
<!-- Logo Start-->
<ImageView android:src="@drawable/ic_launcher"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="10dip"/>
<!-- Logo Ends -->
</LinearLayout>
<!-- Header Ends -->
<!-- Footer Start -->
<LinearLayout android:id="@+id/footer"
android:layout_width="fill_parent"
android:layout_height="90dip"
android:background="@layout/footer_repeat"
android:layout_alignParentBottom="true"
android:orientation="horizontal">
</LinearLayout>
<!-- Footer Ends -->
<!-- Registration Form -->
<LinearLayout
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dip"
android:layout_below="@id/header">
<!-- Full Name Label -->
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#372c24"
android:text="Full Name"/>
<EditText android:id="@+id/reg_fullname"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:singleLine="true"
android:layout_marginBottom="20dip"/>
<!-- Email Label -->
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#372c24"
android:text="Email"/>
<EditText android:id="@+id/reg_email"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="5dip"
android:singleLine="true"
android:layout_marginBottom="20dip"/>
<!-- Password Label -->
<TextView android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:textColor="#372c24"
android:text="Password"/>
<EditText android:id="@+id/reg_password"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:password="true"
android:singleLine="true"
android:layout_marginTop="5dip"/>
<!-- Register Button -->
<Button android:id="@+id/btnRegister"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="10dip"
android:text="Register New Account"/>
<!-- Link to Login Screen -->
<TextView android:id="@+id/link_to_login"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_marginTop="40dip"
android:layout_marginBottom="40dip"
android:text="Already has account! Login here"
android:gravity="center"
android:textSize="20dip"
android:textColor="#025f7c"/>
</LinearLayout>
<!-- Registration Form Ends -->
</RelativeLayout>
</ScrollView>
Here is the logcat:
08-26 17:21:14.818: D/AndroidRuntime(17713): Shutting down VM
08-26 17:21:14.818: W/dalvikvm(17713): threadid=1: thread exiting with uncaught exception (group=0x4001d5a0)
08-26 17:21:14.818: E/AndroidRuntime(17713): FATAL EXCEPTION: main
08-26 17:21:14.818: E/AndroidRuntime(17713): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.loginactivity/com.example.loginactivity.MainActivity}: java.lang.ClassNotFoundException: com.example.loginactivity.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.loginactivity-2.apk]
08-26 17:21:14.818: E/AndroidRuntime(17713): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1746)
08-26 17:21:14.818: E/AndroidRuntime(17713): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1854)
08-26 17:21:14.818: E/AndroidRuntime(17713): at android.app.ActivityThread.access$1500(ActivityThread.java:135)
08-26 17:21:14.818: E/AndroidRuntime(17713): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1041)
08-26 17:21:14.818: E/AndroidRuntime(17713): at android.os.Handler.dispatchMessage(Handler.java:99)
08-26 17:21:14.818: E/AndroidRuntime(17713): at android.os.Looper.loop(Looper.java:150)
08-26 17:21:14.818: E/AndroidRuntime(17713): at android.app.ActivityThread.main(ActivityThread.java:4333)
08-26 17:21:14.818: E/AndroidRuntime(17713): at java.lang.reflect.Method.invokeNative(Native Method)
08-26 17:21:14.818: E/AndroidRuntime(17713): at java.lang.reflect.Method.invoke(Method.java:507)
08-26 17:21:14.818: E/AndroidRuntime(17713): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
08-26 17:21:14.818: E/AndroidRuntime(17713): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
08-26 17:21:14.818: E/AndroidRuntime(17713): at dalvik.system.NativeStart.main(Native Method)
08-26 17:21:14.818: E/AndroidRuntime(17713): Caused by: java.lang.ClassNotFoundException: com.example.loginactivity.MainActivity in loader dalvik.system.PathClassLoader[/data/app/com.example.loginactivity-2.apk]
08-26 17:21:14.818: E/AndroidRuntime(17713): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
08-26 17:21:14.818: E/AndroidRuntime(17713): at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
08-26 17:21:14.818: E/AndroidRuntime(17713): at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
08-26 17:21:14.818: E/AndroidRuntime(17713): at android.app.Instrumentation.newActivity(Instrumentation.java:1040)
08-26 17:21:14.818: E/AndroidRuntime(17713): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1738)
08-26 17:21:14.818: E/AndroidRuntime(17713): ... 11 more
Here is the AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.loginactivity"
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="com.example.loginactivity.MainActivity"
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>
<application android:icon="@drawable/ic_launcher" android:label="@string/app_name">
<activity android:name=".LoginActivity"
android:label="Login to your Account">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<!-- Entry for RegisterActivity.class -->
<activity android:name=".RegisterActivity"
android:label="Register New Account"></activity>
</application>
</manifest>
update:
the problem is that the activity is not registered in the manifest.
Please add your Activity in your AndroidManifest.xml.
When you want to making new activity, you should register it in your AndroidManifest.xml.
ex.
<activity
android:name="x.x.x.Register"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.REGISTER" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.loginactivity"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:allowBackup="true"
android:theme="@style/AppTheme" >
<activity android:name="com.example.loginactivity.LoginActivity"
android:label="Login to your Account">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.loginactivity.RegisterActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.REGISTERACTIVITY" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
</application>
</manifest>
这篇关于该应用程序已停止意外〜的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!