在我正在使用的Eclipse上,构建我的应用程序没有任何问题。在另一台机器上,我收到此错误。
08-24 15:31:57.426: E/AndroidRuntime(8510): FATAL EXCEPTION: main
08-24 15:31:57.426: E/AndroidRuntime(8510): Process: com.wdi.wdigateway, PID: 8510
08-24 15:31:57.426: E/AndroidRuntime(8510): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.wdi.wdigateway/com.wdi.wdiandroid.LoginActivity}: java.lang.ClassNotFoundException: Didn't find class "com.wdi.wdiandroid.LoginActivity" on path: DexPathList[[zip file "/data/app/com.wdi.wdigateway-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.wdi.wdigateway-2, /vendor/lib, /system/lib]]
08-24 15:31:57.426: E/AndroidRuntime(8510): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2124)
08-24 15:31:57.426: E/AndroidRuntime(8510): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2257)
08-24 15:31:57.426: E/AndroidRuntime(8510): at android.app.ActivityThread.access$800(ActivityThread.java:139)
08-24 15:31:57.426: E/AndroidRuntime(8510): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1210)
08-24 15:31:57.426: E/AndroidRuntime(8510): at android.os.Handler.dispatchMessage(Handler.java:102)
08-24 15:31:57.426: E/AndroidRuntime(8510): at android.os.Looper.loop(Looper.java:136)
08-24 15:31:57.426: E/AndroidRuntime(8510): at android.app.ActivityThread.main(ActivityThread.java:5086)
08-24 15:31:57.426: E/AndroidRuntime(8510): at java.lang.reflect.Method.invokeNative(Native Method)
08-24 15:31:57.426: E/AndroidRuntime(8510): at java.lang.reflect.Method.invoke(Method.java:515)
08-24 15:31:57.426: E/AndroidRuntime(8510): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
08-24 15:31:57.426: E/AndroidRuntime(8510): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
08-24 15:31:57.426: E/AndroidRuntime(8510): at dalvik.system.NativeStart.main(Native Method)
08-24 15:31:57.426: E/AndroidRuntime(8510): Caused by: java.lang.ClassNotFoundException: Didn't find class "com.wdi.wdiandroid.LoginActivity" on path: DexPathList[[zip file "/data/app/com.wdi.wdigateway-2.apk"],nativeLibraryDirectories=[/data/app-lib/com.wdi.wdigateway-2, /vendor/lib, /system/lib]]
08-24 15:31:57.426: E/AndroidRuntime(8510): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
08-24 15:31:57.426: E/AndroidRuntime(8510): at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
08-24 15:31:57.426: E/AndroidRuntime(8510): at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
08-24 15:31:57.426: E/AndroidRuntime(8510): at android.app.Instrumentation.newActivity(Instrumentation.java:1084)
08-24 15:31:57.426: E/AndroidRuntime(8510): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2115)
08-24 15:31:57.426: E/AndroidRuntime(8510): ... 11 more
我四处寻找答案,但他们都涉及在AndroidManifest中声明活动,但我已经宣布了我的所有活动。
的AndroidManifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.wdi.wdigateway"
android:screenOrientation="portrait"
android:versionCode="1"
android:versionName="1.0" >
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-sdk
android:minSdkVersion="16"
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.wdi.wdiandroid.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait" >
</activity>
<activity
android:name="com.wdi.wdiandroid.setup.SetupGatewayActivity"
android:label="@string/title_activity_setup_gateway" >
<!-- android:parentActivityName="com.wdi.wdigateway.MainActivity" > -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.wdi.wdigateway.MainActivity" />
</activity>
<activity
android:name="com.wdi.wdiandroid.setup.SelectGateway"
android:label="@string/title_activity_select_gateway" >
</activity>
<activity
android:name="com.wdi.wdiandroid.registration.RegistrationActivity"
android:label="@string/title_activity_registration" >
</activity>
<activity
android:name="com.wdi.wdiandroid.test.CommunicationActivity"
android:label="@string/title_activity_customize_gateway" >
</activity>
<activity
android:name="com.wdi.wdiandroid.setup.CustomizeGatewayActivity"
android:label="@string/title_activity_customize_gateway" >
</activity>
<activity
android:name=".FinishActivity"
android:label="@string/title_activity_finish" >
</activity>
<activity
android:name=".TestActivity"
android:label="@string/title_activity_test" >
</activity>
<activity
android:name="com.wdi.wdiandroid.setup.EditDetailActivity"
android:label="@string/title_activity_change_detail" >
</activity>
<service
android:name="com.wdi.wdiandroid.notification.NotificationReceiver"
android:enabled="true" />
<activity
android:name="com.wdi.wdiandroid.notification.NotificationActivity"
android:label="@string/title_activity_notification" >
</activity>
<activity
android:name="com.wdi.wdiandroid.LoginActivity"
android:label="@string/login" >
<intent-filter android:label="@string/app_name" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.wdi.wdiandroid.videoplayer.StreamActivity"></activity>
</application>
</manifest>
答案 0 :(得分:0)
错误表明您在项目中使用的类尚未在清单中正确声明!
步骤1)仔细检查清单中的声明!
步骤2)清理并运行项目
Try this Code
强>
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE" />
<uses-permission android:name="android.permission.CHANGE_WIFI_MULTICAST_STATE" />
<uses-sdk
android:minSdkVersion="16"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden" >
</activity>
<activity
android:name=".SetupGatewayActivity"
android:label="@string/title_activity_setup_gateway"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden" >
<!-- android:parentActivityName="com.wdi.wdigateway.MainActivity" > -->
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.wdi.wdigateway.MainActivity" />
</activity>
<activity
android:name=".SelectGateway"
android:label="@string/title_activity_select_gateway"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden" >
</activity>
<activity
android:name=".RegistrationActivity"
android:label="@string/title_activity_registration"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden" >
</activity>
<activity
android:name=".CommunicationActivity"
android:label="@string/title_activity_customize_gateway"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden" >
</activity>
<activity
android:name=".CustomizeGatewayActivity"
android:label="@string/title_activity_customize_gateway"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden" >
</activity>
<activity
android:name=".FinishActivity"
android:label="@string/title_activity_finish"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden" >
</activity>
<activity
android:name=".TestActivity"
android:label="@string/title_activity_test"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden" >
</activity>
<activity
android:name=".EditDetailActivity"
android:label="@string/title_activity_change_detail"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden" >
</activity>
<service
android:name=".NotificationReceiver"
android:enabled="true" />
<activity
android:name=".NotificationActivity"
android:label="@string/title_activity_notification"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden" >
</activity>
<activity
android:name=".LoginActivity"
android:label="@string/login"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden" >
<intent-filter android:label="@string/app_name" >
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".StreamActivity"
android:screenOrientation="portrait"
android:configChanges="orientation|keyboardHidden">
</activity>
</application>