Search Unity

Question When I make a build targeting API level 31 it crashes instantly, how can I know what is the cause?

Discussion in 'Android' started by NogeGames, Jan 31, 2023.

  1. NogeGames

    NogeGames

    Joined:
    Jun 16, 2016
    Posts:
    5
    When I build for android targeting API level 30, my app works perfectly. But when I make a build targeting API level 31 it crashes instantly when you open it, it doesn't even show the splash screen.
    I tried to find some clues using logcat but it seems that there aren't error messages related to my app. What can I do?

    I have also tried targeting API level 33 and the same thing happens. I don't know how to debug this, I can't find any hint about what is causing the crash, any idea?

    I'm using Unity2021.3.17, and I have a few plugins integrated in the project like AdMob and GooglePlayGames.
     
  2. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,918
    If there's a crash, there should be crash log in the logcat if you filter by the process id of your app.
     
    NogeGames likes this.
  3. NogeGames

    NogeGames

    Joined:
    Jun 16, 2016
    Posts:
    5
    Oh, after searching with the process id in the full logcat I found this:

    I have no idea what flags is this talking about, but at least we have an error message.
     
    Last edited: Feb 1, 2023
  4. Tomas1856

    Tomas1856

    Unity Technologies

    Joined:
    Sep 21, 2012
    Posts:
    3,918
    The issue is inside androidx.work.impl.utils.ForceStopRunnable, I assume you need to update a dependency which holds this class. According to this https://androidx.de/androidx/work/impl/utils/ForceStopRunnable.html, it's a part of androidx.work package?

    As can be seen here - https://android.googlesource.com/pl...dx/work/impl/utils/ForceStopRunnable.java#192

    Code (CSharp):
    1.             int flags = FLAG_NO_CREATE;
    2.             if (Build.VERSION.SDK_INT >= 31) {
    3.                 flags |= FLAG_MUTABLE;
    4.             }
    They pass FLAG_MUTABLE flag in latest code.
     
    NogeGames likes this.
  5. NogeGames

    NogeGames

    Joined:
    Jun 16, 2016
    Posts:
    5
    Thanks for your help Tomas! Your replies headed me in the right direction!
    This androidx package was related to Google AdMob, I needed to update AdMob. After updating AdMob and fighting with the compiler for a few hours everything seems to be working.
    Thanks a million!
     
    Tomas1856 likes this.