Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Building with Android 11 results in runtime crash

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

Thread Status:
Not open for further replies.
  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:
    97
    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. unity-richardh

    unity-richardh

    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:
    2
    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:
    30
    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:
    26
    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:
    26
    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:
    65
    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:
    65
    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
     
  20. karyll

    karyll

    Joined:
    Apr 4, 2017
    Posts:
    50
    Same scenario for me: 2019.4, Unity Ads 3.6.1 - only works with target API 29, crashes on API 30.
     
  21. a_strl

    a_strl

    Joined:
    Aug 12, 2019
    Posts:
    7
    I just fixed this issue (on my test device, will see how it will be running in release) by changing the unity ads version from 3.4.7 to 3.4.9. so you can try this one =)
     
    wpbuchanan and karyll like this.
  22. karyll

    karyll

    Joined:
    Apr 4, 2017
    Posts:
    50
    I installed 3.4.9 eventually.

    on 3.6.1 ads were not loaded on Android 8.
     
  23. umair21

    umair21

    Joined:
    Mar 4, 2016
    Posts:
    147
    There's no such version 3.4.9 on Unity's github repository. From where did you get that?
     
  24. carldevelopsforcoffee

    carldevelopsforcoffee

    Joined:
    Sep 20, 2017
    Posts:
    19
    Unity "Advertisement 3.4.9" is available on Unity's Package Manager.

    My issue is that Google Mobile Ads is not compatible with Advertisement 3.4.9. I am currently on Google Mobile Ads 2.4.7 that uses Unity Ads 3.4.8 (this version is where I get Fatal Exceptions errors).
     
  25. ikhlaqbhutta93

    ikhlaqbhutta93

    Joined:
    Apr 23, 2020
    Posts:
    2
    this issue due to unity ads sdk .You can use latest unity ads sdk from asset store...Thanks me later... :)
     
  26. ArnoldRauers_Tinytouchtales

    ArnoldRauers_Tinytouchtales

    Joined:
    Jan 25, 2015
    Posts:
    33
    @unity-richardh

    This issue is still ongoing with Unity Ads 3.6.0, use Target API 29 to fix it for now.

    Code (CSharp):
    1. java.lang.Error: FATAL EXCEPTION [ConnectivityThread]
    2. Unity version     : 2021.1.5f1
    3. Device model      : Google Pixel 2
    4. Device fingerprint: google/walleye/walleye:11/RP1A.201005.004.A1/6934943:user/release-keys
    5. Build Type        : Release
    6. Scripting Backend : IL2CPP
    7. ABI               : arm64-v8a
    8. Strip Engine Code : true
    9. Caused by
    10.   at android.os.Parcel.createExceptionOrNull (Parcel.java:2373)
    11.   at android.os.Parcel.createException (Parcel.java:2357)
    12.   at android.os.Parcel.readException (Parcel.java:2340)
    13.   at android.os.Parcel.readException (Parcel.java:2282)
    14.   at com.android.internal.telephony.ITelephony$Stub$Proxy.getNetworkTypeForSubscriber (ITelephony.java:8762)
    15.   at android.telephony.TelephonyManager.getNetworkType (TelephonyManager.java:3021)
    16.   at android.telephony.TelephonyManager.getNetworkType (TelephonyManager.java:2985)
    17.   at com.unity3d.ads.connectivity.ConnectivityMonitor.connectionStatusChanged (ConnectivityMonitor.java:162)
    18.   at com.unity3d.ads.connectivity.ConnectivityNetworkCallback.onCapabilitiesChanged (ConnectivityNetworkCallback.java:48)
    19.   at android.net.ConnectivityManager$NetworkCallback.onAvailable (ConnectivityManager.java:3327)
    20.   at android.net.ConnectivityManager$CallbackHandler.handleMessage (ConnectivityManager.java:3607)
    21.   at android.os.Handler.dispatchMessage (Handler.java:106)
    22.   at android.os.Looper.loop (Looper.java:223)
    23.   at android.os.HandlerThread.run (HandlerThread.java:67)
     
    marsac likes this.
  27. ap-unity

    ap-unity

    Unity Technologies

    Joined:
    Aug 3, 2016
    Posts:
    1,519
    @ArnoldRauers_Tinytouchtales and all,

    Thanks for reporting this issue.

    Can you confirm if this issue is still happening with SDK 3.6.2 or above. We did fix an issue related to the ConnectivityMonitor in 3.6.2. The stack trace from that bug looks very similar to the one you shared.

    Please let us know if the issue is still present when using Target API 30.
     
    davidchai6w likes this.
  28. ikhlaqbhutta93

    ikhlaqbhutta93

    Joined:
    Apr 23, 2020
    Posts:
    2
    i have solved my issue by using latest unity SDK from asset store
     
    davidchai6w likes this.
Thread Status:
Not open for further replies.