javaandroidnullpointerexceptionadsmobclix

Mobclix banner NullPointerException?


I am using Andengine for my first game in conjunction with Mobclix and whenever I try to run the app, I get a huge error in LogCat. I have searched absolutely everywhere and I cant seem to find the answer.

FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.amzoft.starraider/com.amzoft.starraider.MainScreenMain}: android.view.InflateException: Binary XML file line #8: Error inflating class com.mobclix.android.sdk.MobclixMMABannerXLAdView
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1659)
    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1675)
    at android.app.ActivityThread.access$1500(ActivityThread.java:121)
    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:943)
    at android.os.Handler.dispatchMessage(Handler.java:99)
    at android.os.Looper.loop(Looper.java:130)
    at android.app.ActivityThread.main(ActivityThread.java:3701)
    at java.lang.reflect.Method.invokeNative(Native Method)
    at java.lang.reflect.Method.invoke(Method.java:507)
    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:624)
    at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.mobclix.android.sdk.MobclixMMABannerXLAdView
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:581)
    at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
    at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:227)
    at android.app.Activity.setContentView(Activity.java:1657)
    at org.anddev.andengine.ui.activity.LayoutGameActivity.onSetContentView(LayoutGameActivity.java:38)
    at org.anddev.andengine.ui.activity.BaseGameActivity.onCreate(BaseGameActivity.java:67)
    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1623)
    ... 11 more
Caused by: java.lang.ClassNotFoundException: com.mobclix.android.sdk.MobclixMMABannerXLAdView in loader dalvik.system.PathClassLoader[/mnt/asec/com.amzoft.starraider-2/pkg.apk]
    at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:240)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:551)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
    at android.view.LayoutInflater.createView(LayoutInflater.java:471)
    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
    ... 21 more

This is my layout xml file:

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" 
    android:id="@+id/layoutg">

    <com.mobclix.android.sdk.MobclixMMABannerXLAdView
        android:id="@+id/banner_adview"
        android:layout_width="320dip"
        android:layout_height="50dip"
        android:layout_gravity="center" />

    <org.anddev.andengine.opengl.view.RenderSurfaceView android:id="@+id/gameview"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_gravity="center" />

</FrameLayout>

And my Ad.class

package com.amzoft.starraider.ads;

import android.app.Activity;
import android.util.Log;
import android.view.View;

import com.amzoft.starraider.R;
import com.mobclix.android.sdk.MobclixAdView;
import com.mobclix.android.sdk.MobclixAdViewListener;
import com.mobclix.android.sdk.MobclixMMABannerXLAdView;

public class Ad implements MobclixAdViewListener{

    public static final String TAG = "StarRaider AD Manager";
    public MobclixMMABannerXLAdView adview;

    public Ad(Activity activity)
    {
        adview = (MobclixMMABannerXLAdView)activity.findViewById(R.id.banner_adview);
        adview.addMobclixAdViewListener(this);
        adview.getAd();
        adview.setRefreshTime(30);
    }

    @Override
    public String keywords() 
    {
        return null;
    }

    @Override
    public void onSuccessfulLoad(MobclixAdView view) 
    {
        Log.v(TAG, "The ad request was successful!");
        view.setVisibility(View.VISIBLE);
    }

    @Override
    public void onFailedLoad(MobclixAdView view, int errorCode) 
    {
        Log.v(TAG, "The ad request failed with error code: " + errorCode);
        view.setVisibility(View.GONE);
    }

    @Override
    public void onAdClick(MobclixAdView adView) {
        Log.v(TAG, "Ad clicked!");
    }

    @Override
    public void onCustomAdTouchThrough(MobclixAdView adView, String string) 
    {
        Log.v(TAG, "The custom ad responded with '" + string + "' when touched!");
    }

    @Override
    public boolean onOpenAllocationLoad(MobclixAdView adView, int openAllocationCode) 
    {
        Log.v(TAG, "The ad request returned open allocation code: " + openAllocationCode);
        return false;
    }

    @Override
    public String query() 
    {
        return null;
    }

}

But when I go into the eclipse visual editor, it says java.lang.NullPointerException Exception details are logged in Window > Show View > Error Log. So when I open up the error log I get an error regarding andengine's RenderSurfaceView:

java.lang.NullPointerException
    at org.anddev.andengine.opengl.view.RenderSurfaceView$Renderer.access$0(RenderSurfaceView.java:93)
    at org.anddev.andengine.opengl.view.RenderSurfaceView.onMeasure(RenderSurfaceView.java:54)
    at android.view.View.measure(View.java:12723)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
    at android.view.View.measure(View.java:12723)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
    at android.widget.FrameLayout.onMeasure(FrameLayout.java:293)
    at android.view.View.measure(View.java:12723)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1369)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:660)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:553)
    at android.view.View.measure(View.java:12723)
    at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:4698)
    at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1369)
    at android.widget.LinearLayout.measureVertical(LinearLayout.java:660)
    at android.widget.LinearLayout.onMeasure(LinearLayout.java:553)
    at android.view.View.measure(View.java:12723)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.measureView(RenderSessionImpl.java:542)
    at com.android.layoutlib.bridge.impl.RenderSessionImpl.render(RenderSessionImpl.java:444)
    at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:324)
    at com.android.ide.common.rendering.LayoutLibrary.createSession(LayoutLibrary.java:325)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.RenderService.createRenderSession(RenderService.java:372)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1361)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1115)
    at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.activated(GraphicalEditorPart.java:941)
    at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate.delegatePageChange(LayoutEditorDelegate.java:450)
    at com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor.pageChange(CommonXmlEditor.java:358)
    at org.eclipse.ui.part.MultiPageEditorPart$2.widgetSelected(MultiPageEditorPart.java:290)
    at org.eclipse.swt.widgets.TypedListener.handleEvent(TypedListener.java:240)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4128)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1457)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1480)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1465)
    at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1270)
    at org.eclipse.swt.custom.CTabFolder.setSelection(CTabFolder.java:2746)
    at org.eclipse.swt.custom.CTabFolder.onMouse(CTabFolder.java:1433)
    at org.eclipse.swt.custom.CTabFolder$1.handleEvent(CTabFolder.java:257)
    at org.eclipse.swt.widgets.EventTable.sendEvent(EventTable.java:84)
    at org.eclipse.swt.widgets.Display.sendEvent(Display.java:4128)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1457)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1480)
    at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1465)
    at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:1270)
    at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:3974)
    at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3613)
    at org.eclipse.ui.internal.Workbench.runEventLoop(Workbench.java:2701)
    at org.eclipse.ui.internal.Workbench.runUI(Workbench.java:2665)
    at org.eclipse.ui.internal.Workbench.access$4(Workbench.java:2499)
    at org.eclipse.ui.internal.Workbench$7.run(Workbench.java:679)
    at org.eclipse.core.databinding.observable.Realm.runWithDefault(Realm.java:332)
    at org.eclipse.ui.internal.Workbench.createAndRunWorkbench(Workbench.java:668)
    at org.eclipse.ui.PlatformUI.createAndRunWorkbench(PlatformUI.java:149)
    at org.eclipse.ui.internal.ide.application.IDEApplication.start(IDEApplication.java:123)
    at org.eclipse.equinox.internal.app.EclipseAppHandle.run(EclipseAppHandle.java:196)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.runApplication(EclipseAppLauncher.java:110)
    at org.eclipse.core.runtime.internal.adaptor.EclipseAppLauncher.start(EclipseAppLauncher.java:79)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:344)
    at org.eclipse.core.runtime.adaptor.EclipseStarter.run(EclipseStarter.java:179)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)
    at java.lang.reflect.Method.invoke(Method.java:597)
    at org.eclipse.equinox.launcher.Main.invokeFramework(Main.java:622)
    at org.eclipse.equinox.launcher.Main.basicRun(Main.java:577)
    at org.eclipse.equinox.launcher.Main.run(Main.java:1410)

Thanks.


Solution

  • Since this needs an answer... I updated the Android Eclipse plugin, the android tools and eclipse.