您好我正在尝试运行Android应用程序。我的目标是根据用户偏好显示雷达图,我使用了webview并将用户名发送到php文件。
但现在我收到一条错误,指出“java.lang.RuntimeException:无法实例化活动ComponentInfo {com.example.newairways / com.example.newairways.communication}:java.lang.ClassCastException:com .example.newairways.communication无法转换为android.app.Activity“ 我已经尽力解决了这个问题,但我能够做到。并且错误地说没有提到通信类所以我也提到但我需要显示雷达部分。所以请帮我解决这个问题。
这是我的logcat
08-04 19:59:21.861: D/gralloc_goldfish(654): Emulator without GPU emulation detected.
08-04 19:59:22.071: W/TextLayoutCache(654): computeValuesWithHarfbuzz -- need to force to single run
08-04 19:59:32.541: D/dalvikvm(654): GC_CONCURRENT freed 177K, 3% free 14296K/14599K, paused 7ms+7ms
08-04 19:59:36.962: W/TextLayoutCache(654): computeValuesWithHarfbuzz -- need to force to single run
08-04 19:59:45.762: W/SingleClientConnManager(654): Invalid use of SingleClientConnManager: connection still allocated.
08-04 19:59:45.762: W/SingleClientConnManager(654): Make sure to release the connection before allocating another one.
08-04 19:59:45.811: I/System.out(654): Response : User Found
08-04 19:59:45.811: I/System.out(654): ---IF---
08-04 19:59:46.682: D/dalvikvm(654): GC_CONCURRENT freed 214K, 3% free 14607K/14919K, paused 6ms+8ms
08-04 19:59:46.831: D/dalvikvm(654): GC_FOR_ALLOC freed 13K, 2% free 14946K/15239K, paused 52ms
08-04 19:59:50.781: D/AndroidRuntime(654): Shutting down VM
08-04 19:59:50.781: W/dalvikvm(654): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
08-04 19:59:50.831: E/AndroidRuntime(654): FATAL EXCEPTION: main
08-04 19:59:50.831: E/AndroidRuntime(654): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.newairways/com.example.newairways.communication}: java.lang.ClassCastException: com.example.newairways.communication cannot be cast to android.app.Activity
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1879)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.ActivityThread.access$600(ActivityThread.java:122)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.os.Handler.dispatchMessage(Handler.java:99)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.os.Looper.loop(Looper.java:137)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.ActivityThread.main(ActivityThread.java:4340)
08-04 19:59:50.831: E/AndroidRuntime(654): at java.lang.reflect.Method.invokeNative(Native Method)
08-04 19:59:50.831: E/AndroidRuntime(654): at java.lang.reflect.Method.invoke(Method.java:511)
08-04 19:59:50.831: E/AndroidRuntime(654): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-04 19:59:50.831: E/AndroidRuntime(654): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-04 19:59:50.831: E/AndroidRuntime(654): at dalvik.system.NativeStart.main(Native Method)
08-04 19:59:50.831: E/AndroidRuntime(654): Caused by: java.lang.ClassCastException: com.example.newairways.communication cannot be cast to android.app.Activity
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
08-04 19:59:50.831: E/AndroidRuntime(654): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
08-04 19:59:50.831: E/AndroidRuntime(654): ... 11 more
08-04 20:06:29.651: D/gralloc_goldfish(707): Emulator without GPU emulation detected.
08-04 20:06:29.802: W/TextLayoutCache(707): computeValuesWithHarfbuzz -- need to force to single run
08-04 20:06:35.271: D/dalvikvm(707): GC_CONCURRENT freed 133K, 2% free 14335K/14599K, paused 7ms+6ms
08-04 20:06:47.093: W/TextLayoutCache(707): computeValuesWithHarfbuzz -- need to force to single run
08-04 20:06:55.241: W/SingleClientConnManager(707): Invalid use of SingleClientConnManager: connection still allocated.
08-04 20:06:55.241: W/SingleClientConnManager(707): Make sure to release the connection before allocating another one.
08-04 20:06:55.352: D/dalvikvm(707): GC_CONCURRENT freed 298K, 3% free 14484K/14855K, paused 6ms+8ms
08-04 20:06:55.441: I/System.out(707): Response : User Found
08-04 20:06:55.512: I/System.out(707): ---IF---
08-04 20:06:56.211: D/dalvikvm(707): GC_FOR_ALLOC freed 70K, 3% free 14754K/15111K, paused 46ms
08-04 20:06:56.334: D/dalvikvm(707): GC_FOR_ALLOC freed 3K, 3% free 15023K/15367K, paused 50ms
08-04 20:07:00.851: D/AndroidRuntime(707): Shutting down VM
08-04 20:07:00.851: W/dalvikvm(707): threadid=1: thread exiting with uncaught exception (group=0x409961f8)
08-04 20:07:00.901: E/AndroidRuntime(707): FATAL EXCEPTION: main
08-04 20:07:00.901: E/AndroidRuntime(707): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.newairways/com.example.newairways.communication}: java.lang.ClassCastException: com.example.newairways.communication cannot be cast to android.app.Activity
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1879)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.ActivityThread.access$600(ActivityThread.java:122)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.os.Handler.dispatchMessage(Handler.java:99)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.os.Looper.loop(Looper.java:137)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.ActivityThread.main(ActivityThread.java:4340)
08-04 20:07:00.901: E/AndroidRuntime(707): at java.lang.reflect.Method.invokeNative(Native Method)
08-04 20:07:00.901: E/AndroidRuntime(707): at java.lang.reflect.Method.invoke(Method.java:511)
08-04 20:07:00.901: E/AndroidRuntime(707): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
08-04 20:07:00.901: E/AndroidRuntime(707): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
08-04 20:07:00.901: E/AndroidRuntime(707): at dalvik.system.NativeStart.main(Native Method)
08-04 20:07:00.901: E/AndroidRuntime(707): Caused by: java.lang.ClassCastException: com.example.newairways.communication cannot be cast to android.app.Activity
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.Instrumentation.newActivity(Instrumentation.java:1023)
08-04 20:07:00.901: E/AndroidRuntime(707): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1870)
08-04 20:07:00.901: E/AndroidRuntime(707): ... 11 more
这是我的宣言文件
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.newairways"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="14"
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.newairways.login"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.example.newairways.menu"
android:label="@string/app_name" >
</activity>s
<activity
android:name="com.example.newairways.bar"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.newairways.radar"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.newairways.measure"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.newairways.plan"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.newairways.day0"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.newairways.goaltest"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.newairways.relationship"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.newairways.start"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.newairways.discipline"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.newairways.skills"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.newairways.knowledge"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.newairways.emotions"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.newairways.adaptation"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.newairways.leadership"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.newairways.lifequality"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.newairways.Globalvars"
android:label="@string/app_name" >
</activity>
<activity
android:name="com.example.newairways.communication"
android:label="@string/app_name" >
</activity>
</application>
<uses-permission android:name="android.permission.INTERNET" />
</manifest>
答案 0 :(得分:0)
你的活动是否扩展了android.app.activity?是清单文件中提到的活动。基本包和活动类的完全限定名称是否正确?