教你如何申請Admob帳號?

張貼者: Mark | 下午4:57

話說Google已經買下Admob,且Google AdSense已經不支援廣告for mobile,因為這是違反的不過有人繼續使用的話,可要先移除改為admob方式崁入廣告,下面是違反告知。

網址

想要在Android軟體崁入Admob廣告,需做下列的事情

  1. 申請 AdMob 帳號
  2. 新增應用程式所屬的廣告,並且下載 AdMob 所釋出的 Java-SDK
  3. 整合至應用程式(APP)

1. 申請 AdMob 帳號

image

因為google已經買下admob,所以已經把帳號都整合在一起,一個帳號多用,google慢慢強大中,接下來就是填入一些個人的帳戶資訊。

2.建立一個網站

image

3.建立稅務資料,使用PayPal

image

,建議使用PayPal,先去PayPal註冊,聽說手續費比較低,至於如何申請PayPal 如下網址。

http://www.paytaiwan.com/

4.新增網站/應用程式

image

5.從「新增網站/應用程式」開始,裡面網址建議為apk 位於market 描述的網址

image

6.完成之後就可以下載 SDK

image

7.整合至軟體,請記住剛剛申請應用程式的ID

image

在專案新增一個資料夾 <your project>/libs,然後將 AdMob 的 JAR 檔案放入

再加入jar:「Project」==>「properties」==>「Java Build Path」==>「Libraries」==>「Add JARs…」

8.修改 AndroidManifest.xml:需要加上一個 Activity 給 AdMob,並且新增網路權限

<activity

android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|

uiMode|screenSize|smallestScreenSize"

android:name="com.google.ads.AdActivity" />

並且加入:

<uses-permission android:name="android.permission.INTERNET" />

<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

9.在需要加入廣告的app頁面加入main.xml

image

10.在對應加廣告的頁面的.java檔案中加入:

import com.google.ads.AdRequest;
import com.google.ads.AdView;

private AdView adView;

並且在 public void onCreate 裡面加入:

請記住剛剛申請應用程式的ID


11.或者直接在activity加入


image



 



請注意Requirements



The Google AdMob Ads SDK for Android requires Android 1.5 or later. Make sure you have the latest copy of the Android SDK and that you're compiling against at least Android v3.2 (set target in default.properties to android-13).



"請下載Android 3.2 (api 13) 至少"



不然參數設定的部份會出現錯誤




E/Ads     (26043): The android:configChanges value of the com.google.ads.AdActivity must include uiMode.
E/Ads (26043): The android:configChanges value of the com.google.ads.AdActivity must include screenSize.
E/Ads (26043): The android:configChanges value of the com.google.ads.AdActivity must include smallestScreenSize.





*重點: 


(configChanges的錯誤 , 沒有


uiMode / screenSize / smallestScreenSize 這三個參數)


官方網址有告訴 : 網址


The Google AdMob Ads SDK for Android requires Android 1.5 or later. 


Make sure you have thelatest copy of the Android SDK and 


that you're compiling against at least Android v3.2


 (set target indefault.properties to android-13).


看起來好像可以使用,但是第一次compile時就出現error,因為手機是android2.3,


所以在安裝專案的時候會顯示,手機不能支援3.2 所以不能安裝,解決方法如下


1.選擇使用android 3.2 sdk


image


2.去專案找到project.properties / 舊的版本為 default.properties 打開


image


# Project target.
target=android-13


改成"13" 就可以 , 然後在configChanges就可以看到


uiMode / screenSize / smallestScreenSize 這三個參數 , 


這樣就可以選擇android 2.3以下不會錯誤


應該說改成13...就可以支援3.2以下的版本...


3. 在AndroidManifest.xml sdk版本設為10...10=>android 2.3.3


image


都ok後手機的畫面如下:


device-2012-03-19-094806


 


分享好文: 讚 ! 分享到塗鴉牆
0 意見