Reputation: 734
I've seen similar questions but they couldnt solve my problem. I've installed Google Play SDKs, imported as a library to my app. Following Admob instructions, I've written that code below:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/relative"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.oguz.nfcdatareaderwriter.MainPage$PlaceholderFragment" >
<Button
android:id="@+id/writeNFC"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/openingMessage"
android:layout_centerHorizontal="true"
android:layout_marginTop="116dp"
android:text="Write Custom Data to a Card" />
<TextView
android:id="@+id/openingMessage"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="174dp"
android:text=".."
android:textAppearance="?android:attr/textAppearanceLarge" />
</RelativeLayout>
Main Activity:
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_main_page);
// Create an ad.
adView = new AdView(this);
adView.setAdSize(AdSize.BANNER);
adView.setAdUnitId(AD_UNIT_ID);
// Add the AdView to the view hierarchy. The view will have no size
// until the ad is loaded.
RelativeLayout layout = (RelativeLayout) findViewById(R.id.relative);
layout.addView(adView);
// Create an ad request. Check logcat output for the hashed device ID to
// get test ads on a physical device.
AdRequest adRequest = new AdRequest.Builder()
.addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
.addTestDevice("4df1dccd39006f0f")
.build();
// Start loading the ad in the background.
adView.loadAd(adRequest);
}
Upvotes: 1
Views: 2328
Reputation: 196
For me it was quite difficult to use AdMob
with Eclipse LUNA and the last SDK and ADT.
What I've found it's that you must order your Java Build Path (Right Click then properties) as folow :
Android Dependecies checked, Android xxx Unchecked, Android Private Librairies Checked
And control that in your libs folder the google-play-services.jar is inside !
Upvotes: 2
Reputation: 20196
If you are getting NoClassDefFoundError then you have not properly included the GooglePlayServices library, or you have managed to exclude the classes using Proguard or similar. Try redoing the steps.
Upvotes: 4