关于unfortunately has stopped的问题

hou0201_ 2015-10-16 10:58:01
logcat日志猫:
10-15 22:53:02.319: E/AndroidRuntime(2974): FATAL EXCEPTION: main
10-15 22:53:02.319: E/AndroidRuntime(2974): Process: com.itheima.qq, PID: 2974
10-15 22:53:02.319: E/AndroidRuntime(2974): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.itheima.qq/qq.MainActivity}: java.lang.ClassNotFoundException: Didn't find class "qq.MainActivity" on path: DexPathList[[zip file "/data/app/com.itheima.qq-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.itheima.qq-1, /system/lib]]
10-15 22:53:02.319: E/AndroidRuntime(2974): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2121)
10-15 22:53:02.319: E/AndroidRuntime(2974): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
10-15 22:53:02.319: E/AndroidRuntime(2974): at android.app.ActivityThread.access$800(ActivityThread.java:135)
10-15 22:53:02.319: E/AndroidRuntime(2974): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
10-15 22:53:02.319: E/AndroidRuntime(2974): at android.os.Handler.dispatchMessage(Handler.java:102)
10-15 22:53:02.319: E/AndroidRuntime(2974): at android.os.Looper.loop(Looper.java:136)
10-15 22:53:02.319: E/AndroidRuntime(2974): at android.app.ActivityThread.main(ActivityThread.java:5017)
10-15 22:53:02.319: E/AndroidRuntime(2974): at java.lang.reflect.Method.invokeNative(Native Method)
10-15 22:53:02.319: E/AndroidRuntime(2974): at java.lang.reflect.Method.invoke(Method.java:515)
10-15 22:53:02.319: E/AndroidRuntime(2974): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
10-15 22:53:02.319: E/AndroidRuntime(2974): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
10-15 22:53:02.319: E/AndroidRuntime(2974): at dalvik.system.NativeStart.main(Native Method)
10-15 22:53:02.319: E/AndroidRuntime(2974): Caused by: java.lang.ClassNotFoundException: Didn't find class "qq.MainActivity" on path: DexPathList[[zip file "/data/app/com.itheima.qq-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.itheima.qq-1, /system/lib]]
10-15 22:53:02.319: E/AndroidRuntime(2974): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
10-15 22:53:02.319: E/AndroidRuntime(2974): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
10-15 22:53:02.319: E/AndroidRuntime(2974): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
10-15 22:53:02.319: E/AndroidRuntime(2974): at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
10-15 22:53:02.319: E/AndroidRuntime(2974): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2112)
10-15 22:53:02.319: E/AndroidRuntime(2974): ... 11 more
...全文
1241 3 打赏 收藏 转发到动态 举报
写回复
用AI写文章
3 条回复
切换为时间正序
请发表友善的回复…
发表回复
hou0201_ 2015-10-16
  • 打赏
  • 举报
回复
代码: [code=java][/package com.itheima.qq; import java.io.BufferedReader; import java.io.File; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; import android.app.Activity; import android.os.Bundle; import android.support.v7.app.ActionBarActivity; import android.view.View; import android.view.Window; import android.widget.CheckBox; import android.widget.EditText; import android.widget.Toast; public class MainActivity extends Activity{ // 初始化成员变量,保证以下所有方法中都能得到调用 private EditText et_name; private EditText et_pass; @Override // 相当于主函数,所有方法的执行调用的入口 protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); /*//在活动中隐藏标题栏,这句话一定要写在setContentView()之前执行,否则会报错 requestWindowFeature(Window.FEATURE_NO_TITLE);*/ //调用setOntentView()方法,给当前活动加载一个布局 setContentView(R.layout.fragment_main); // 获取用户名和密码 et_name = (EditText) findViewById(R.id.et_name); et_pass = (EditText) findViewById(R.id.et_pass); // 调用readAccount()方法 readAccount(); } /* * BufferedReader:从字符输入流中读取文本,缓冲各个字符,从而实现字符、数组和行的高效读取。 BufferedReader in= * new BufferedReader(new FileReader("foo.in")); * InputStreamReader:是字节流通向字符流的桥梁:它使用指定的 charset 读取字节并将其解码为字 * 符。它使用的字符集可以由名称指定或显式给定,或者可以接受平台默认的字符集。 BufferedReader in = new * BufferedReader(new InputStreamReader(System.in)); * FileInputStream:从文件系统中的某个文件中获得输入字节。哪些文件可用取决于主机环境。 * FileInputStream:用于读取诸如图像数据之类的原始字节流。要读取字符流,请考虑使用 FileReader。 */ public void readAccount() {// 定义一个读取数据的方法 // 返回File类对象 File file = new File(getCacheDir(), "info.txt"); // 判断目录文件是否存在 if (file.exists()) { // 初始化输入流对象 FileInputStream in = null; try { // 读取文件内容(创建输入流对象) in = new FileInputStream(file); // 把字节流转换成字符流,并且从字符输入流中读取文本,缓冲各个字符 /* * InputStreamReader isr = new InputStreamReader(in); * BufferedReader br = new BufferedReader(isr); */ BufferedReader br = new BufferedReader( new InputStreamReader(in)); // 读取txt文件中的内容 String text = null; try { text = br.readLine(); // 以"###"分割字符串得到用户名和密码的String[]数组 String[] str = text.split("###"); // 用户名和密码对象对数组进行调用获取用户输入的数据(设置用户数据显示到App显示框) et_name.setText(str[0]); et_pass.setText(str[1]); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (FileNotFoundException e) { e.printStackTrace(); } finally { // 关闭流对象 try { in.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } } } public void onClick(View v) { // 获取字符串类型的用户名和密码;getText()获取文字的方法 String name = et_name.getText().toString(); String pass = et_pass.getText().toString(); // 通过找ID创建CheckBox的对象 CheckBox cb = (CheckBox) findViewById(R.id.cb); // 判断是否被勾选.isCheck()方法 if (cb.isChecked()) { // 返回一个File对象,其路径为:new File(getCacheDir(), "info.txt") File file = new File(getCacheDir(), "info.txt"); // 初始化输出流对象 FileOutputStream out = null; try { out = new FileOutputStream(file); try { // 向文件中写入用户输入的用户名和密码,write(byte[] // b),使用getbytes()方法将字符串转换成直接数组 out.write((name + "###" + pass).getBytes()); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } finally { // 关闭流对象 try { out.close(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } } // 创建并显示土司对话框 Toast.makeText(this, "登录成功", 0).show(); } } } code]
hou0201_ 2015-10-16
  • 打赏
  • 举报
回复
代码XML文件: [code=html][/<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context="com.itheima.qq.MainActivity$PlaceholderFragment" > <EditText android:id="@+id/et_name" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/yh" android:textColor="#ff33b5e5" /> <EditText android:id="@+id/et_pass" android:layout_width="match_parent" android:layout_height="wrap_content" android:hint="@string/ps" android:textColor="#ff33b5e5" android:inputType="textPassword"/> <RelativeLayout android:layout_width="match_parent" android:layout_height="wrap_content" > <CheckBox android:id="@+id/cb" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/us" android:layout_centerVertical="true" /> <Button android:id="@+id/bt" android:layout_width="wrap_content" android:layout_height="wrap_content" android:text="@string/dl" android:layout_alignParentRight="true" android:onClick="login" /> </RelativeLayout> </LinearLayout>code]
hou0201_ 2015-10-16
  • 打赏
  • 举报
回复
配置信息
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.itheima.qq"
    android:versionCode="1"
    android:versionName="1.0" >

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

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.itheima.qq.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>

</manifest>

566

社区成员

发帖
与我相关
我的任务
社区描述
英特尔® 边缘计算,聚焦于边缘计算、AI、IoT等领域,为开发者提供丰富的开发资源、创新技术、解决方案与行业活动。
社区管理员
  • 英特尔技术社区
  • shere_lin
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧