Search Unity

  1. Unity 2020.2 has been released.
    Dismiss Notice
  2. 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

Building with Android 11 results in runtime crash

Discussion in 'Unity Ads' started by Pedroatg, Jun 26, 2020.

  1. Pedroatg

    Pedroatg

    Joined:
    Oct 30, 2015
    Posts:
    12
    We downloaded the new Android 11 SDK to test our apps on the new OS, but UnityAds keeps crashing with the following error:

    Code (CSharp):
    1. java.lang.SecurityException: getDataNetworkTypeForSubscriber
    2.         at android.os.Parcel.createExceptionOrNull(Parcel.java:2373)
    3.         at android.os.Parcel.createException(Parcel.java:2357)
    4.         at android.os.Parcel.readException(Parcel.java:2340)
    5.         at android.os.Parcel.readException(Parcel.java:2282)
    6.         at com.android.internal.telephony.ITelephony$Stub$Proxy.getNetworkTypeForSubscriber(ITelephony.java:8711)
    7.         at android.telephony.TelephonyManager.getNetworkType(TelephonyManager.java:2945)
    8.         at android.telephony.TelephonyManager.getNetworkType(TelephonyManager.java:2909)
    9.         at com.unity3d.services.core.connectivity.ConnectivityMonitor.connectionStatusChanged(ConnectivityMonitor.java:162)
    10.         at com.unity3d.services.core.connectivity.ConnectivityNetworkCallback.onCapabilitiesChanged(ConnectivityNetworkCallback.java:48)
    11.         at android.net.ConnectivityManager$NetworkCallback.onAvailable(ConnectivityManager.java:3346)
    12.         at android.net.ConnectivityManager$CallbackHandler.handleMessage(ConnectivityManager.java:3626)
    13.         at android.os.Handler.dispatchMessage(Handler.java:106)
    14.         at android.os.Looper.loop(Looper.java:223)
    15.         at android.os.HandlerThread.run(HandlerThread.java:67)

    It seems that it requires the READ_PHONE_STATE permission, but this wasn't required in the previous OS versions. Is there a way to get around this issue without having to request an adicional permission from the user?
     
  2. sbankhead

    sbankhead

    Unity Technologies

    Joined:
    Jul 27, 2014
    Posts:
    94
    Can you provide some details about your setup? What version of the sdk your using? Can you reproduce this is a sample project outside of your app?
     
  3. Pedroatg

    Pedroatg

    Joined:
    Oct 30, 2015
    Posts:
    12
    I'm running the project in Android Studio 4.0 targeting API level 30 and using UnityAds 3.4.6.

    Here is a simple project where you replicate the issue: https://gitlab.com/marcobat1989/testads/-/tree/master
    You have to add a GameId to the MainActivity before running, it should crash after a couple of seconds from opening the app.

    The issue goes away if you go to the app's settings and give the READ_PHONE_STATE permission. If you change to a previous Android API level (e.g. 29) the crash does not occur.
     
  4. richardhawkins

    richardhawkins

    Unity Technologies

    Joined:
    Jun 14, 2017
    Posts:
    1
    Hi Pedroatg, we have reproduced the issue using the provided project and are currently investigating a solution. I'll reply here when we have more information.
     
  5. Pedroatg

    Pedroatg

    Joined:
    Oct 30, 2015
    Posts:
    12
    Any news regarding this issue?
     
  6. arbelsolutions

    arbelsolutions

    Joined:
    Aug 3, 2020
    Posts:
    3
    Any news?
    I have the exact problem.
    All ok when I take your dependency out.
    Please inform me so I can continue working with you.

    Best regards
    Arbel
     
  7. arbelsolutions

    arbelsolutions

    Joined:
    Aug 3, 2020
    Posts:
    3
    Fatal Exception: java.lang.SecurityException: getDataNetworkTypeForSubscriber
    at android.os.Parcel.createExceptionOrNull(Parcel.java:2373)
    at android.os.Parcel.createException(Parcel.java:2357)
    at android.os.Parcel.readException(Parcel.java:2340)
    at android.os.Parcel.readException(Parcel.java:2282)
    at com.android.internal.telephony.ITelephony$Stub$Proxy.getNetworkTypeForSubscriber(ITelephony.java:8722)
    at android.telephony.TelephonyManager.getNetworkType(TelephonyManager.java:2945)
    at android.telephony.TelephonyManager.getNetworkType(TelephonyManager.java:2909)
    at com.unity3d.services.core.connectivity.ConnectivityMonitor.connectionStatusChanged(ConnectivityMonitor.java:162)
    at com.unity3d.services.core.connectivity.ConnectivityNetworkCallback.onCapabilitiesChanged(ConnectivityNetworkCallback.java:48)
    at android.net.ConnectivityManager$NetworkCallback.onAvailable(ConnectivityManager.java:3347)
    at android.net.ConnectivityManager$CallbackHandler.handleMessage(ConnectivityManager.java:3627)
    at android.os.Handler.dispatchMessage(Handler.java:106)
    at android.os.Looper.loop(Looper.java:223)
    at android.os.HandlerThread.run(HandlerThread.java:67)
     
  8. wocaonimalegebibi

    wocaonimalegebibi

    Joined:
    Aug 4, 2020
    Posts:
    1
    I met the same problem
     
  9. Pedroatg

    Pedroatg

    Joined:
    Oct 30, 2015
    Posts:
    12
    I tried opening a ticket, I was told that they haven't fixed it yet and to expect a reply here.
    In the mean time, they recommended targeting Android 10 instead of 11...
     
  10. aklimovGismart

    aklimovGismart

    Joined:
    Aug 5, 2020
    Posts:
    1
    Moving my app the latest target sdk (30) and faced with the same issue, why don't you check connectivity in some other way?
     
  11. Pedroatg

    Pedroatg

    Joined:
    Oct 30, 2015
    Posts:
    12
    They released a new version (3.4.8), it seems to have fixed it.
     
  12. arbelsolutions

    arbelsolutions

    Joined:
    Aug 3, 2020
    Posts:
    3
    Last version is
    implementation 'com.google.ads.mediation:unity:3.4.6.1'
     
  13. unity_G8Q03EtzOQk4Xw

    unity_G8Q03EtzOQk4Xw

    Joined:
    Sep 11, 2020
    Posts:
    1
    I'm getting a lot of crashes right now.
    I'm using Google AdMob Unity SDK v5.3.0 (Unity 2018.4.23f1) with Unity mediation adapter version:
    com.google.ads.mediation:unity:3.4.6.1
     
  14. savvyquest

    savvyquest

    Joined:
    Dec 4, 2019
    Posts:
    1
    I have the same error ... Still not resolved?
    Edit: all works in unity 2019.4.10f1
     
    Last edited: Sep 21, 2020
  15. MochiBits

    MochiBits

    Joined:
    Mar 11, 2014
    Posts:
    27
    Started noticing more reported crashes on the Play Dashboard since Android 11 came out. Traced it back to this same error. Using 2018.4.12f1

    Update: (Workaround) I'm using ad mediation, so I was able to trace it back to Unity Ads. Unity Ads On = Yes Crashing... Unity Ads Off = No Crashing.
     
    Last edited: Sep 24, 2020
  16. dave_oak

    dave_oak

    Joined:
    Oct 7, 2015
    Posts:
    16
    My latest build is having the same problem on Android 11 devices. I'm using Unity 2018.4.27f1and targeting API level 28.
     
  17. dave_oak

    dave_oak

    Joined:
    Oct 7, 2015
    Posts:
    16
    In the change log for Unity Monetization (Unity Ads):

    Version: 3.4.8 • Aug 7, 2020
    3.4.8 [iOS] Enable support for SKAdNetwork
    [iOS] Enable support for App Tracking Transparency
    [Android] Fix crash in Android API level 30 with getNetworkType
     
    NhatNhan likes this.
  18. BeorGames

    BeorGames

    Joined:
    Jul 28, 2018
    Posts:
    4
    Hi! I'm facing the same problem using Unity 2020.1.16f1, targeting API 30 and Unity Advertisement version 3.6.1
     
  19. BeorGames

    BeorGames

    Joined:
    Jul 28, 2018
    Posts:
    4
    Edit: I've changed the target for API 29 and it worked! For some reason Google has refused my update but I'm working on it, at least it's not crashing on Android 11 anymore
     
unityunity