Reputation:
I dont know how this error comes, when i try this lots of times, so I saw differnt post in stackoverflow but i doent get solution. So after this i post this problem. I have a 2.3.3 android app that I am developing that I would like to add Admob ads onto. My errors:
Here is the my java files>
package com.example.admobtest;
import android.os.Bundle;
import android.app.Activity;
import com.google.ads.*;
public class MainActivity extends Activity {
private AdView adView;
@Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
// Create the adView
adView=(AdView) findViewById(R.id.adView);
// Initiate a generic request to load it with an ad
adView.loadAd(new AdRequest());
}
}
and main.xml files
<RelativeLayout 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" >
<com.google.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginTop="17dp"
ads:adSize="BANNER"
ads:adUnitId="**************"
ads:loadAdOnCreate="true" />
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:text="@string/hello_world"
tools:context=".MainActivity" />
</RelativeLayout>
In graphical layout
The following classes could not be instantiated: - com.google.ads.AdView (Open Class, Show Error Log) See the Error Log (Window > Show View) for more details.
Finally in AndroidManifest.xml
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.admobtest"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="10" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
<application
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name=".MainActivity"
android:label="@string/title_activity_main" >
<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" />
</application>
</manifest>
Here I also try this android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"
instead of android:configChanges="keyboard|keyboardHidden|orientation"
but does not effects.
And I add GoogleAdMobAdsSdk-6.1.0.jar from exterval jar files.
Upvotes: 5
Views: 4767
Reputation: 924
i think you missing meta-data tag
<meta-data android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version"/>
i hope that helps
Upvotes: 0
Reputation: 56925
To fix the problem you have to set your project build target to Android 3.2 or higher .
Check more details on this link .
https://developers.google.com/mobile-ads-sdk/docs/ (See Android Tab)
Upvotes: 1