flutter-unity-view-widget
                                
                                 flutter-unity-view-widget copied to clipboard
                                
                                    flutter-unity-view-widget copied to clipboard
                            
                            
                            
                        UnityMessageManager not working on some Android phones
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.
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.
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']
        }
    }    
It tried to add
debug / profile / innerTestto the gradle config (according the6.3), it has no effectsigningConfigs { 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.
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 ??