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

Doesn't work on android with unity 2023.1 #218

Open
Tr0sT opened this issue May 30, 2023 · 9 comments
Open

Doesn't work on android with unity 2023.1 #218

Tr0sT opened this issue May 30, 2023 · 9 comments

Comments

@Tr0sT
Copy link

Tr0sT commented May 30, 2023

"failed to verify android.view.view spacemadness.com.lunarconsole.console"

@Zoxan
Copy link

Zoxan commented Jul 17, 2023

Same problem. Android app crashes on launch with error:
FATAL EXCEPTION: main Process: com.myapp.name, PID: 18604 java.lang.VerifyError: Verifier rejected class spacemadness.com.lunarconsole.console.ManagedPlatform: android.view.View spacemadness.com.lunarconsole.console.ManagedPlatform.getTouchRecipientView() failed to verify: android.view.View spacemadness.com.lunarconsole.console.ManagedPlatform.getTouchRecipientView(): [0x4] returning 'Reference: com.unity3d.player.UnityPlayer', but expected from declaration 'Reference: android.view.View' (declaration of 'spacemadness.com.lunarconsole.console.ManagedPlatform' appears in base.apk!classes2.dex) at spacemadness.com.lunarconsole.console.NativeBridge$2.execute(NativeBridge.java:89) at spacemadness.com.lunarconsole.concurrent.DispatchTask.run(DispatchTask.java:66) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:214) at android.app.ActivityThread.main(ActivityThread.java:7050) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:965)

Unity 2023.1.3
LunarConsole 1.8.5

@orionsdev
Copy link

I have the same issue, my game crashes on start, please help!
Crash log:
1701493362342

@VladTempest
Copy link

Yep, same problem. Any solution?

@romanchikovboris
Copy link

Same problem

@dogramacigokhan
Copy link

The issue happens because the native UnityPlayer class that the plugin tries to cast to View no longer extends the FrameLayout, instead it declares it as an internal field to be accessed. As a workaround, I changed the native ManagedPlatform as below to make the getTouchRecipientView work as expected. If you don't want to go through the hassle of building, I'm also sharing the modified lunar-console.aar file for the free version as a drag and drop replacement for Unity 2023+, hope it works.

NOTE: unityPlayer.getFrameLayout() worked nicely for me, but it's just a workaround, and in an empty project for some reason it couldn't receive the touch events, maybe because of the structure of the views were unexpected, but you can give it a try in any case.

lunar-console.zip - Drag & drop the .aar to [PluginPath]\LunarConsole\Editor\Android.

package spacemadness.com.lunarconsole.console;

import android.app.Activity;
import android.view.View;

import com.unity3d.player.UnityPlayer;

import java.lang.reflect.Field;
import java.util.Map;

import spacemadness.com.lunarconsole.debug.Log;

import static spacemadness.com.lunarconsole.debug.Tags.PLUGIN;

public class ManagedPlatform implements Platform {
    private final UnityScriptMessenger scriptMessenger;

    public ManagedPlatform(String target, String method) {
        scriptMessenger = new UnityScriptMessenger(target, method);
    }

    @Override
    public View getTouchRecipientView() {
        Activity activity = UnityPlayer.currentActivity;
        if (activity == null) {
            Log.e(PLUGIN, "UnityPlayer.currentActivity is null");
            return null;
        }

        UnityPlayer unityPlayer = null;

        try {
            Field unityPlayerField = activity.getClass().getDeclaredField("mUnityPlayer");
            unityPlayerField.setAccessible(true);
            unityPlayer = (UnityPlayer) unityPlayerField.get(activity);
        } catch (Exception e) {
            Log.e(PLUGIN, "Error while getting UnityPlayer instance: %s", e);
        }

        if (unityPlayer == null) {
            Log.e(PLUGIN, "UnityPlayer instance is null");
            return null;
        }

        return unityPlayer.getFrameLayout();
    }

    @Override
    public void sendUnityScriptMessage(String name, Map<String, Object> data) {
        try {
            scriptMessenger.sendMessage(name, data);
        } catch (Exception e) {
            Log.e(PLUGIN, "Error while sending Unity script message: name=%s param=%s", name, data);
        }
    }
}

@jandulio
Copy link

After this fix, the console now works on Android for me, but I receive nonstop errors:
"UInt (94) There is no compatible format on this platform or this fallback to a compatible format is disabled in the import inspector.
RenderTexture.Create failed: depth/stencil format unsupported - D32 SFloat 28"

Using Unity 6 LTS and Samsung Galaxy S9.

Any ideas?

@jandulio
Copy link

After this fix, the console now works on Android for me, but I receive nonstop errors: "UInt (94) There is no compatible format on this platform or this fallback to a compatible format is disabled in the import inspector. RenderTexture.Create failed: depth/stencil format unsupported - D32 SFloat 28"

Using Unity 6 LTS and Samsung Galaxy S9.

Any ideas?

Updated to Unity 6 (6000.0.31f1) and it fixed my issues.

@ssnd292
Copy link

ssnd292 commented Jan 14, 2025

@dogramacigokhan I think the issue here is that Unity changed who inputs are read. Maybe its also something on the android side as well.

In any case, if anyone has some straight forward advice how to fix at least the crashing on the pro I'd be happy.

@ssnd292
Copy link

ssnd292 commented Jan 14, 2025

If you are concerend with liability - I tried sending a mail to @weeeBox but his gmail returns

[<[email protected]>](mailto:[email protected]): host gmail-smtp-in.l.google.com[***.***.***.**] said: 550-5.7.26 Your email has been blocked because the sender is unauthenticated.

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

No branches or pull requests

8 participants