Eclipse/com中的java AdMob。谷歌。安卓gms。ads.AdView
我有个问题,什么都帮不了我(
我每次都会犯这个错误
The following classes could not be instantiated:
- com.google.安卓.gms.ads.AdView (Open Class, Show Error Log)
See the Error Log (Window > Show View) for more details.
在这里你可以看到:
这是我的代码:
主要活动。java
package com.example.test;
import com.google.安卓.gms.ads.*;
import 安卓.support.v7.app.ActionBarActivity;
import 安卓.os.Bundle;
import 安卓.view.Menu;
import 安卓.view.MenuItem;
publicclass MainActivity extends ActionBarActivity {
AdRequest adRequest = new AdRequest.Builder().build();
@Override
protectedvoid onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
// Look up the AdView as a resource and load a request.
AdView adView = (AdView)this.findViewById(R.id.adView);
AdRequest adRequest = new AdRequest.Builder().build();
adView.loadAd(adRequest); } @Override
publicboolean onCreateOptionsMenu(Menu menu) {
// Inflate the menu; this adds items to the action bar if it is present.
getMenuInflater().inflate(R.menu.main, menu);
returntrue;
} @Override
publicboolean onOptionsItemSelected(MenuItem item) {
// Handle action bar item clicks here. The action bar will
// automatically handle clicks on the Home/Up button, so long
// as you specify a parent activity in AndroidManifest.xml.
int id = item.getItemId();
if (id == R.id.action_settings) {
returntrue;
} returnsuper.onOptionsItemSelected(item);
} }
主要活动。xml
<LinearLayoutxmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
xmlns:tools="http://schemas.安卓.com/tools"
xmlns:ads="http://schemas.安卓.com/apk/res-auto"
安卓:layout_width="match_parent"
安卓:layout_height="match_parent"
安卓:paddingBottom="@dimen/activity_vertical_margin"
安卓:paddingLeft="@dimen/activity_horizontal_margin"
安卓:paddingRight="@dimen/activity_horizontal_margin"
安卓:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.example.blackcalculator.MainActivity">
<com.google.安卓.gms.ads.AdView
安卓:id="@+id/adView"
安卓:layout_width="wrap_content"
安卓:layout_height="wrap_content"
ads:adSize="BANNER"
ads:adUnitId="ca-app-pub-1322203023519977/3000186843">
</com.google.安卓.gms.ads.AdView>
</LinearLayout>
AndroidManifest
<?
xmlversion="1.0"encoding="utf-8"?>
<
manifestxmlns:安卓="http://schemas.安卓.com/apk/res/安卓"
package="com.example.test"
安卓:versionCode="1"
安卓:versionName="1.0">
<uses-sdk
安卓:minSdkVersion="9"
安卓:targetSdkVersion="21"/>
<uses-permission安卓:name="安卓.permission.INTERNET"/>
<uses-permission安卓:name="安卓.permission.ACCESS_NETWORK_STATE"/>
<application
安卓:allowBackup="true"
安卓:icon="@drawable/ic_launcher"
安卓:label="@string/app_name"
安卓:theme="@style/AppTheme">
<meta-data安卓:name="com.google.安卓.gms.version"
安卓:value="@integer/google_play_services_version"/>
<activity
安卓:name=".MainActivity"
安卓:label="@string/app_name">
<intent-filter>
<action安卓:name="安卓.intent.action.MAIN"/>
<category安卓:name="安卓.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<activity安卓:name="com.google.安卓.gms.ads.AdActivity"
安卓:configChanges="keyboard|keyboardHidden|orientation|screenLayout| uiMode|screenSize|smallestScreenSize"/>
</application>
</
manifest>
我还发现adview eems中的一些错误,请看右边
我希望你能帮助我
共 (0) 个答案