0

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 ComponentInfo{net.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)
Serafins
  • 1,237
  • 1
  • 17
  • 36
Bazanye-0Lutu
  • 3
  • 1
  • 1
  • 3
  • 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
  • 3
    Admob is now integrated into Play Services. You should use this in new projects going forward. https://developers.google.com/mobile-ads-sdk/docs/admob/play-migration – Kuffs Dec 15 '13 at 22:46

4 Answers4

1

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

William
  • 20,150
  • 8
  • 49
  • 91
  • 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 http://stackoverflow.com/questions/16588064/how-do-i-add-a-library-project-to-the-android-studio – 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 06: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 http://www.jetbrains.com/idea/webhelp/configuring-module-dependencies-and-libraries.html#d1112130e248 – William Dec 23 '13 at 21:59
1

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.

compile 'com.google.android.gms:play-services-ads:8.4.0'

Sync your project as prompted after which you should be good to go.

Viral Patel
  • 32,418
  • 18
  • 82
  • 110
1

Use this latest library:

implementation 'com.google.android.gms:play-services-ads:19.3.0'

And feel free to read the admob documentation.

zcoop98
  • 2,590
  • 1
  • 18
  • 31
Muhammad Asad
  • 694
  • 6
  • 10
1

I'm using react-native-admob-next and seriously I face lot of problems in implementaion

i do just :-

  1. npm i react-native-admob-next
  2. then open node_modules then find react-native-admob-next/android/build.gradle i change dependencies below is code : -

just add some lines

dependencies {
//noinspection GradleDynamicVersion
// implementation 'com.intellij:annotations:+@jar'
// implementation 'com.google.android.gms:play-services-ads:20.2.0'


implementation 'com.facebook.react:react-native:+'
implementation('com.google.android.gms:play-services-ads:+')
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.ads.mediation:facebook:+'
}
Deepak Singh
  • 749
  • 4
  • 16