Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Proguard support for minified releases #4

Open
dhiraj opened this issue Jan 1, 2024 · 1 comment
Open

Proguard support for minified releases #4

dhiraj opened this issue Jan 1, 2024 · 1 comment

Comments

@dhiraj
Copy link

dhiraj commented Jan 1, 2024

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!

@TyelorD
Copy link

TyelorD commented Mar 19, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

No branches or pull requests

2 participants