Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Crash during init of UnityAds (Android)

Discussion in 'Unity Ads & User Acquisition' started by liortal, Jun 5, 2016.

  1. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,555
    Hey,

    We are seeing random crashes during the initialization of UnityAds on devices.
    * The version we use is 1.5.6-r2 (we are using UnityAds using mediation, through Fyber).

    Here is the crash:
    I have traced the code that is crashing, it seems that File.listFiles() may return null in some cases. The code then tries to iterate that null array:
    Code (CSharp):
    1. File[] fileList;
    2. FilenameFilter filter;
    3. File[] fileList;
    4. if (_cacheDirectory.getAbsolutePath().endsWith("UnityAdsVideoCache"))
    5. {
    6.   UnityAdsDeviceLog.debug("Unity Ads cache: checking cache directory " + _cacheDirectory.getAbsolutePath());
    7. fileList = _cacheDirectory.listFiles();
    8. }
    9. else
    10. {
    11.   UnityAdsDeviceLog.debug("Unity Ads cache: checking app directory for Unity Ads cached files");
    12.   filter = new FilenameFilter()
    13.   {
    14.     public boolean accept(File dir, String filename)
    15.     {
    16.       boolean filter = filename.startsWith("UnityAds-");
    17.       UnityAdsDeviceLog.debug("Unity Ads cache: filtering result for file: " + filename + ", " + filter);
    18.       return filter;
    19.     }
    20.   };
    21. fileList = _cacheDirectory.listFiles(filter);
    22. }
    23. for (File cacheFile : fileList)
    24. {
    25.     ....
    26.     }
    27. }
    Here's the docs for listFiles() - https://docs.oracle.com/javase/7/docs/api/java/io/File.html#listFiles()

    Is this a known issue? has anyone else run into this?
    Is this going to be fixed? or already fixed in a newer-released version?

    Thx
    -liortal
     
  2. rasmus-unity

    rasmus-unity

    Unity Technologies

    Joined:
    Aug 15, 2014
    Posts:
    1,312
    Are you seeing this on multiple different devices?

    -Rasmus
     
  3. liortal

    liortal

    Joined:
    Oct 17, 2012
    Posts:
    3,555
    Yes, here are examples of devices i saw it occurred on:
    • OnePlus A0001
    • Samsung GT-I9195
    • Sony D6603
    • HTC HTC One_M8
    • HTC HTC_M8x
    • HTC HTC Butterfly 2
    • HUAWEI HUAWEI GRA-L09
    I have submitted a PR to the UnityAds repo yesterday, hopefully this does resolve the issue and can be merged into the code: https://github.com/Applifier/unity-ads/pull/89