HapticFeedback icon indicating copy to clipboard operation
HapticFeedback copied to clipboard

Proguard support for minified releases

Open dhiraj opened this issue 2 years ago • 1 comments

In our app, we're using minified release builds and the HapticFeedback class is not being found after minification, but it works fine in Debug builds without minification.

Exact stack trace looks like this:

Fatal Exception: java.lang.Exception: AndroidJavaException : java.lang.ClassNotFoundException: com.candycoded.hapticfeedbacklibrary.AndroidPlugin
       at java.lang.Class.classForName(java.lang.Class)
       at java.lang.Class.forName(java.lang.Class)
       at com.unity3d.player.UnityPlayer.nativeRender(com.unity3d.player.UnityPlayer)
       at com.unity3d.player.UnityPlayer.x(com.unity3d.player.UnityPlayer)
       at com.unity3d.player.UnityPlayer$F$a.handleMessage(com.unity3d.player.UnityPlayer$F$a)
       at android.os.Handler.dispatchMessage(android.os.Handler)
       at android.os.Looper.loopOnce(android.os.Looper)
       at android.os.Looper.loop(android.os.Looper)
       at com.unity3d.player.UnityPlayer$F.run(com.unity3d.player.UnityPlayer$F)
       at UnityEngine.AndroidJNISafe.CheckException(UnityEngine.AndroidJNISafe)
       at UnityEngine.AndroidJNISafe.FindClass(UnityEngine.AndroidJNISafe)
       at UnityEngine.AndroidJavaObject._AndroidJavaObject(UnityEngine.AndroidJavaObject)
       at CandyCoded.HapticFeedback.Android.HapticFeedback.get_androidPlugin(CandyCoded.HapticFeedback.Android.HapticFeedback)
       at CandyCoded.HapticFeedback.Android.HapticFeedback.PerformHapticFeedback(CandyCoded.HapticFeedback.Android.HapticFeedback)
       at GameContainer.HandleCollision(GameContainer)
       at UnityEngine.Events.UnityEvent`1[T0].Invoke(UnityEngine.Events.UnityEvent`1[T0])
       at UnityAtoms.AtomBaseListener`3[T,E,UER].OnEventRaised(UnityAtoms.AtomBaseListener`3[T,E,UER])
       at UnityAtoms.AtomEvent`1[T].Raise(UnityAtoms.AtomEvent`1[T])
       at UnityAtoms.MonoHooks.MonoHook`4[E,EV,ER,F].OnHook(UnityAtoms.MonoHooks.MonoHook`4[E,EV,ER,F])

Adding this to our proguard-user.txt seems to fix the problem:

-keep public class com.candycoded.hapticfeedbacklibrary.**{
   public *;
}

Is there a better way to solve this problem? Please suggest, thanks!

dhiraj avatar Jan 01 '24 17:01 dhiraj

You'll want to implement a link.xml file for your assembly, read here for more details.

TyelorD avatar Mar 19 '24 21:03 TyelorD