ThexXTURBOXx / flutter_web_auth_2

Flutter plugin for authenticating a user with a web service
https://pub.dev/packages/flutter_web_auth_2
MIT License
51 stars 50 forks source link

Upgrading to oauth2_client 3.0.0 (using flutter_web_auth_2) fails #12

Closed gregertw closed 1 year ago

gregertw commented 1 year ago

Description

When upgrading oauth2_client to 3.0.0 that introduces use of flutter_web_auth_2, I get a build error that looks related to making the plugin dependant on kotlin-gradle-plugin 1.7.10:

Running Gradle task 'assembleRelease'...                        

FAILURE: Build failed with an exception.

* What went wrong:
A problem occurred configuring project ':flutter_web_auth_2'.
> Could not resolve all artifacts for configuration ':flutter_web_auth_2:classpath'.
   > Could not resolve org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10.
     Required by:
         project :flutter_web_auth_2
      > The consumer was configured to find a runtime of a component compatible with Java 13, packaged as a jar, and its dependencies declared externally. However we cannot choose between the following variants of org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10:
          - gradle70JavadocElements
          - gradle70RuntimeElements
          - gradle70SourcesElements
          - javadocElements
          - runtimeElementsWithFixedAttribute
          - sourcesElements
        All of them match the consumer attributes:
          - Variant 'gradle70JavadocElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10 declares a runtime of a component, and its dependencies declared externally:
              - Unmatched attributes:
                  - Provides documentation but the consumer didn't ask for it
                  - Provides javadocs but the consumer didn't ask for it
                  - Doesn't say anything about its target Java version (required compatibility with Java 13)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Provides attribute 'org.gradle.plugin.api-version' with value '7.0' but the consumer didn't ask for it
                  - Provides release status but the consumer didn't ask for it
          - Variant 'gradle70RuntimeElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10 declares a runtime of a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
              - Unmatched attributes:
                  - Provides a library but the consumer didn't ask for it
                  - Provides attribute 'org.gradle.jvm.environment' with value 'standard-jvm' but the consumer didn't ask for it
                  - Provides attribute 'org.gradle.plugin.api-version' with value '7.0' but the consumer didn't ask for it
                  - Provides release status but the consumer didn't ask for it
          - Variant 'gradle70SourcesElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10 declares a runtime of a component, and its dependencies declared externally:
              - Unmatched attributes:
                  - Provides documentation but the consumer didn't ask for it
                  - Provides sources but the consumer didn't ask for it
                  - Doesn't say anything about its target Java version (required compatibility with Java 13)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Provides attribute 'org.gradle.plugin.api-version' with value '7.0' but the consumer didn't ask for it
                  - Provides release status but the consumer didn't ask for it
          - Variant 'javadocElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10 declares a runtime of a component, and its dependencies declared externally:
              - Unmatched attributes:
                  - Provides documentation but the consumer didn't ask for it
                  - Provides javadocs but the consumer didn't ask for it
                  - Doesn't say anything about its target Java version (required compatibility with Java 13)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Provides release status but the consumer didn't ask for it
          - Variant 'runtimeElementsWithFixedAttribute' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10 declares a runtime of a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
              - Unmatched attributes:
                  - Provides a library but the consumer didn't ask for it
                  - Provides attribute 'org.gradle.jvm.environment' with value 'standard-jvm' but the consumer didn't ask for it
                  - Provides release status but the consumer didn't ask for it
          - Variant 'sourcesElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10 declares a runtime of a component, and its dependencies declared externally:
              - Unmatched attributes:
                  - Provides documentation but the consumer didn't ask for it
                  - Provides sources but the consumer didn't ask for it
                  - Doesn't say anything about its target Java version (required compatibility with Java 13)
                  - Doesn't say anything about its elements (required them packaged as a jar)
                  - Provides release status but the consumer didn't ask for it
        The following variants were also considered but didn't match the requested attributes:
          - Variant 'apiElementsWithFixedAttribute' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10 declares a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
          - Variant 'gradle70ApiElements' capability org.jetbrains.kotlin:kotlin-gradle-plugin:1.7.10 declares a component compatible with Java 8, packaged as a jar, and its dependencies declared externally:
              - Incompatible because this component declares an API of a component and the consumer needed a runtime of a component
> Failed to notify project evaluation listener.
   > Could not get unknown property 'android' for project ':flutter_web_auth_2' of type org.gradle.api.Project.
   > Could not get unknown property 'android' for project ':flutter_web_auth_2' of type org.gradle.api.Project.

* 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 2s
Running Gradle task 'assembleRelease'...                            3.3s
Gradle task assembleRelease failed with exit code 1
ThexXTURBOXx commented 1 year ago

This is most likely a configuration issue with sourceCompatibility and targetCompatibility on your end. Try changing these values :)

gregertw commented 1 year ago

Thanks for quick response! I don't set these explicitly on my side. I also use the default flutter ext.kotlin_version = '1.6.10' while I see you have bumped to 1.7.10. I have tried to bump both kotlin_version and set compatibility as your plugin without any change, but I don't think it's a good idea to make that a requirement to use the plugin (or at least should be documented). Here's the code https://github.com/gregertw/actingweb_firstapp/tree/beta_channel if you want to have a look.

ThexXTURBOXx commented 1 year ago

Well, any version of Kotlin will be a requirement anyways since the android part of flutter_web_auth_2 is written in Kotlin. And I want to always target the newest version of everything that's available, because that is what most users would want. Alas, I do not have the same issue as you and I am not at home until the start of October. So, until then I am not able to help you in that regard. As soon as I have any updates on this, I will let you know :)

ThexXTURBOXx commented 1 year ago

I just looked at your repo and saw something that might fix some errors: You are still using jcenter which has been deprecated more than a year ago and is not available anymore since a few months ago. Please try changing jcenter to mavenCentral in all build.gradle files and try again :)

gregertw commented 1 year ago

Nice catch, thanks! However, it did no difference. Unfortunately, reusing the compatibility and kotlin_version from your build.gradle didn't fix the problem. Also, I'm not comfortable deviating from flutter standard config to make one plugin dependency work.

gregertw commented 1 year ago

I will then need to use the pre-3.0.0 version of oauth2_client that depends on flutter_web_auth. Would appreciate if you look at it when you have the chance. Of course, this could also be something related to oauth2_client, but I'm not sure how to debug that.

ThexXTURBOXx commented 1 year ago

Okay, one last try without me trying anything out myself: https://stackoverflow.com/a/73349774/5894824 I also had something like that in mind. If that also does not help, I will reopen this issue and try to fix it myself in the beginning of October :)

gregertw commented 1 year ago

Hi, I finally managed to resolve this thanks to the latest post you shared, thanks! By upgrading to gradle 7.1.2 (which included cleaning cache, I managed to keep the 1.6.10 official kotlin version on the top-level build.gradle, but still make oauth2_client load flutter_web_auth2. You can see the result at https://github.com/gregertw/actingweb_firstapp/tree/beta_channel Thanks for the help!

ThexXTURBOXx commented 1 year ago

Alright, good to know for other people that might have the same issue, thanks for reporting back! :)