3

I have an app on the market using admob and now I would like to update my app. When I test this new version I get a Fatal Exception caused by the admob.

04-06 15:09:04.123: E/AndroidRuntime(409): Caused by: android.view.InflateException: Binary XML file line #51: Error inflating class com.google.ads.AdView


04-06 15:09:04.123: E/AndroidRuntime(409): Caused by: java.lang.ClassNotFoundException: com.google.ads.AdView in loader dalvik.system.PathClassLoader[/data/app/com.kmbdev.purrkitty-2.apk]

Here is the xml file with line #51:

  <com.google.ads.AdView
    android:id="@+id/adView"
    android:layout_width="wrap_content"
    android:layout_height="wrap_content"
    android:layout_above="@id/bottom_border"
    android:layout_toLeftOf="@id/right_border"
    ads:adSize="BANNER"
    ads:adUnitId="my id"
    ads:loadAdOnCreate="true" />

I have not made any major changes from the original app that is published. I have only added a splash screen and some language strings files and changed the version to 1.2, the published app is version 1.1. I was wondering why this app will no longer run.

I have tried again, here is the log:

04-11 12:13:21.474: D/AndroidRuntime(282): Shutting down VM
04-11 12:13:21.474: W/dalvikvm(282): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-11 12:13:21.644: E/AndroidRuntime(282): FATAL EXCEPTION: main
04-11 12:13:21.644: E/AndroidRuntime(282): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.kmbdev.purrkitty/com.kmbdev.purrkitty.Cat1}: android.view.InflateException: Binary XML file line #52: Error inflating class com.google.ads.AdView
04-11 12:13:21.644: E/AndroidRuntime(282):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-11 12:13:21.644: E/AndroidRuntime(282):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-11 12:13:21.644: E/AndroidRuntime(282):  at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-11 12:13:21.644: E/AndroidRuntime(282):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-11 12:13:21.644: E/AndroidRuntime(282):  at android.os.Handler.dispatchMessage(Handler.java:99)
04-11 12:13:21.644: E/AndroidRuntime(282):  at android.os.Looper.loop(Looper.java:123)
04-11 12:13:21.644: E/AndroidRuntime(282):  at android.app.ActivityThread.main(ActivityThread.java:4627)
04-11 12:13:21.644: E/AndroidRuntime(282):  at java.lang.reflect.Method.invokeNative(Native Method)
04-11 12:13:21.644: E/AndroidRuntime(282):  at java.lang.reflect.Method.invoke(Method.java:521)
04-11 12:13:21.644: E/AndroidRuntime(282):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-11 12:13:21.644: E/AndroidRuntime(282):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-11 12:13:21.644: E/AndroidRuntime(282):  at dalvik.system.NativeStart.main(Native Method)
04-11 12:13:21.644: E/AndroidRuntime(282): Caused by: android.view.InflateException: Binary XML file line #52: Error inflating class com.google.ads.AdView
04-11 12:13:21.644: E/AndroidRuntime(282):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:576)
04-11 12:13:21.644: E/AndroidRuntime(282):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
04-11 12:13:21.644: E/AndroidRuntime(282):  at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
04-11 12:13:21.644: E/AndroidRuntime(282):  at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-11 12:13:21.644: E/AndroidRuntime(282):  at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-11 12:13:21.644: E/AndroidRuntime(282):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
04-11 12:13:21.644: E/AndroidRuntime(282):  at android.app.Activity.setContentView(Activity.java:1647)
04-11 12:13:21.644: E/AndroidRuntime(282):  at com.kmbdev.purrkitty.Cat1.onCreate(Cat1.java:25)
04-11 12:13:21.644: E/AndroidRuntime(282):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-11 12:13:21.644: E/AndroidRuntime(282):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-11 12:13:21.644: E/AndroidRuntime(282):  ... 11 more
04-11 12:13:21.644: E/AndroidRuntime(282): Caused by: java.lang.ClassNotFoundException: com.google.ads.AdView in loader dalvik.system.PathClassLoader[/data/app/com.kmbdev.purrkitty-2.apk]
04-11 12:13:21.644: E/AndroidRuntime(282):  at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
04-11 12:13:21.644: E/AndroidRuntime(282):  at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
04-11 12:13:21.644: E/AndroidRuntime(282):  at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
04-11 12:13:21.644: E/AndroidRuntime(282):  at android.view.LayoutInflater.createView(LayoutInflater.java:466)
04-11 12:13:21.644: E/AndroidRuntime(282):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:565)
04-11 12:13:21.644: E/AndroidRuntime(282):  ... 20 more
kmb
  • 73
  • 1
  • 2
  • 9
  • use `com.admob.android.ads.AdView` instead of `com.google.ads.AdView` – ρяσѕρєя K Apr 06 '12 at 15:25
  • solved or not ya still getting error? – ρяσѕρєя K Apr 06 '12 at 15:49
  • `com.google.ads.AdView` is the correct namespace. Did you recently upgrade to r17 of the Android tools? If so, starting with r17 you need to create a libs/ directory in your project and put all jars that you reference into that directory, or else they won't be added when creating the apk. – Eric Leichtenschlag Apr 06 '12 at 16:40
  • Did you upgrade ADT to version 17? See http://stackoverflow.com/questions/9904614/classnotfound-exception-when-using-admob-jar-in-my-android-project – Hounshell Apr 06 '12 at 21:22
  • I have added the log from my last attempt. I have a libs directory and admob jar is there. – kmb Apr 11 '12 at 12:31

5 Answers5

4

I've got the same issue and wasted more than 3 hours to figure it out. Finally, I found the way to make it work.

  1. change sdk name from GoogleAdMobAdsSdk-6.0.0.jar to GoogleAdMobAdsSdk.jar
  2. create "libs" folder under project, copy above sdk in the folder and link the library using Add External JARs.
  3. if not worked, change import class name from com.google.ads.* to com.google.ads.AdRequest, comp.google.ads.AdView, and so on.
San
  • 1,104
  • 3
  • 17
  • 31
  • How exactly do you link the library. I'm still having problems. I changed the name of the sdk and copied it to the libs folder. I went under ad external jars and found the file on my computer. – kmb Apr 23 '12 at 13:00
  • Thanks everyone for you ideas. I finally got it working. Some how there were 2 different jars for admob. 1 one in the libs directory and a different one through add external jar. No sure how that happened. – kmb Apr 24 '12 at 12:37
  • Yes, I solved my problem doing steps 1 and 2. But at step 2, I just copy the `GoogleAdMobAdsSdk.jar` with Copy/Paste in **libs**. How exactly do you "link the library using Add External JARs" in **libs**? I done this in `ProjectName->Properties->Java BuildPath` – AlexAndro May 31 '12 at 10:58
  • thank you - changing the name of the jar and putting it in the lib folder worked. thank you – nurnachman Apr 22 '13 at 19:16
0

Are you sure the manifest has all the tags? (Those of admob). Also in the XML, you need to have a addl tag for xmlns right? Did you specify it?

nithinreddy
  • 6,167
  • 4
  • 38
  • 44
  • Yes, I have check the manifest. I didn't make any changes to it except the version change to 1.2. – kmb Apr 06 '12 at 16:04
  • May be, the problem is with the Admob jar file? You should have moved the jar file later (anytime after publishing the first version). Did you get me? But in that case, you should be getting errors in the source code too (so may be I am wrong) – nithinreddy Apr 07 '12 at 13:56
0

Clean your project, and if you don't have activated the automatic build in Eclipse, make a manual build. It will work.

Ciprian
  • 2,879
  • 3
  • 28
  • 28
0

To fix that problem you just have to link the sdk .jar file in two ways. First, to add it to the libs folder (if you don't have one, create it) and then, right-click on .jar file, go to Build Path->Add to Build Path... Three days to that conclusion.

Juan
  • 1
0

I fixed it by renaming the folder in which the jar file is kept from /lib to /libs.

Raghav Sood
  • 81,899
  • 22
  • 187
  • 195