Hello stackoverflow社区,
我是Android编程的新手。我创建的应用程序“加密”始终在模拟器上崩溃,并显示消息“不幸的是,加密已停止”。我正在学习本教程:https://www.sites.google.com/site/mobilesecuritylabware/3-data-location-privacy/lab-activity/cryptography/cryptography-mobile-labs/encryption-decryption/2-lab-activity/lab1。任何人都可以帮我弄清楚什么是错的吗? 非常感谢!
详细说明:
Mac OS X 10.7.5,
Eclipse SDK
版本:4.2.2
构建ID:M20130204-1200
EncryptActivity.java代码位于上面给出的链接上
应用程序名称:加密
活动:加密活动
包名:Android.Encrypt
这是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
以下是清单信息:
<?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>
答案 0 :(得分:1)
问题是你在android:name
中指定了相对类名活动,并且android会将该名称附加到你指定的名称,然后android得到Android.Encrypt.Android.Encrypt.EncryptActivity
而不是Android.Encrypt.EncryptActivity {{ 1}}。活动元素中的Android.Encrypt.EncryptActivity`。