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

Android admob app crash..

Discussion in 'Android' started by 1WeekGames, Dec 6, 2015.

  1. 1WeekGames

    1WeekGames

    Joined:
    Dec 6, 2015
    Posts:
    2
    I am following the next tutorial in a empty scene..

    https://developers.google.com/admob/android/games#unity

    When I deploy the proyect to an android device it crash.. I try with a Nexus 5, 6, 7 emulator device.
    In the unity editor works fine but it doesn't show any ads..

    Unity3d version 5.2.3f1
    Google Play Services Rev. 28
    Google Mobile Ads Unity Plugin v2.3.1


    I try differents androidmanifest files..

    Adding

    <activityandroid:name="com.unity3d.player.UnityPlayerNativeActivity"
    android:label="@String/app_name">
    <intent-filter>
    <actionandroid:name="android.intent.action.MAIN"/>
    <categoryandroid:name="android.intent.category.LAUNCHER"/>
    </intent-filter>
    <meta-dataandroid:name="unityplayer.UnityActivity"android:value="true"/>
    <meta-dataandroid:name="unityplayer.ForwardNativeEventsToDalvik"
    android:value="true"
    /></activity>

    or just adding this sentece to the main activity

    <meta-dataandroid:name="unityplayer.ForwardNativeEventsToDalvik"
    android:value="true"
    />

    or adding nothing. Nothings work... This is my code.

    usingGoogleMobileAds.Api;

    private void RequestBanner(){
    #if UNITY_ANDROID
    string adUnitId ="ca-app-pub-xxxxxxxxxxxxxxxxxxxxxx";
    #elif UNITY_IPHONE
    string adUnitId ="INSERT_IOS_BANNER_AD_UNIT_ID_HERE";
    #else
    string adUnitId ="ca-app-pub-xxxxxxxxxxxxxxxxxxxxxx";
    #endif

    // Create a 320x50 banner at the top of the screen.
    BannerView bannerView =newBannerView(adUnitId,AdSize.Banner,AdPosition.Top);
    // Create an empty ad request.
    AdRequest request =newAdRequest.Builder().Build();
    // Load the banner with the request.
    bannerView.LoadAd(request);}

    The app crash in thes last line.. bannerView.LoadAd(request);

    The crash log..

    --------- beginning of crash

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: FATAL EXCEPTION: main

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: Process: com.rete.adfs, PID: 2548

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: java.lang.Error: FATAL EXCEPTION [main]

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: Unity version : 5.2.3f1

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: Device model : unknown Android SDK built for x86

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: Device fingerprint: generic_x86/sdk_google_phone_x86/generic_x86:6.0/MASTER/2401146:eng/test-keys

    12-06 16:49:53.048 2548 2548 E AndroidRuntime:

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/util/SimpleArrayMap;

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at com.google.android.gms.ads.internal.zzq.<init>(Unknown Source)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at com.google.android.gms.ads.internal.zzq.<init>(Unknown Source)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at com.google.android.gms.ads.internal.zzb.<init>(Unknown Source)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at com.google.android.gms.ads.internal.zzc.<init>(Unknown Source)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at com.google.android.gms.ads.internal.zzf.<init>(Unknown Source)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at com.google.android.gms.ads.internal.client.zze.zza(Unknown Source)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at com.google.android.gms.ads.internal.client.zzz.zzdb(Unknown Source)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at com.google.android.gms.ads.internal.client.zzz.zzda(Unknown Source)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at com.google.android.gms.ads.internal.client.zzz.zza(Unknown Source)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at com.google.android.gms.ads.BaseAdView.loadAd(Unknown Source)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at com.google.android.gms.ads.AdView.loadAd(Unknown Source)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at com.google.unity.ads.Banner$2.run(Banner.java:157)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at android.os.Handler.handleCallback(Handler.java:739)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at android.os.Handler.dispatchMessage(Handler.java:95)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at android.os.Looper.loop(Looper.java:148)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at android.app.ActivityThread.main(ActivityThread.java:5417)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at java.lang.reflect.Method.invoke(Native Method)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:726)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:616)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.v4.util.SimpleArrayMap" on path: DexPathList[[zip file "/data/app/com.rete.adfs-1/base.apk"],nativeLibraryDirectories=[/data/app/com.rete.adfs-1/lib/x86, /data/app/com.rete.adfs-1/base.apk!/lib/x86, /vendor/lib, /system/lib]]

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:511)

    12-06 16:49:53.048 2548 2548 E AndroidRuntime: at java.lang.ClassLoader.loadClass(ClassLoader.java:469)



    I don't know what to do..
    Sorry for my english
    Thanks in advance!!
     
    Last edited: Dec 6, 2015
  2. 1WeekGames

    1WeekGames

    Joined:
    Dec 6, 2015
    Posts:
    2
    At least!!! I find the solution, just in case someone happend the same..

    In the assets folder "assets/Plugins/Android/"

    You have to copy the files

    "\AppData\Local\Android\sdk\extras\android\support\v4\"

    Admob has a compatibility problem. Need to include dependencies to android support libraries.
     
    TheProGamer01, plasticYoda and ArysX like this.
  3. Venatal

    Venatal

    Joined:
    Nov 12, 2015
    Posts:
    134
    That did not solve the problem for me, the game still crashed.
     
  4. ArysX

    ArysX

    Joined:
    Mar 4, 2015
    Posts:
    3
    BIG THX 1WeekGames
     
  5. bigjobs

    bigjobs

    Joined:
    Feb 24, 2016
    Posts:
    14
  6. LAKSHAYMAVIA

    LAKSHAYMAVIA

    Joined:
    Aug 28, 2018
    Posts:
    26
    This tutorial solve the problem for me. After integrating admob 2019 my app crashed but not anymore.
     
  7. Blacklister001

    Blacklister001

    Joined:
    Jun 13, 2016
    Posts:
    5
    Which build system did you use? Internal or Gradle?
     
  8. LAKSHAYMAVIA

    LAKSHAYMAVIA

    Joined:
    Aug 28, 2018
    Posts:
    26
    Internal . I am not able to build any app with gradle in unity till now.
     
unityunity