我一直在试图将AdMob功能实施到我的项目中,并继续遭遇砖墙。我一直在网络上进行研究,并注意到其他用户所看到的类似问题以及他们的解决方案,但是我似乎得到了这么多,然后却无法完成它的工作。我希望有人能够指出我的一些愚蠢的错误!
顺便说一句,我正在运行Android 2.3.3的HTC Desire(Bravo)上进行测试,并使用最新的AdMob SDK(4.3.1)进行测试。
我可以从我的AdMob帐户看到服务器正在看到广告请求,但我的应用程序中的Ad对象一直声明我需要在清单中声明AdActivity以及configChange参数。两者都在那里!
任何帮助将非常感激。下面是我的代码的关联(煮沸)部分;
=================== AndroidManifest.xml ============================ =====
package=""
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:debuggable="false">
android:label="@string/app_name"
android:name=".MainActivity" >
android:configChanges="orientation|keyboard|keyboardHidden"/>
====================== MainActivity.java ========================= ========package my.package.name;
import com.google.ads.AdRequest;
import com.google.ads.AdView;
public class MainActivity extends Activity{
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.choice_layout_main);
AdView adView = (AdView) this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest();
adView.loadAd(adRequest);
}
}================ choice_layout_main.xml ==============================
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@drawable/background_main"
android:gravity="top"
android:orientation="vertical"
android:scrollbarStyle="insideOverlay"
android:scrollbars="vertical"
android:textColor="#FFFFFFFF">
android:id="@+id/MainLayout"
android:padding="50sp"
android:layout_width="match_parent"
android:layout_height="wrap_content">
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:backgroundColor="#000000"
ads:primaryTextColor="#FFFFFF"
ads:secondaryTextColor="#CCCCCC"
ads:adSize="BANNER"
ads:refreshInterval="30"
ads:adUnitId=""
ads:loadAdOnCreate="true"
/>
看起来,其他开发者展示的所有其他解决方案都不适合我,所以我认为它必定是我忽略的一些愚蠢点!任何帮助对我的理智都会有好处!
干杯,
背风处