HoloEverywhere を使ったアプリを作りたいです。このマニュアルで説明されているように、HoloEverywhere と ActionBarSherlock をインポートします。
主な活動:
import org.holoeverywhere.app.*;
import android.os.Bundle;
public class MainActivity extends Activity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
AndroidManifest.xml:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.myapp"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="17" />
<application android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/Holo.Theme"
android:allowBackup="true">
<activity
android:name="com.myapp.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>
org.holoeverywhere.addon.IAddonBasicAttacher.inhert:
public void inhert(Collection<Class<? extends IAddon>> sourceClasses) {
List<Class<? extends IAddon>> classes = new ArrayList<Class<? extends IAddon>>();
for (Class<? extends IAddon> clazz : sourceClasses) {
if (!clazz.isAnnotationPresent(Addon.class)) {
continue;
}
Addon addon = clazz.getAnnotation(Addon.class);
if (addon.inhert()) {
classes.add(clazz);
}
}
addon(classes);
}
public void inhert(IAddonAttacher<?> attacher) {
inhert(attacher.obtainAddonsList());
}
アプリを実行したいときに、Eclipse で次のエラーが発生しました。
05-15 23:26:48.132: E/AndroidRuntime(16934): FATAL EXCEPTION: main
05-15 23:26:48.132: E/AndroidRuntime(16934):
java.lang.RuntimeException: Unable to start activity
ComponentInfo{com.myapp/com.myapp.MainActivity}:
java.lang.NullPointerException 05-15 23:26:48.132:
E/AndroidRuntime(16934): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2059)
05-15 23:26:48.132: E/AndroidRuntime(16934): at
android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2084)
05-15 23:26:48.132: E/AndroidRuntime(16934): at
android.app.ActivityThread.access$600(ActivityThread.java:130) 05-15
23:26:48.132: E/AndroidRuntime(16934): at
android.app.ActivityThread$H.handleMessage(ActivityThread.java:1195)
05-15 23:26:48.132: E/AndroidRuntime(16934): at
android.os.Handler.dispatchMessage(Handler.java:99) 05-15
23:26:48.132: E/AndroidRuntime(16934): at
android.os.Looper.loop(Looper.java:137) 05-15 23:26:48.132:
E/AndroidRuntime(16934): at
android.app.ActivityThread.main(ActivityThread.java:4745) 05-15
23:26:48.132: E/AndroidRuntime(16934): at
java.lang.reflect.Method.invokeNative(Native Method) 05-15
23:26:48.132: E/AndroidRuntime(16934): at
java.lang.reflect.Method.invoke(Method.java:511) 05-15 23:26:48.132:
E/AndroidRuntime(16934): at
com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
05-15 23:26:48.132: E/AndroidRuntime(16934): at
com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553) 05-15
23:26:48.132: E/AndroidRuntime(16934): at
dalvik.system.NativeStart.main(Native Method) 05-15 23:26:48.132:
E/AndroidRuntime(16934): Caused by: java.lang.NullPointerException
05-15 23:26:48.132: E/AndroidRuntime(16934): at
org.holoeverywhere.addon.IAddonBasicAttacher.inhert(IAddonBasicAttacher.java:89)
05-15 23:26:48.132: E/AndroidRuntime(16934): at
org.holoeverywhere.app.Activity.onCreate(Activity.java:247) 05-15
23:26:48.132: E/AndroidRuntime(16934): at
com.myapp.MainActivity.onCreate(MainActivity.java:10) 05-15
23:26:48.132: E/AndroidRuntime(16934): at
android.app.Activity.performCreate(Activity.java:5008) 05-15
23:26:48.132: E/AndroidRuntime(16934): at
android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1079)
05-15 23:26:48.132: E/AndroidRuntime(16934): at
android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2023)
05-15 23:26:48.132: E/AndroidRuntime(16934): ... 11 more
どうしたの?