I have read through about 2 dozen articles and through the Google documents and my code as it is just gives me a force close box. Here is my code
Manifest
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.ndai.funnys"
android:versionCode="1"
android:versionName="1.0" >
<uses-sdk android:minSdkVersion="8"
android:targetSdkVersion="15" />
<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" >
<activity
android:name=".GuysFunnysActivity"
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>
</manifest>
main.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout android:id="@+id/LinearLayout01"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<com.google.ads.AdView android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
ads:adUnitId="a14ffb06b21e68e"
ads:adSize="BANNER"
ads:testDevices="TEST_EMULATOR, 12345678901234567890123456789012"
ads:loadAdOnCreate="true"/>
</LinearLayout>
JAVA
package com.ndai.funnys;
import java.io.InputStream;
import java.net.URL;
import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.os.Bundle;
import android.widget.ImageView;
import android.widget.LinearLayout;
import com.google.ads.*;
public class GuysFunnysActivity extends Activity
{
@Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
}
What am I doing wrong? This is exactly as I have seen it on other sites. I have also tried the non-xml version with the same exact issues, even when I used the test device code.
LOGCAT
07-09 17:34:23.207: D/AndroidRuntime(729): Shutting down VM
07-09 17:34:23.207: W/dalvikvm(729): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
07-09 17:34:23.237: E/AndroidRuntime(729): FATAL EXCEPTION: main
07-09 17:34:23.237: E/AndroidRuntime(729): java.lang.RuntimeException: Unable to start activity ComponentInfo {com.ndai.funnys/com.ndai.funnys.GuysFunnysActivity}: android.view.InflateException: Binary XML file line #8: Error inflating class com.google.ads.AdView
07-09 17:34:23.237: E/AndroidRuntime(729): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
07-09 17:34:23.237: E/AndroidRuntime(729): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
07-09 17:34:23.237: E/AndroidRuntime(729): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
07-09 17:34:23.237: E/AndroidRuntime(729): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
07-09 17:34:23.237: E/AndroidRuntime(729): at android.os.Handler.dispatchMessage(Handler.java:99)
07-09 17:34:23.237: E/AndroidRuntime(729): at android.os.Looper.loop(Looper.java:123)
07-09 17:34:23.237: E/AndroidRuntime(729): at android.app.ActivityThread.main(ActivityThread.java:4627)
07-09 17:34:23.237: E/AndroidRuntime(729): at java.lang.reflect.Method.invokeNative(Native Method)
07-09 17:34:23.237: E/AndroidRuntime(729): at java.lang.reflect.Method.invoke(Method.java:521)
07-09 17:34:23.237: E/AndroidRuntime(729): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
07-09 17:34:23.237: E/AndroidRuntime(729): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
07-09 17:34:23.237: E/AndroidRuntime(729): at dalvik.system.NativeStart.main(Native Method)
07-09 17:34:23.237: E/AndroidRuntime(729): Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.google.ads.AdView
07-09 17:34:23.237: E/AndroidRuntime(729): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
07-09 17:34:23.237: E/AndroidRuntime(729): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
07-09 17:34:23.237: E/AndroidRuntime(729): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
07-09 17:34:23.237: E/AndroidRuntime(729): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
07-09 17:34:23.237: E/AndroidRuntime(729): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
07-09 17:34:23.237: E/AndroidRuntime(729): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
07-09 17:34:23.237: E/AndroidRuntime(729): at android.app.Activity.setContentView(Activity.java:1647)
07-09 17:34:23.237: E/AndroidRuntime(729): at com.ndai.funnys.GuysFunnysActivity.onCreate(GuysFunnysActivity.java:20)
07-09 17:34:23.237: E/AndroidRuntime(729): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-09 17:34:23.237: E/AndroidRuntime(729): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
07-09 17:34:23.237: E/AndroidRuntime(729): ... 11 more
07-09 17:34:23.237: E/AndroidRuntime(729): Caused by: java.lang.ClassNotFoundException: com.google.ads.AdView in loader dalvik.system.PathClassLoader [/data/app/com.ndai.funnys-2.apk]
07-09 17:34:23.237: E/AndroidRuntime(729): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
07-09 17:34:23.237: E/AndroidRuntime(729): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
07-09 17:34:23.237: E/AndroidRuntime(729): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
07-09 17:34:23.237: E/AndroidRuntime(729): at android.view.LayoutInflater.createView(LayoutInflater.java:466)
07-09 17:34:23.237: E/AndroidRuntime(729): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
07-09 17:34:23.237: E/AndroidRuntime(729): ... 20 more
In Eclipse, all jars must be added to libs/ or specifically exported in the
Order And Exporttab of theJava Build Path. Otherwise, the jar won’t get bundled in to your compiled code, and your app will fail at runtime when referencing the jar files.