Search Unity

Question Proguard / R8 Configuration Help Needed

Discussion in 'Android' started by Rajmahal, Apr 18, 2021.

  1. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Hi,

    I'm running into an issue where Proguard / R8 is stripping out a library that I need (Anroid UniPermission). The package name is net.sanukin.PermissionManager.

    I'm pretty sure I need to add the instruction to keep the code in my Proguard settings file. However, I can't find clear instructions on how to do this for a Unity project. Can someone please provide some step-by-step instructions or a link to a guide that explains this?
     
  2. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    The error I get in logcat is:

    ******

    2021/04/18 11:06:36.719 2466 3093 Error Unity AndroidJavaException: java.lang.ClassNotFoundException: net.sanukin.PermissionManager
    2021/04/18 11:06:36.719 2466 3093 Error Unity java.lang.ClassNotFoundException: net.sanukin.PermissionManager
    2021/04/18 11:06:36.719 2466 3093 Error Unity at java.lang.Class.classForName(Native Method)
    2021/04/18 11:06:36.719 2466 3093 Error Unity at java.lang.Class.forName(Class.java:454)
    2021/04/18 11:06:36.719 2466 3093 Error Unity at com.unity3d.player.UnityPlayer.nativeRender(Native Method)
    2021/04/18 11:06:36.719 2466 3093 Error Unity at com.unity3d.player.UnityPlayer.access$300(Unknown Source:0)
    2021/04/18 11:06:36.719 2466 3093 Error Unity at com.unity3d.player.UnityPlayer$e$1.handleMessage(Unknown Source:83)
    2021/04/18 11:06:36.719 2466 3093 Error Unity at android.os.Handler.dispatchMessage(Handler.java:102)
    2021/04/18 11:06:36.719 2466 3093 Error Unity at android.os.Looper.loop(Looper.java:246)
    2021/04/18 11:06:36.719 2466 3093 Error Unity at com.unity3d.player.UnityPlayer$e.run(Unknown Source:20)
    2021/04/18 11:06:36.719 2466 3093 Error Unity Caused by: java.lang.ClassNotFoundException: net.sanukin.PermissionManager
     
  3. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,735
  4. Rajmahal

    Rajmahal

    Joined:
    Apr 20, 2011
    Posts:
    2,101
    Thanks ... I did see that. The challenge is that it's not always clear exactly what to type in the proguard-user.txt file. That being said, I was able to find a workaround for this issue by deleting the android unipermission asset and replacing it with another asset that did the same thing and that one had an explanation of what to include in the proguard txt file.
     
  5. Aurimas-Cernius

    Aurimas-Cernius

    Unity Technologies

    Joined:
    Jul 31, 2013
    Posts:
    3,735
    The Java APIs you use from C# have to be prevented from minification. As for what to write in those files, the official proguard documentation is as best as you can get:
    https://www.guardsquare.com/en/products/proguard/manual/usage
     
    Rajmahal likes this.