Android Plugins issue- developer vs non-developer builds

Hello folks,

I’ve built a java plugin for android, based on this plugin: GitHub - Real-Serious-Games/Unity-Android-Plugin-Example: A simple example of an Android specific plugin for Unity3d that uses a WebView to print some html (based on HTML 문서 인쇄  |  Android Developers - I have the INTERNET permission set in the manifest, and i’ve tried it with all permissions, so its not that)

It works fine when i do a development build to the device, but not when i do a regular build.

the plugin is definitely being executed in the non-dev build (logcat shows my debugging but there are no crashes or anything markedly different from the dev build), but the webview never triggers onPageFinish.

My question is, is there a difference in how contexts/activities are handled in dev builds? or some other permissions that are ignored that I need to be aware of?

any clues would be greatly appreciated

for reference my plugin code is here:

I don’t think there’s any option to handle contexts / activities differently, nor should it have any difference on what you’re doing (calling into Java using JNI).

I believe i replied to the same answer today on the Answers site… you can PM me and i can help you diagnose this issue probably.

thanks, I might just do that (the android stuff does my head in… when from start to finish the iOS plugin took 20 minutes). I added logs to the answers site. if that doesn’t help, then I’ll create a new project with just the printing stuff in it and see if you cant recreate it.

From the logs and the code examples, it’s not clear what you expect the logs to actually show.
The “non working” log also shows some prints from the plugin:

The next log is a bunch of errors saying that some java classes could not be initialized. might be related, although still not clear how it’s related to Development builds.

Ok so, while trolling through some unrelated WebView issues (people trying to diagnose why they are having issues) someone mentioned crashes when the webview was modified from threads outside of the main UI thread. So I thought perhaps theres some jiggerypokery going on in release vs debug builds … and lo, running the entire DoPrint() method from the UI thread sorts it.

    public void DoPrint(final String html_body,final String doc_name) {
      
        ((Activity)context).runOnUiThread(new Runnable(){
            @Override
            public void run() {
            <etc>

seemed to do the trick.

Thanks for your help!

1 Like