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

Unity Widget does not allow the use of the Flutter --profile flag

Open johnfriedrich opened this issue 3 years ago • 2 comments

Describe the bug Not possible to use the Flutter --profile flag to profile the app.

To Reproduce Steps to reproduce the behavior: Try to run the app with the --profile flag

This error pops up:

Running Gradle task 'assembleProfile'...

FAILURE: Build failed with an exception.

* What went wrong:
Could not determine the dependencies of task ':flutter_unity_widget:compileProfileAidl'.
> Could not resolve all task dependencies for configuration ':flutter_unity_widget:profileCompileClasspath'.
   > Could not resolve project :unityLibrary.
     Required by:
         project :flutter_unity_widget
      > No matching variant of project :unityLibrary was found. The consumer was configured to find an API of a component, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'profile', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but:
          - Variant 'debugApiElements' capability android:unityLibrary:unspecified declares an API of a component:
              - Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'profile'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for Android)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'androidJvm')
          - Variant 'debugRuntimeElements' capability android:unityLibrary:unspecified declares a runtime of a component:
              - Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'profile'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for Android)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'androidJvm')
          - Variant 'releaseApiElements' capability android:unityLibrary:unspecified declares an API of a component:
              - Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'profile'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for Android)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'androidJvm')
          - Variant 'releaseRuntimeElements' capability android:unityLibrary:unspecified declares a runtime of a component:
              - Incompatible because this component declares a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'release' and the consumer needed a component, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'profile'
              - Other compatible attributes:
                  - Doesn't say anything about its target Java environment (preferred optimized for Android)
                  - Doesn't say anything about org.jetbrains.kotlin.platform.type (required 'androidJvm')

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 1s
Exception: Gradle task assembleProfile failed with exit code 1

Expected behavior You should be able to profile the Flutter application

Screenshots

Unity (please complete the following information):

  • OS: Windows Standalone Android Studio
  • Version [e.g. 22]

Smartphone (please complete the following information):

Additional context Add any other context about the problem here.

johnfriedrich avatar Feb 01 '22 18:02 johnfriedrich

Solved by adding

buildTypes {
        release {
        }
        debug {
        }
        profile {
        }
        innerTest {
            matchingFallbacks = ['debug', 'release']
        }
    }

into the android part of the unityLibrary project build.gradle.

Maybe this can be added to the post process Unity script

johnfriedrich avatar Feb 03 '22 10:02 johnfriedrich

Thanks, @johnfriedrich will add this. Thanks for the feedback.

juicycleff avatar Feb 09 '22 12:02 juicycleff