Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

[Solved] Google Play Services + Admob Issues

Discussion in 'Android' started by Ian094, Aug 30, 2014.

  1. Ian094

    Ian094

    Joined:
    Jun 20, 2013
    Posts:
    1,525
    I'm having major problems trying to integrate google play services and admob.

    I'm using the latest google play service plugin (0.0.94) from here and VNITS's admob plugin.

    The problem is that the game keeps crashing when I try to add the neccessay admob dependencies to the manifest.
    Code (CSharp):
    1. <!-- Admob Dependencies -->
    2.  
    3. <meta-data android:name="com.google.android.gms.version"
    4. android:value="@integer/google_play_services_version"/>
    5.  
    6. <activity android:name="com.google.android.gms.ads.AdActivity"
    7. android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
    If I add the admob dependencies as shown above, the ads work but when I press the "sign in" button, the app crashes, bringing up the annoying message "Unfortunately, your app has stopped."

    If I remove the admob plugin and erase the admob dependencies from the manifest then the game doesn't crash when I press the "sign in" button but if i remove the admob plugin and leave the admob dependencies in the manifest, the game still crashes.

    I might be wrong but maybe the admob dependencies in the manifest are somehow clashing with the google play services. I tried this solution but got the exact same result.

    I've been trying to work around this for hours but I just can't seem to get admob to work with google play services without the game crashing.

    Any help would be great.

    Thanks.
     
  2. Ian094

    Ian094

    Joined:
    Jun 20, 2013
    Posts:
    1,525
    Ok, I've finally managed to solve it. Both Google play services and admob are working perfectly without any crashes occurring :)

    For any one going through the same issue, the fix is EXTREMELY simple. Just add the following to your manifest :
    Code (CSharp):
    1. <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\ AppID"/>
    2. <meta-data android:name="com.google.android.gms.appstate.APP_ID" android:value="\ AppID"/>
    Replace "AppID" with your numerical application ID.
     
    ssalimib and NareshKhandla like this.
  3. Marzoa

    Marzoa

    Joined:
    Dec 2, 2012
    Posts:
    50
    The manifest file is generated by Unity, so how you edit it? do you extract the manifest file from the APK or somethign like that?
     
  4. Ian094

    Ian094

    Joined:
    Jun 20, 2013
    Posts:
    1,525
    After making an android build, you'll find the generated manifest file in the StagingArea folder. You can navigate there by going to your projects root folder and clicking on the Temp folder.

    Just drag & drop the "AndroidManifest.xml" to "Plugins/Android" in your assets folder and you should be able to edit it. Now when you make another build, it will use that manifest rather than generating a new one.
     
  5. ALGENERAL

    ALGENERAL

    Joined:
    Apr 20, 2014
    Posts:
    1
    what is the numerical application ID ?

    how to get it ?
     
  6. Ian094

    Ian094

    Joined:
    Jun 20, 2013
    Posts:
    1,525
    You get it from your Google Play Developer Console when you set up Game Services for your app.
     
  7. NareshKhandla

    NareshKhandla

    Joined:
    Aug 6, 2013
    Posts:
    27
    The problem is that the game keeps crashing when I try to add the neccessay admob dependencies to the manifest.
    I have add two line in manifest file .
    1. <meta-data android:name="com.google.android.gms.games.APP_ID" android:value="\ AppID"/>
    2. <meta-data android:name="com.google.android.gms.appstate.APP_ID" android:value="\ AppID"/>
    after still generate same problem of crashing unity. Please help me. Thank you.
     
  8. Ian094

    Ian094

    Joined:
    Jun 20, 2013
    Posts:
    1,525
    Have you added the following to your manifest?

    Code (CSharp):
    1. <meta-data android:name="com.google.android.gms.version"
    2. android:value="@integer/google_play_services_version"/>
    3.  
    4. <activity android:name="com.google.android.gms.ads.AdActivity"
    5. android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
     
  9. joneman

    joneman

    Joined:
    Mar 5, 2016
    Posts:
    8
  10. AscentGames

    AscentGames

    Joined:
    Sep 30, 2018
    Posts:
    2
  11. LAKSHAYMAVIA

    LAKSHAYMAVIA

    Joined:
    Aug 28, 2018
    Posts:
    26
    Thanks. This works.

     
unityunity