我想使用Madvertise而不是AdMob作为广告平台,但我不断收到以下错误:de.madvertise.android.sdk.MadvertiseView无法实例化。
这是我的xml布局:
<?xml version="1.0" encoding="utf-8"?><RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
xmlns:mad="http://schemas.android.com/apk/res/com.celticwolf.alex"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/menu_dimback"
android:orientation="vertical" >
<RelativeLayout
android:id="@+id/relativeLayout1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_alignParentRight="true"
android:layout_below="@+id/adsContainer" >
</RelativeLayout>
<RelativeLayout
android:id="@+id/relativeFeedback"
android:layout_width="wrap_content"
android:layout_height="40dp"
android:layout_marginTop="50dp"
android:layout_below="@+id/adsContainer"
android:layout_centerHorizontal="true" >
</RelativeLayout>
<Button
android:id="@+id/tvBeerName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/country"
android:layout_centerHorizontal="true"
android:background="@drawable/blanktwo"
android:layout_marginBottom="30dp"
android:gravity="center"
android:shadowColor="#000000"
android:shadowDx="-2.5"
android:shadowDy="3"
android:shadowRadius="2"
android:text="@string/beername"
android:textColor="#FFFFFF"
android:textSize="25sp"
android:textStyle="bold"
android:typeface="serif" />
<ImageView
android:id="@+id/glassfull1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/llButtonHorizontal"
android:paddingLeft="20dp"
android:src="@drawable/glassfull" />
<ImageView
android:id="@+id/country"
android:layout_width="wrap_content"
android:layout_height="100dp"
android:layout_above="@+id/llButtonHorizontal"
android:layout_centerHorizontal="true"
android:paddingBottom="20dp"
android:src="@drawable/blanktwo" /><LinearLayout
android:id="@+id/adsContainer"
android:layout_width="fill_parent"
android:layout_height="53dip"
android:orientation="vertical" >
<de.madvertise.android.sdk.MadvertiseView
android:id="@+id/madad"
android:layout_width="320dip"
android:layout_height="53dip"
mad:bannerType="mma"
mad:placement_type="inline"/>
<ListView
android:id="@+id/country_list"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#000000"/>
</LinearLayout>
<LinearLayout
android:id="@+id/llButtonHorizontal"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:orientation="horizontal"
android:weightSum="10" >
<Button
android:id="@+id/bBeer"
android:layout_width="fill_parent"
android:layout_height="80dp"
android:layout_weight="5"
android:background="@drawable/custombeer" />
<Button
android:id="@+id/bNoBeer"
android:layout_width="match_parent"
android:layout_height="80dp"
android:layout_weight="5"
android:background="@drawable/customnobeer" />
</LinearLayout>
<ImageView
android:id="@+id/glassfull2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_above="@+id/llButtonHorizontal"
android:layout_alignParentRight="true"
android:paddingRight="20dp"
android:src="@drawable/glassfullrigth" />
<TextView
android:id="@+id/tvIsBeer"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_alignParentLeft="true"
android:layout_below="@+id/relativeFeedback"
android:gravity="center"
android:shadowColor="#000000"
android:shadowDx="-2.5"
android:shadowDy="3"
android:shadowRadius="2"
android:text="@string/check"
android:textSize="30sp"
android:textStyle="bold"
android:typeface="serif" />
</RelativeLayout>
这是完整的错误日志:
!ENTRY com.android.ide.eclipse.adt 4 0 2013-07-08 01:37:17.733
!MESSAGE de.madvertise.android.sdk.MadvertiseView failed to instantiate.
!STACK 0
java.lang.NullPointerException
at de.madvertise.android.sdk.MadvertiseUtil.checkForBrowserDeclaration(MadvertiseUtil.java:526)
at de.madvertise.android.sdk.MadvertiseView.<init>(MadvertiseView.java:201)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
at java.lang.reflect.Constructor.newInstance(Unknown Source)
at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.instantiateClass(ProjectCallback.java:422)
at com.android.ide.eclipse.adt.internal.editors.layout.ProjectCallback.loadView(ProjectCallback.java:179)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:207)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:135)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:746)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:718)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:749)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:64)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:718)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:372)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:385)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:332)
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:440)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.renderWithBridge(GraphicalEditorPart.java:1545)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.recomputeLayout(GraphicalEditorPart.java:1302)
at com.android.ide.eclipse.adt.internal.editors.layout.gle2.GraphicalEditorPart.activated(GraphicalEditorPart.java:1059)
at com.android.ide.eclipse.adt.internal.editors.layout.LayoutEditorDelegate.delegatePageChange(LayoutEditorDelegate.java:686)
at com.android.ide.eclipse.adt.internal.editors.common.CommonXmlEditor.pageChange(CommonXmlEditor.java:360)
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.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1077)
at org.eclipse.swt.widgets.Widget.sendEvent(Widget.java:1062)
at org.eclipse.swt.widgets.Widget.notifyListeners(Widget.java:774)
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.Widget.sendEvent(Widget.java:1053)
at org.eclipse.swt.widgets.Display.runDeferredEvents(Display.java:4165)
at org.eclipse.swt.widgets.Display.readAndDispatch(Display.java:3754)
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(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
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)
at org.eclipse.equinox.launcher.Main.main(Main.java:1386)
这是清单。
<uses-sdk
android:minSdkVersion="7"
android:targetSdkVersion="17"
/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<application
android:icon="@drawable/bonbicon"
android:label="@string/app_name"
android:theme="@style/Theme.Sherlock"
android:allowBackup="true">
<activity
android:name=".Splash"
android:screenOrientation="portrait"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".Menu"
android:screenOrientation="portrait"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.celticwolf.alex.MENU" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".Game"
android:screenOrientation="portrait"
android:label="@string/app_name" >
<intent-filter>
<action android:name="com.celticwolf.alex.GAME" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".About"
android:screenOrientation="portrait"
android:label="@string/about" >
<intent-filter>
<action android:name="com.celticwolf.alex.ABOUT" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".SendBrand"
android:screenOrientation="portrait"
android:label="@string/sendbeerbrand" >
<intent-filter>
<action android:name="com.celticwolf.alex.SENDBRAND" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity
android:name=".HighscoreView"
android:screenOrientation="portrait"
android:label="@string/txthighscore" >
<intent-filter>
<action android:name="com.celticwolf.alex.HIGHSCOREVIEW" />
<category android:name="android.intent.category.DEFAULT" />
</intent-filter>
</activity>
<activity android:name="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
<activity android:name=".ShareOnFacebook" android:label="@string/app_name"
android:screenOrientation="portrait" android:theme="@android:style/Theme.Dialog"/>
<!-- open external urls -->
<activity android:name="de.madvertise.android.sdk.MadvertiseActivity" />
<!-- Setup your site token. For tests, use 'TestTokn'-->
<meta-data android:value="TestTokn" android:name="madvertise_site_token" />
<!-- Mraid TestSuite -->
<activity android:name="android.app.Activity" />
<uses-library android:name="android.test.runner" />
</application>
<instrumentation android:targetPackage="de.madvertise.test" android:name="android.test.InstrumentationTestRunner" />
</manifest>
以下是Eclipse中XML编辑器的外观,但是当我运行它时,它不会显示任何广告:
我希望任何人都可以提前帮助和感谢:)
答案 0 :(得分:1)
您在Eclipse中遇到错误。即Eclipse无法呈现MadvertiseView。这是一个Eclipse问题,而不是Android问题。你的应用程序运行吗?我怀疑它确实如此。