On the Internet, there are instructions on how to add AdMob ads to the libgdx project, but to Eclipse. And I made a game in Android Studio, I need to add a line (compile 'com.google.android.gms: play-services-ads: 8.4.0') in gradle, but where I didn’t insert everywhere the error crashes (inserted into project ( ": android") {// dependencies {). In eclipse, instead, you had to specify a folder (google_play_services). here is my grad.android:

buildscript { repositories { mavenCentral() mavenLocal() } dependencies { classpath 'com.android.tools.build:gradle:1.1.0' } } allprojects { apply plugin: "eclipse" apply plugin: "idea" version = '1.0' ext { appName = 'Boom-Boom' gdxVersion = '0.9.9' roboVMVersion = '0.0.13' } repositories { mavenLocal() mavenCentral() maven { url "https://oss.sonatype.org/content/repositories/snapshots/" } maven { url "https://oss.sonatype.org/content/repositories/releases/" } } } project(":desktop") { apply plugin: "java" dependencies { compile project(":core") compile "com.badlogicgames.gdx:gdx-backend-lwjgl:$gdxVersion" compile "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-desktop" } } project(":android") { apply plugin: "android" configurations { natives } dependencies { compile project(":core") compile "com.badlogicgames.gdx:gdx-backend-android:$gdxVersion" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-armeabi-v7a" natives "com.badlogicgames.gdx:gdx-platform:$gdxVersion:natives-x86" compile fileTree(dir: '../libs', include: '*.jar') compile 'com.google.android.gms:play-services-ads:8.4.0' //тут ошибку выдает } } project(":core") { apply plugin: "java" dependencies { compile "com.badlogicgames.gdx:gdx:$gdxVersion" compile fileTree(dir: '../libs', include: '*.jar') } } tasks.eclipse.doLast { delete ".project" } 
  • one
    Is this a global or local gradle? In general, this should not have caused problems, write (compile 'com.google.android.gms:play-services-ads:8.4.0') in the place of dependencies and make synchronization. Ps gradle local - Silento

3 answers 3

Now admob works with firebase (as far as I know, I connected it exactly a couple of days ago) connect the SDK according to this instruction. And instructions for connecting admob.

For example:

Project-level build.gradle

 dependencies { ... classpath 'com.google.gms:google-services:3.0.0' } 

App-level build.gradle

 ... dependencies { ... compile 'com.google.firebase:firebase-core:9.2.0' compile 'com.google.firebase:firebase-ads:9.2.0' } ... apply plugin: 'com.google.gms.google-services' 

Click Sync Now to sync. And then as usual.

And in general, see firebase, a lot of things can and all in one place.

  • firebase does not make friends with libgdx in this way - Hellraiser
  • To be honest, I did not work with libgdx, but I do not see the difference. Why not make friends? - Vladimir VSeos
  • and you read the instructions on how to add admob in libgdh - everything is different there - Hellraiser
  • this? - Vladimir VSeos
  • what's different? - Vladimir VSeos

I did on the idea, and could not screw the admob on my own. As a result, I found ready source codes for Android Studio, took a working example of InterstitialExample and translated all my code there! And earned.

True, I had to suffer, find all the references to someone else's package, and rename it to my own. And a-studio brutally slows down. Well, okay, here it is, the project on GitHub =)

    here it is shown how to add AdMob to libgdx on Android Studio