0

androidannotations + mopub を使用した人はいますか? 実行時にヌル ポインター例外が発生します。ビューが見つからないようです。ここにリストとスタックトレースがあります

設定.java

package com.nbrk.rates;

import android.os.Bundle;
import android.support.v4.app.NavUtils;
import com.actionbarsherlock.app.SherlockPreferenceActivity;
import com.googlecode.androidannotations.annotations.*;
import com.mopub.mobileads.MoPubView;

/**
 * Created with IntelliJ IDEA.
 * User: rpagyc
 * Date: 17.12.12
 * Time: 3:12
 * To change this template use File | Settings | File Templates.
 */
@EActivity(R.layout.admob_preference)
public class Settings extends SherlockPreferenceActivity {

    @ViewById(R.id.adview)
    MoPubView adview;

    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        addPreferencesFromResource(R.xml.app_prefs_cat1);
    }

    @AfterViews
    public void init() {
        getSupportActionBar().setDisplayHomeAsUpEnabled(true);

        adview.setAdUnitId("d1124826a1664353bd0c723561b1be34");
        adview.loadAd();
    }
}

admob_preference.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
              android:orientation="vertical"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"
              android:gravity="center">
    <com.mopub.mobileads.MoPubView
            android:id="@+id/adview"
            android:layout_width="fill_parent"
            android:layout_height="50dp"
            />
    <ListView android:id="@android:id/list"
              android:layout_width="fill_parent"
              android:layout_height="fill_parent"/>
</LinearLayout>

スタックトレース

08-16 05:36:10.954: ERROR/AndroidRuntime(2190): FATAL EXCEPTION: main
        java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nbrk.rates/com.nbrk.rates.Settings_}: java.lang.NullPointerException
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
        at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
        at android.app.ActivityThread.access$600(ActivityThread.java:141)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:137)
        at android.app.ActivityThread.main(ActivityThread.java:5039)
        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:793)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
        at dalvik.system.NativeStart.main(Native Method)
        Caused by: java.lang.NullPointerException
        at com.nbrk.rates.Settings.init(Settings.java:34)
        at com.nbrk.rates.Settings_.afterSetContentView_(Settings_.java:34)
        at com.nbrk.rates.Settings_.setContentView(Settings_.java:40)
        at android.preference.PreferenceActivity.onCreate(PreferenceActivity.java:510)
        at com.nbrk.rates.Settings.onCreate(Settings.java:25)
        at com.nbrk.rates.Settings_.onCreate(Settings_.java:26)
        at android.app.Activity.performCreate(Activity.java:5104)
        at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
        at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
        ... 11 more
4

1 に答える 1