我正在尝试将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
答案 0 :(得分:1)
您似乎可能正在使用
设置内容视图 setContentView(R.layout.screen_customtext);
到不存在的布局ID。也就是说,R.layout.screen_customtext
似乎没有在布局xml中定义。