我为Splash Unable to instantiate activity ComponentInfo java.lang.ClassNotFoundException
收到错误Activity
。在所有设备中都没有显示错误,这是我无法检查的原因。
我在我的项目中使用ActionBarSherLock
。
我也检查过Manifest。那里添加了Splash活动。
来自Play商店的Logcat:
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{test.mytestbuddy.IIM_CAT/test.mytestbuddy.IIM_CAT.Splash}: java.lang.ClassNotFoundException: test.mytestbuddy.IIM_CAT.Splash
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2108)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2211)
at android.app.ActivityThread.access$600(ActivityThread.java:149)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1300)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:153)
at android.app.ActivityThread.main(ActivityThread.java:4987)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:821)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:584)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: test.mytestbuddy.IIM_CAT.Splash
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.app.Instrumentation.newActivity(Instrumentation.java:1053)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2099)
检查属性的快照 - > Android和Java Build Path,如果有什么不对的话。但是我第一次只是从新版Android应用程序中得到了这个错误。
我已经从另一个不是当前Project的Project中将android-support-v4文件分配给ActionBarSherLock。当前的Project包含自己的android-support-v4.jar文件。
清单:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="test.mytestbuddy.IIM_CAT"
android:versionCode="7"
android:versionName="1.30" >
<uses-feature
android:name="android.hardware.telephony"
android:required="false" >
</uses-feature>
<permission
android:name="test.mytestbuddy.IIM_CAT.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="test.mytestbuddy.IIM_CAT.permission.C2D_MESSAGE" />
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MTBOfflineAppTheme" >
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="test.mytestbuddy.IIM_CAT" />
</intent-filter>
</receiver>
<service android:name="test.mytestbuddy.IIM_CAT.GCMIntentService" />
<activity
android:name="test.mytestbuddy.IIM_CAT.Splash"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
</application>
</manifest>
答案 0 :(得分:0)
像这样更改您的清单文件。
首先添加活动标签然后在注册接收器之后。
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="test.mytestbuddy.IIM_CAT"
android:versionCode="7"
android:versionName="1.30" >
<uses-feature
android:name="android.hardware.telephony"
android:required="false" >
</uses-feature>
<permission
android:name="test.mytestbuddy.IIM_CAT.permission.C2D_MESSAGE"
android:protectionLevel="signature" />
<uses-permission android:name="test.mytestbuddy.IIM_CAT.permission.C2D_MESSAGE" />
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="19" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/MTBOfflineAppTheme" >
<activity
android:name="test.mytestbuddy.IIM_CAT.Splash"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.NoTitleBar" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<receiver
android:name="com.google.android.gcm.GCMBroadcastReceiver"
android:permission="com.google.android.c2dm.permission.SEND" >
<intent-filter>
<action android:name="com.google.android.c2dm.intent.RECEIVE" />
<action android:name="com.google.android.c2dm.intent.REGISTRATION" />
<category android:name="test.mytestbuddy.IIM_CAT" />
</intent-filter>
</receiver>
<service android:name="test.mytestbuddy.IIM_CAT.GCMIntentService" />