Could not find class 'com.google.android.gms.ads.AdView
Could not find class 'com.google.android.gms.ads.AdView
I'm using Android Studio. I have added the googleAdMobAdsdk6-4-1.jar to the project in my previously added libs folder. I can expand the library file and actually navigate to the AdView class. It compiles with no problem but when I run it It crashes. Any assistance appreciated.
12-15 21:35:40.581 5375-5375/? E/dalvikvm﹕ Could not find class 'com.google.android.gms.ads.AdView', referenced from method net.kritico.todolist.ToDoListActivity.onCreate
12-15 21:35:40.581 5375-5375/? W/dalvikvm﹕ VFY: unable to resolve new-instance 996 (Lcom/google/android/gms/ads/AdView;) in Lnet/kritico/todolist/ToDoListActivity;
12-15 21:35:40.581 5375-5375/? D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x0037
12-15 21:35:40.585 5375-5375/? D/dalvikvm﹕ DexOpt: unable to opt direct call 0x2034 at 0x39 in Lnet/kritico/todolist/ToDoListActivity;.onCreate
12-15 21:35:40.585 5375-5375/? I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0b0b at 0x47 in Lnet/kritico/todolist/ToDoListActivity;.onCreate
12-15 21:35:40.585 5375-5375/? D/dalvikvm﹕ DexOpt: unable to opt direct call 0x2031 at 0x5c in Lnet/kritico/todolist/ToDoListActivity;.onCreate
12-15 21:35:40.597 5375-5375/? I/dalvikvm﹕ DexOpt: unable to optimize static field ref 0x0b0a at 0x5f in Lnet/kritico/todolist/ToDoListActivity;.onCreate
12-15 21:35:40.765 5375-5375/? D/AndroidRuntime﹕ Shutting down VM
12-15 21:35:40.765 5375-5375/? W/dalvikvm﹕ threadid=1: thread exiting with uncaught exception (group=0xa617b908)
12-15 21:35:40.789 5375-5375/? E/AndroidRuntime﹕ FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfonet.kritico.todolist/net.kritico.todolist.ToDoListActivity: android.view.InflateException: Binary XML file line #19: Error inflating class fragment
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
at android.app.ActivityThread.access$600(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
at android.os.Handler.dispatchMessage(Handler.java:99)
Admob is now integrated into Play Services. You should use this in new projects going forward. developers.google.com/mobile-ads-sdk/docs/admob/play-migration
– Kuffs
Dec 15 '13 at 22:46
2 Answers
2
Your XML references com.google.android.gms.ads.AdView (see stacktrace) which is contained in the Google Play Services library and is how Admob is now packaged.
But your have included Admob-6.4.1 whcih is the old Admob SDK and the Admob classes there are in a different package and have slightly different signatures.
Remove Admob-6.4.1 from your project and use Google play Services instead.
See https://developers.google.com/mobile-ads-sdk/docs/admob/fundamentals#play
I have done that but now I am getting an error "The Google Play services resources were not found" I am using android studio and all responses about this error on the net are for eclipse.
– Bazanye-0Lutu
Dec 17 '13 at 20:34
How do I add resources in android studio?
– Bazanye-0Lutu
Dec 17 '13 at 20:44
See stackoverflow.com/questions/16588064/…
– William
Dec 17 '13 at 22:54
William I have tried that but my Project Structure dialog box has no "Import module" menu option. It only has "+" sign which opens up a New Module dialog. Im using android 0.3.7.
– Bazanye-0Lutu
Dec 23 '13 at 6:18
Sorry that was a poor link. You want to add the Play Services library as a dependency of your module. See the "Adding existing libraries to module dependencies" section of jetbrains.com/idea/webhelp/…
– William
Dec 23 '13 at 21:59
Remove the jar from your libs folder (That sdk is now deprecated). You should use Google play services.
After removing the jar. Clean your project and add the following under dependencies
in your app level build.gradle
.
dependencies
build.gradle
compile 'com.google.android.gms:play-services-ads:8.4.0'
Sync your project as prompted after which you should be good to go.
By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.
I don't know how it is in Android Studio, but in Eclipse you should click right on project ->Properties->Android and on the bottom add library. Maybe in Android Studio is similar
– Serafins
Dec 15 '13 at 22:39