简体   繁体   中英

Eclipse android app crashes when launch on emulator

Hello stackoverflow community,

I'm new to android programming. The app I create,"Encrypt", always crashes on the emulator with the message " Unfortunately, Encrypt has stopped". I'm following this tutorial: https://www.sites.google.com/site/mobilesecuritylabware/3-data-location-privacy/lab-activity/cryptography/cryptography-mobile-labs/encryption-decryption/2-lab-activity/lab1 . Can anyone help me figure out what's wrong?
Thanks a lot!

Details:
Mac OS X 10.7.5, Eclipse SDK Version: 4.2.2 Build id: M20130204-1200

The EncryptActivity.java code is on the link given above.
Application name: Encrypt
Activity: EncryptActivity
Package name: Android.Encrypt

This is the logcat :

10-28 11:21:58.583: D/AndroidRuntime(1257): Shutting down VM
10-28 11:21:58.583: W/dalvikvm(1257): threadid=1: thread exiting with uncaught exception (group=0x414c4700)
10-28 11:21:58.603: E/AndroidRuntime(1257): FATAL EXCEPTION: main
10-28 11:21:58.603: E/AndroidRuntime(1257): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{Android.Encrypt/Android.Encrypt.Android.Encrypt.EncryptActivity}: java.lang.ClassNotFoundException: Didn't find class "Android.Encrypt.Android.Encrypt.EncryptActivity" on path: DexPathList[[zip file "/data/app/Android.Encrypt-2.apk"],nativeLibraryDirectories=[/data/app-lib/Android.Encrypt-2, /system/lib]]
10-28 11:21:58.603: E/AndroidRuntime(1257):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2137)
10-28 11:21:58.603: E/AndroidRuntime(1257):     at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
10-28 11:21:58.603: E/AndroidRuntime(1257):     at android.app.ActivityThread.access$600(ActivityThread.java:141)
10-28 11:21:58.603: E/AndroidRuntime(1257):     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
10-28 11:21:58.603: E/AndroidRuntime(1257):     at android.os.Handler.dispatchMessage(Handler.java:99)
10-28 11:21:58.603: E/AndroidRuntime(1257):     at android.os.Looper.loop(Looper.java:137)
10-28 11:21:58.603: E/AndroidRuntime(1257):     at android.app.ActivityThread.main(ActivityThread.java:5103)
10-28 11:21:58.603: E/AndroidRuntime(1257):     at java.lang.reflect.Method.invokeNative(Native Method)
10-28 11:21:58.603: E/AndroidRuntime(1257):     at java.lang.reflect.Method.invoke(Method.java:525)
10-28 11:21:58.603: E/AndroidRuntime(1257):     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
10-28 11:21:58.603: E/AndroidRuntime(1257):     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
10-28 11:21:58.603: E/AndroidRuntime(1257):     at dalvik.system.NativeStart.main(Native Method)
10-28 11:21:58.603: E/AndroidRuntime(1257): Caused by: java.lang.ClassNotFoundException: Didn't find class "Android.Encrypt.Android.Encrypt.EncryptActivity" on path: DexPathList[[zip file "/data/app/Android.Encrypt-2.apk"],nativeLibraryDirectories=[/data/app-lib/Android.Encrypt-2, /system/lib]]
10-28 11:21:58.603: E/AndroidRuntime(1257):     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:53)
10-28 11:21:58.603: E/AndroidRuntime(1257):     at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
10-28 11:21:58.603: E/AndroidRuntime(1257):     at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
10-28 11:21:58.603: E/AndroidRuntime(1257):     at android.app.Instrumentation.newActivity(Instrumentation.java:1061)
10-28 11:21:58.603: E/AndroidRuntime(1257):     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2128)
10-28 11:21:58.603: E/AndroidRuntime(1257):     ... 11 more

Here is the Manifest info :

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

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

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

问题是您正在android:name相对的类名称活动,而android会将名称附加到您指定的名称中,然后android得到了Android.Encrypt.Android.Encrypt.EncryptActivity而不是Android.Encrypt.EncryptActivity, just remove the dot of活动元素just remove the dot of .Android.Encrypt.EncryptActivity`的just remove the dot of

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM