2013-11-03 27 views
1

我試圖讓谷歌admob sdk集成到在xml中編寫的android應用程序中展示廣告。是的,我已經確保admob jar被按順序檢查並在構建路徑下導出!Admob「以下類無法實例化: - com.google.ads.AdView」Android XML問題

我意識到還有其他未解決的問題,但沒有答案可以解決我的問題!即時得到任何錯誤,我project.properties設爲目標19,我的表現有這樣的:

<activity android:name="com.google.ads.AdActivity" 
      android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/> 

,我會後我的整個主佈局頁面 請幫我傢伙!

<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" 
xmlns:tools="http://schemas.android.com/tools" 
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads" 
android:layout_width="match_parent" 
android:layout_height="match_parent" 
android:background="#000000" 
android:paddingBottom="@dimen/activity_vertical_margin" 
android:paddingRight="@dimen/activity_horizontal_margin" 
android:paddingTop="@dimen/activity_vertical_margin" 
tools:context=".MainActivity" > 

<TextView 
    android:id="@+id/textView1" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    android:layout_alignLeft="@+id/imageView1" 
    android:layout_centerVertical="true" 
    android:gravity="center" 
    android:text="@string/text_mainmenu" 
    android:textAppearance="?android:attr/textAppearanceLarge" 
    android:textColor="#FFFFFF" /> 
<com.google.ads.AdView 
    android:id="@+id/adView" 
    android:layout_width="fill_parent" 
    android:layout_height="wrap_content" 
    ads:adUnitId="[MYIDHERE]" 
    ads:adSize="BANNER" 
    ads:testDevices="TEST_EMULATOR, TEST_DEVICE_ID" 
    ads:loadAdOnCreate="true" /> 
</RelativeLayout> 
+0

您是否正在收到日誌,顯示正在收到廣告?發佈你的logcat – William

回答

11

我有同樣的問題。當您在Eclipse中爲Android-19(KitKat)渲染布局時,圖形佈局存在一些問題。例如,您無法在「屬性」窗口中更改項目。

以圖形佈局切換到Android-18(綠色Android右上)爲我解決了這個問題。

相關問題