flutter-unity-view-widget icon indicating copy to clipboard operation
flutter-unity-view-widget copied to clipboard

UnityMessageManager not working on some Android phones

Open subzero911 opened this issue 4 years ago • 4 comments

On touching an object in Unity view I send a message:

GetComponent<UnityMessageManager>().SendMessageToFlutter("ARObjectTouch");

That's how I catch it in Flutter (on any message finish the activity and go to the next screen).

onUnityMessage: (msg) {
        Get.to(() => UnitySuccessScreen());
      },

We received complaints, that on some phones it doesn't navigate to the next screen, and the Unity game never ends. We tested it out on a variety of devices.

On some Android phones it works:

  • Xiaomi Mi 9 SE (Android 10)
  • Samsung s10e

On some others it's not working:

  • OnePlus 7t (Android 11)
  • OnePlus 5 (Android 10)
  • Xiaomi Redmi note 5 (android 9)
  • Honor 10 (Android 10)
  • Pixel 3a XL (Android 11)

We noticed it after we upgraded our project to null-safety and old plugin version (0.1.6+8) to the latest 4.2.1 It works on iOS devices though. Seems like it's an Android platform-specific issue.

subzero911 avatar Jul 13 '21 16:07 subzero911

Seems like it's the same problem: https://github.com/juicycleff/flutter-unity-view-widget/issues/172 It works on those phones we used for debugging. But provided solutions didn't work for us. We use --no-shrink flag. I also unticked "strip engine code" in Unity, but it had no effect. We can't compile it manually from AS, as we use Codemagic CI. We tried to install aab (converting it to apk), and it is still not working.

subzero911 avatar Jul 15 '21 07:07 subzero911

It tried to add debug / profile / innerTest to the gradle config (according the 6.3), it has no effect

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {            
            signingConfig signingConfigs.release
        }
        debug {
            signingConfig signingConfigs.debug
        }
        profile {
            signingConfig signingConfigs.debug
        }
        innerTest {
            matchingFallbacks = ['debug', 'release']
        }
    }    

subzero911 avatar Jul 19 '21 18:07 subzero911

It tried to add debug / profile / innerTest to the gradle config (according the 6.3), it has no effect

    signingConfigs {
        release {
            keyAlias keystoreProperties['keyAlias']
            keyPassword keystoreProperties['keyPassword']
            storeFile keystoreProperties['storeFile'] ? file(keystoreProperties['storeFile']) : null
            storePassword keystoreProperties['storePassword']
        }
    }
    buildTypes {
        release {            
            signingConfig signingConfigs.release
        }
        debug {
            signingConfig signingConfigs.debug
        }
        profile {
            signingConfig signingConfigs.debug
        }
        innerTest {
            matchingFallbacks = ['debug', 'release']
        }
    }    

for me was this and following the documentation solved my problem: If you use minifyEnabled true in your android/app/build.gradle file, open the android/unityLibrary/proguard-unity.txt and change the following: -keep class com.xraph.plugin.** {*;} and adding this to android/app/build.gradle under the android section:

     lintOptions {
       checkReleaseBuilds false
     }

as for the build I used --no-shrink flag, and it worked.

nimr77 avatar Aug 26 '21 16:08 nimr77

Hello i'm facing the same issue with flutter_unity_widget: ^2022.2.0 i tried --no-shrink and nothing changed i have minifyEnabled false did you find any solutions ??

12265 avatar Oct 01 '23 13:10 12265