简体   繁体   English

使用admob将广告添加到android代码中

[英]Adding ads to android code using admob

Eclipse gives the following error when i try to ad ads to my application. 当我尝试将广告投放到应用程序时,Eclipse出现以下错误。

The following classes could not be found: - com.google.ads.Adview (Fix Build Path, Edit XML, Create Class) 找不到以下类别:-com.google.ads.Adview(修复构建路径,编辑XML,创建类别)

Manifest : 清单:

<uses-sdk
    android:minSdkVersion="9"
    android:targetSdkVersion="17" />

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

Xml : Xml:

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >


<com.google.ads.Adview
    android:id="@+id/ad"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    ads:adSize="BANNER"
    ads:adUnitID="MYID"
    ads:loadAdOnCreate="true" >
</com.google.ads.Adview>

I have checked my code thousand times i think there is no mistake in the manifest or in the xml. 我已经检查过我的代码数千次,我认为清单或xml中没有错误。 Please help me 请帮我

Also when i try to do so by using java i was'nt able to import com.google.android.gms.ads.* 另外,当我尝试使用Java这样做时,我也无法导入com.google.android.gms.ads。*

Copy AdMob lib file ( GoogleAdMobAdsSdk-6.0.1.jar ) to your libs folder , so Eclipse will automatically include it to your build. 将AdMob库文件( GoogleAdMobAdsSdk-6.0.1.jar )复制到您的libs文件夹中 ,以便Eclipse会自动将其包含在您的版本中。 And also add the library to project's build path . 并将添加项目的构建路径

More info here: 更多信息在这里:

http://jimmod.com/blog/2012/07/jimmys-blog-adding-admobs-ads-to-android-application/ http://jimmod.com/blog/2012/07/jimmys-blog-adding-admobs-ads-to-android-application/

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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