Android/Eclipse:无法实例化以下类:-com.google.Android.gms.ads.AdView
我正在Google Play Services下转换为新的AdMob,在图形界面上出现以下错误。我已经清理了这个项目很多次了,但是没有运气。有什么建议吗Android/Eclipse:无法实例化以下类:-com.google.Android.gms.ads.AdView,android,eclipse,admob,Android,Eclipse,Admob,我正在Google Play Services下转换为新的AdMob,在图形界面上出现以下错误。我已经清理了这个项目很多次了,但是没有运气。有什么建议吗 无法实例化以下类:-com.google.android.gms.ads.AdView 舱单: <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package=
无法实例化以下类:-com.google.android.gms.ads.AdView
舱单:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ARCompware.shapetapper"
android:versionCode="4"
android:versionName="1.3" >
<uses-sdk
android:minSdkVersion="9"
android:targetSdkVersion="17" />
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:allowBackup="true"
android:icon="@drawable/shapetapperlogo"
android:label="@string/app_name"
android:theme="@style/AppTheme" android:logo="@drawable/shapetapperlogo" android:requiredForAllUsers="true"
>
<activity
android:name="com.ARCompware.shapetapper.MainActivity"
android:configChanges="orientation|keyboardHidden"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.ARCompware.shapetapper.HowToPlay"
android:label="@string/title_activity_how_to_play"
android:parentActivityName="com.ARCompware.shapetapper.MainActivity"
android:screenOrientation="portrait" >
<meta-data
android:name="android.support.PARENT_ACTIVITY"
android:value="com.ARCompware.shapetapper.MainActivity" />
</activity>
<activity
android:name="com.ARCompware.shapetapper.GamePlay"
android:label="@string/title_activity_game_play"
android:theme="@android:style/Theme.Black.NoTitleBar.Fullscreen"
android:screenOrientation="portrait" >
</activity>
<activity android:name="com.google.android.gms.ads.AdActivity"
android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
</application>
</manifest>
因此,似乎需要java代码,您需要将其添加到onCreate中:
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("TEST_DEVICE_ID")
.build();
adView.loadAd(adRequest);
还可以将其添加到布局adView中:
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
....
Oops,忘了在我的代码中包含Java部分,但是是的,它是完全相同的东西。没有luckOk请确保Google play services库与您的应用程序位于同一工作区,并将此xmlns:ads=”“添加到您的标记com.Google.android.gms.ads.AdViewTried中。还是不走运。
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("TEST_DEVICE_ID")
.build();
adView.loadAd(adRequest);
<com.google.android.gms.ads.AdView
xmlns:ads="http://schemas.android.com/apk/res-auto"
....