recognizegroup / capacitor-plugin-msauth

Capacitor-wrapper for MSAL libraries. Works on iOS, Android and web.
Other
17 stars 16 forks source link

Unable to build with default generated project #42

Open colonelpopcorn opened 2 weeks ago

colonelpopcorn commented 2 weeks ago

I'm getting a build error from the default capacitor.build.gradle script generated by npx cap sync. The build warns (Failed to resolve: io.opentelemetry:opentelemetry-bom:1.18.0) when I try to run Gradle sync with the generated plugins project, and errors when I try to build the app project. See this stack trace for the error:

Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
   > Could not resolve io.opentelemetry:opentelemetry-bom:1.18.0.
     Required by:
         project :app > project :recognizebv-capacitor-plugin-msauth > com.microsoft.identity.client:msal:4.9.0
      > No matching variant of io.opentelemetry:opentelemetry-bom:1.18.0 was found. The consumer was configured to find a library for use during runtime, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.3.1' but:
          - Variant 'apiElements' capability io.opentelemetry:opentelemetry-bom:1.18.0:
              - Incompatible because this component declares a platform for use during compile-time and the consumer needed a library for use during runtime
              - Other compatible attributes:
                  - Doesn't say anything about com.android.build.api.attributes.AgpVersionAttr (required '8.3.1')
                  - Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
                  - Doesn't say anything about its target Java environment (preferred optimized for Android)
          - Variant 'enforcedApiElements' capability io.opentelemetry:opentelemetry-bom-derived-enforced-platform:1.18.0:
              - Incompatible because this component declares an enforced platform for use during compile-time and the consumer needed a library for use during runtime
              - Other compatible attributes:
                  - Doesn't say anything about com.android.build.api.attributes.AgpVersionAttr (required '8.3.1')
                  - Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
                  - Doesn't say anything about its target Java environment (preferred optimized for Android)
          - Variant 'enforcedRuntimeElements' capability io.opentelemetry:opentelemetry-bom-derived-enforced-platform:1.18.0 declares a component for use during runtime:
              - Incompatible because this component declares an enforced platform and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about com.android.build.api.attributes.AgpVersionAttr (required '8.3.1')
                  - Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
                  - Doesn't say anything about its target Java environment (preferred optimized for Android)
          - Variant 'runtimeElements' capability io.opentelemetry:opentelemetry-bom:1.18.0 declares a component for use during runtime:
              - Incompatible because this component declares a platform and the consumer needed a library
              - Other compatible attributes:
                  - Doesn't say anything about com.android.build.api.attributes.AgpVersionAttr (required '8.3.1')
                  - Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
                  - Doesn't say anything about its target Java environment (preferred optimized for Android)

Android Studio Version: Iguana | 2023.2.1 Java Version: corretto 17.0.10-amzn Gradle Version: 8.6

colonelpopcorn commented 2 weeks ago

I found this issue in M$oft's MSAL library here, and so I tried to exclude and re-include MSAL within the app build.gradle file. That didn't work (same error saying unable to resolve), and now I'm at a loss and wondering what can be done to resolve this issue. Here's how I've been trying to exclude the transitive dependency on MSAL:

  implementation(project(':capacitor-cordova-android-plugins')) {
    exclude(group: 'com.microsoft.identity.client', module: 'msal')
  }
  implementation "com.microsoft.identity.client:msal:5.3.0"
colonelpopcorn commented 1 week ago

I was able to get this error resolved by bumping com.microsoft.identity.client:msal to 5.3.0 instead of 4.9.0. I can't confirm that this won't break anything for other users, but I experienced no issues. Is there any reason this version can't be changed upstream in this project? If there is concern about making the change do you have any suggestions for moving forward with this fix on our side? I'd prefer not to maintain a fork, even for a short length of time.

colonelpopcorn commented 1 week ago

For those that need assistance with this issue you can use PR #43 as a patch with the patch-package npm package.