SherlockActivity から継承するたびにアプリケーションがクラッシュするのはなぜですか? それはおそらくばかげた間違いですが、私は本当にそれを理解することはできません! Activity から継承するだけで機能します。コード、レイアウト ファイル、マニフェスト、logcat ログは次のとおりです。
package com.p4p.joinme;
import android.os.Bundle;
import com.actionbarsherlock.app.SherlockActivity;
public class MainActivity extends SherlockActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
レイアウト ファイル:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical" >
<TextView
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:text="I'm a textview." />
</LinearLayout>
マニフェスト:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.p4p.joinme"
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=".MainActivity"
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>
エラーログ:
06-07 12:03:22.613: E/ExternalAccountType(21992): Unsupported attribute readOnly
06-07 12:03:23.244: E/ExternalAccountType(21992): Unsupported attribute readOnly
06-07 12:03:25.316: E/AndroidRuntime(9285): FATAL EXCEPTION: main
06-07 12:03:25.316: E/AndroidRuntime(9285): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.p4p.joinme/com.p4p.joinme.MainActivity}: java.lang.ClassNotFoundException: com.p4p.joinme.MainActivity
06-07 12:03:25.316: E/AndroidRuntime(9285): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
06-07 12:03:25.316: E/AndroidRuntime(9285): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2229)
06-07 12:03:25.316: E/AndroidRuntime(9285): at android.app.ActivityThread.access$600(ActivityThread.java:139)
06-07 12:03:25.316: E/AndroidRuntime(9285): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1261)
06-07 12:03:25.316: E/AndroidRuntime(9285): at android.os.Handler.dispatchMessage(Handler.java:99)
06-07 12:03:25.316: E/AndroidRuntime(9285): at android.os.Looper.loop(Looper.java:154)
06-07 12:03:25.316: E/AndroidRuntime(9285): at android.app.ActivityThread.main(ActivityThread.java:4945)
06-07 12:03:25.316: E/AndroidRuntime(9285): at java.lang.reflect.Method.invokeNative(Native Method)
06-07 12:03:25.316: E/AndroidRuntime(9285): at java.lang.reflect.Method.invoke(Method.java:511)
06-07 12:03:25.316: E/AndroidRuntime(9285): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-07 12:03:25.316: E/AndroidRuntime(9285): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-07 12:03:25.316: E/AndroidRuntime(9285): at dalvik.system.NativeStart.main(Native Method)
06-07 12:03:25.316: E/AndroidRuntime(9285): Caused by: java.lang.ClassNotFoundException: com.p4p.joinme.MainActivity
06-07 12:03:25.316: E/AndroidRuntime(9285): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-07 12:03:25.316: E/AndroidRuntime(9285): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-07 12:03:25.316: E/AndroidRuntime(9285): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-07 12:03:25.316: E/AndroidRuntime(9285): at android.app.Instrumentation.newActivity(Instrumentation.java:1039)
06-07 12:03:25.316: E/AndroidRuntime(9285): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2101)
06-07 12:03:25.316: E/AndroidRuntime(9285): ... 11 more
06-07 12:03:25.326: E/EmbeddedLogger(239): App crashed! Process: com.p4p.joinme
06-07 12:03:25.326: E/EmbeddedLogger(239): App crashed! Package: com.p4p.joinme v1 (1.0)
06-07 12:03:25.326: E/EmbeddedLogger(239): Application Label: JoinMe!
06-07 12:07:33.959: E/ExternalAccountType(21992): Unsupported attribute readOnly
06-07 12:07:34.299: E/ExternalAccountType(21992): Unsupported attribute readOnly
06-07 12:07:37.452: E/EmbeddedLogger(239): App crashed! Process: com.p4p.joinme
06-07 12:07:37.452: E/EmbeddedLogger(239): App crashed! Package: com.p4p.joinme v1 (1.0)
06-07 12:07:37.452: E/AndroidRuntime(9610): FATAL EXCEPTION: main
06-07 12:07:37.452: E/AndroidRuntime(9610): java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.p4p.joinme/com.p4p.joinme.MainActivity}: java.lang.ClassNotFoundException: com.p4p.joinme.MainActivity
06-07 12:07:37.452: E/AndroidRuntime(9610): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2110)
06-07 12:07:37.452: E/AndroidRuntime(9610): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2229)
06-07 12:07:37.452: E/AndroidRuntime(9610): at android.app.ActivityThread.access$600(ActivityThread.java:139)
06-07 12:07:37.452: E/AndroidRuntime(9610): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1261)
06-07 12:07:37.452: E/AndroidRuntime(9610): at android.os.Handler.dispatchMessage(Handler.java:99)
06-07 12:07:37.452: E/AndroidRuntime(9610): at android.os.Looper.loop(Looper.java:154)
06-07 12:07:37.452: E/AndroidRuntime(9610): at android.app.ActivityThread.main(ActivityThread.java:4945)
06-07 12:07:37.452: E/AndroidRuntime(9610): at java.lang.reflect.Method.invokeNative(Native Method)
06-07 12:07:37.452: E/AndroidRuntime(9610): at java.lang.reflect.Method.invoke(Method.java:511)
06-07 12:07:37.452: E/AndroidRuntime(9610): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
06-07 12:07:37.452: E/AndroidRuntime(9610): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
06-07 12:07:37.452: E/AndroidRuntime(9610): at dalvik.system.NativeStart.main(Native Method)
06-07 12:07:37.452: E/AndroidRuntime(9610): Caused by: java.lang.ClassNotFoundException: com.p4p.joinme.MainActivity
06-07 12:07:37.452: E/AndroidRuntime(9610): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
06-07 12:07:37.452: E/AndroidRuntime(9610): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
06-07 12:07:37.452: E/AndroidRuntime(9610): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
06-07 12:07:37.452: E/AndroidRuntime(9610): at android.app.Instrumentation.newActivity(Instrumentation.java:1039)
06-07 12:07:37.452: E/AndroidRuntime(9610): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2101)
06-07 12:07:37.452: E/AndroidRuntime(9610): ... 11 more
06-07 12:07:37.472: E/EmbeddedLogger(239): Application Label: JoinMe!
06-07 12:07:38.933: E/ActivityManager(239): fail to set top app changed!