בעיה בהוספת פרסומת AdMob באנדרואיד למביני עיניין - גאדג'טים ומובייל - HWzone פורומים
עבור לתוכן
  • צור חשבון

בעיה בהוספת פרסומת AdMob באנדרואיד למביני עיניין


CodeNinja

Recommended Posts

היי לכולם,

ניסיתי להוסיף פרסומת לאפליקציה והאפליקציה קורסת בהפעלה הראשונית.

הוספתי את הSDK -

googleadmobadssdkandroid



[LEFT]package com.example.banner;


import .app.Activity;
import .os.Bundle;
import .widget.LinearLayout;


import com.google.ads.*;


public class BannerExample extends Activity {
private AdView adView;


@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);

// Create the adView
adView = new AdView(this, AdSize.BANNER, "a1518d796c04d6b");
LinearLayout layout = (LinearLayout)findViewById(R.id.mainLayout);


// Add the adView to it
layout.addView(adView);


// Initiate a generic request to load it with an ad
adView.loadAd(new AdRequest());

}



@Override
public void onDestroy() {
// bug at sdk, no need to call
//adView.destroy();
}

}[/LEFT]




[LEFT]<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:id="@+id/mainLayout">
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="a1518d796c04d6b"
ads:adSize="BANNER"
ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID"
ads:loadAdOnCreate="true"/>
</LinearLayout>[/LEFT]




[LEFT]<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.banner"
android:versionCode="1"
android:versionName="1.0" >


<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>


<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.banner.BannerExample"
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="com.google.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>

</application>


</manifest>[/LEFT]


הLogCat שאני מקבל בעת הרצה:

07-24 10:13:31.535: E/dalvikvm(541): Could not find class 'com.google.ads.AdView', referenced from method com.example.banner.BannerExample.onCreate

07-24 10:13:31.535: W/dalvikvm(541): VFY: unable to resolve new-instance 473 (Lcom/google/ads/AdView;) in Lcom/example/banner/BannerExample;

07-24 10:13:31.905: E/AndroidRuntime(541): FATAL EXCEPTION: main

07-24 10:13:31.905: E/AndroidRuntime(541): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.banner/com.example.banner.BannerExample}: .view.InflateException: Binary XML file line #8: Error inflating class com.google.ads.AdView

07-24 10:13:31.905: E/AndroidRuntime(541): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)

ועוד מלא שטויות...

מישהו?

תודה רבה לעוזרים,

שחר.

קישור לתוכן
שתף באתרים אחרים

ארכיון

דיון זה הועבר לארכיון ולא ניתן להוסיף בו תגובות חדשות.

×
  • צור חדש...