我正在尝试将 Adwhirl 添加到 Android 上的 Buzztouch 应用程序中,但它会使手机崩溃。Admob 本身就可以。
Adwhirl 代码已添加到 Buzztouch 1.4 中的自定义文本页面代码中。我在 Adwhirl 控制面板中设置了一个使用 Admob 的应用程序。
Admob 和 Adwhirl SDK 包含在libs
文件夹中并链接到构建路径
清单提取物
<!-- starting activity -->
<activity android:name=".Act_Home" android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<meta-data android:value="8a1d###cf6482407ba52947923949d714"
android:name="ADWHIRL_KEY"/>
</activity>
<activity android:name=".Screen_CustomText"
android:label="@string/app_name"
android:screenOrientation="sensor"
android:configChanges="orientation">
<meta-data android:value="8a1d92cf64###ba52947923949d714"
android:name="ADWHIRL_KEY"/>
</activity>
主要活动提取物
//onCreate
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.screen_customtext);
AdWhirlManager.setConfigExpireTimeout(1000 * 60 * 5);
AdWhirlTargeting.setAge(23);
AdWhirlTargeting.setGender(AdWhirlTargeting.Gender.MALE);
AdWhirlTargeting.setKeywords("online games gaming");
AdWhirlTargeting.setPostalCode("bb54de");
AdWhirlTargeting.setTestMode(false);
AdWhirlLayout adWhirlLayout = (AdWhirlLayout)findViewById(R.id.adwhirl_layout);
TextView textView = new TextView(this);
RelativeLayout.LayoutParams layoutParams = new
RelativeLayout.LayoutParams(LayoutParams.WRAP_CONTENT,
LayoutParams.WRAP_CONTENT);
int diWidth = 320;
int diHeight = 52;
int density = (int) getResources().getDisplayMetrics().density;
adWhirlLayout.setAdWhirlInterface(this);
adWhirlLayout.setMaxWidth((int)(diWidth * density));
adWhirlLayout.setMaxHeight((int)(diHeight * density));
layoutParams.addRule(RelativeLayout.CENTER_HORIZONTAL);
textView.setText("Below AdWhirlLayout");
LinearLayout layout2 = (LinearLayout)findViewById(R.id.layout_main);
layout2.setGravity(Gravity.CENTER_HORIZONTAL);
layout2.addView(adWhirlLayout, layoutParams);
layout2.addView(textView, layoutParams);
layout2.invalidate();
布局xml
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout android:id="@+id/header"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:background="#FFFFFF"
>
<include layout="@layout/global_title_dark" />
<!-- Layout for admob -->
<LinearLayout
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/mainLayout"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_marginTop="47dip"
android:orientation="horizontal">
</LinearLayout>
<LinearLayout
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:id="@+id/myContent"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:layout_marginTop="87dip"
android:orientation="vertical">
<!-- Layout for adwhirl -->
<RelativeLayout android:id="@+id/layout_main"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res/com.adwhirl"
android:layout_height="fill_parent"
android:layout_width="fill_parent"
android:background="#FFFFFF">
<com.adwhirl.AdWhirlLayout
android:id="@+id/adwhirl_layout"
android:layout_width="fill_parent"
android:layout_height="wrap_content" />
</RelativeLayout>
<WebView xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/myWebView"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
</LinearLayout>
错误日志提取,错误从“存储的配置数据不存在”开始
06-03 09:39:06.072: I/AdWhirl SDK(5954): Finished creating adWhirlManager
06-03 09:39:06.072: D/AdWhirl SDK(5954): Prefs{null}: {"config": "[]
06-03 09:39:06.072: D/AdWhirl SDK(5954): ", "timestamp": 1338665057125}
06-03 09:39:06.072: D/AndroidRuntime(5954): Shutting down VM
06-03 09:39:06.072: I/AdWhirl SDK(5954): Stored config info not present or expired,
fetching fresh data**
06-03 09:39:06.072: W/dalvikvm(5954): threadid=1: thread exiting with uncaught
exception (group=0x4027a5a0)
06-03 09:39:06.082: E/AndroidRuntime(5954): FATAL EXCEPTION: main
06-03 09:39:06.082: E/AndroidRuntime(5954): java.lang.RuntimeException: Unable
to start activity ComponentInfo{com.v1_4.eightiespopquiz.com/
com.v1_4.eightiespopquiz.com.Screen_CustomText}:
java.lang.ClassCastException:
android.widget.RelativeLayout