我在这个网站注册的一个广告联盟http://zhcn.admob.com/.
然后根据步骤https://developers.google.com/mobile-ads-sdk/docs/android/fundamentals?hl=zh-cn这个网站的步骤,
一步一步的,可是都完事了之后,到运行模拟器的时候,就报错了,说找不到Could not find class 'com.google.ads.AdView'
这个类..我把GoogleAdMobAdsSdkAndroid-4.3.1这个Jra包都引导项目里了,可是还不行,
大家谁能帮帮我.谢谢了..
下面是我的Java代码.package com.feng.main;import android.app.Activity;
import android.os.Bundle;
import android.widget.LinearLayout;import com.google.ads.*;public class TestActivity 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, "a14f756f69907d7"); // Lookup your LinearLayout assuming it’s been given
// the attribute android:id="@+id/mainLayout"
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() {
if (adView != null) {
adView.destroy();
}
super.onDestroy();
}
}
下面是我的XML代码<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.feng.main"
    android:versionCode="1"
    android:versionName="1.0" >    <uses-sdk android:minSdkVersion="15" />    <application
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name" >
        <activity
            android:name=".TestActivity"
            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>    <uses-permission android:name="android.permission.INTERNET" />
    <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /></manifest>

解决方案 »

  1.   

    R.layout.main文件里面少了广告条布局
      

  2.   

    你这个情况蛮奇怪的,既然已经编译成功了,怎么会找不到的,你可以用它官网上提供的sample测一下,看有没有问题,不行可以直接找他们的客服或者开发支持问下
      

  3.   


    这是我的R文件/* AUTO-GENERATED FILE.  DO NOT MODIFY.
     *
     * This class was automatically generated by the
     * aapt tool from the resource data it found.  It
     * should not be modified by hand.
     */package com.feng.main;public final class R {
        public static final class attr {
        }
        public static final class drawable {
            public static final int ic_launcher=0x7f020000;
        }
        public static final class id {
            public static final int mainLayout=0x7f050000;
        }
        public static final class layout {
            public static final int main=0x7f030000;
        }
        public static final class string {
            public static final int app_name=0x7f040001;
            public static final int hello=0x7f040000;
        }
    }下面是我的Main.xml<?xml version="1.0" encoding="utf-8"?>
    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:orientation="vertical" >    <TextView
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:text="@string/hello" />    <LinearLayout
            android:id="@+id/mainLayout"
            android:layout_width="match_parent"
            android:layout_height="wrap_content"
            android:orientation="vertical" >
        </LinearLayout></LinearLayout>
      

  4.   


    我下载官网的例子里面没有完整的项目.
    只有res文件夹src文件夹
    一个AndroidManifest.xml文件
    一个build.xml文件
    一个proguard.cfg文件
    一个project.properties文件.
    我都原封不动复制,运行还是不好使!!!
      

  5.   

    you guys can check following link for solution http://android.foxykeep.com/dev/how-to-fix-the-classdefnotfounderror-with-adt-17
      

  6.   

    是否混淆了?混淆时候需要keep一些不能混淆的东西,有的时候引入jar包混淆,就会找不到其中的东西!
      

  7.   

    解决了,是我引用Jar出问题了,添加第三方jar的时候一定要在
    项目目录下建立一个jar文件夹,把所有的jar放到文件夹下,
    然后项目引入jar的时候一定要从项目的目录下来引用.