简体   繁体   中英

Integrating adwhirl with Buzztouch 1.4 on Android,crashes phone

I am trying to add Adwhirl to a Buzztouch app on Android but it crashes the phone. Admob on its own is OK.

The Adwhirl code has been added to the custom text page code in Buzztouch 1.4. I have an app set up in the Adwhirl control panel that uses Admob.

The Admob and Adwhirl SDKs are included in the libs folder and linked to the build path

Manifest extract

     <!-- 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>

Main activity extract

//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();

layout 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>

Error log extract, the error starts at "stored config data not present"

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

It seems like you might be setting your content view with

setContentView(R.layout.screen_customtext);

to a layout id that doesn't exist. That is, R.layout.screen_customtext doesn't seem to be defined in your layout xml.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM