I am writing a Flutter plugin, On android part after finishing everything when I am running Android plugin with Android Studio, the plugin works correctly but when I am running my plugin on Flutter I got this error:
Execution failed for task ':app:mergeLibDexDebug'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Failed to transform classes.jar (project :flutter_basis_theory) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, com.android.build.api.attributes.AgpVersionAttr=7.3.0, com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.attributes.VariantAttr=debug, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.category=library, org.gradle.jvm.environment=android, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime, org.jetbrains.kotlin.platform.type=androidJvm}.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> No variants of javax.ws.rs:javax.ws.rs-api:2.1.1 match the consumer attributes:
- javax.ws.rs:javax.ws.rs-api:2.1.1 configuration runtime declares a component for use during runtime:
- Incompatible because this component declares a component, as well as attribute 'artifactType' with value '${packaging.type}' and the consumer needed a component, as well as attribute 'artifactType' with value 'android-classes-jar'
- Other compatible attributes:
- Doesn't say anything about asm-transformed-variant (required 'NONE')
- Doesn't say anything about com.android.build.api.attributes.AgpVersionAttr (required '7.3.0')
- Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
- Doesn't say anything about dexing-enable-desugaring (required 'true')
- Doesn't say anything about dexing-enable-jacoco-instrumentation (required 'false')
- Doesn't say anything about dexing-is-debuggable (required 'true')
- Doesn't say anything about dexing-min-sdk (required '21')
- 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')
> Failed to transform classes.jar (project :integration_test) to match attributes {artifactType=android-dex, asm-transformed-variant=NONE, com.android.build.api.attributes.AgpVersionAttr=7.3.0, com.android.build.api.attributes.BuildTypeAttr=debug, com.android.build.gradle.internal.attributes.VariantAttr=debug, dexing-enable-desugaring=true, dexing-enable-jacoco-instrumentation=false, dexing-is-debuggable=true, dexing-min-sdk=21, org.gradle.libraryelements=jar, org.gradle.usage=java-runtime}.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> No variants of javax.ws.rs:javax.ws.rs-api:2.1.1 match the consumer attributes:
- javax.ws.rs:javax.ws.rs-api:2.1.1 configuration runtime declares a component for use during runtime:
- Incompatible because this component declares a component, as well as attribute 'artifactType' with value '${packaging.type}' and the consumer needed a component, as well as attribute 'artifactType' with value 'android-classes-jar'
- Other compatible attributes:
- Doesn't say anything about asm-transformed-variant (required 'NONE')
- Doesn't say anything about com.android.build.api.attributes.AgpVersionAttr (required '7.3.0')
- Doesn't say anything about com.android.build.api.attributes.BuildTypeAttr (required 'debug')
- Doesn't say anything about dexing-enable-desugaring (required 'true')
- Doesn't say anything about dexing-enable-jacoco-instrumentation (required 'false')
- Doesn't say anything about dexing-is-debuggable (required 'true')
- Doesn't say anything about dexing-min-sdk (required '21')
- 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.
this is my project build Gradle:
buildscript {
ext.kotlin_version = '1.9.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
maven { url 'https://jitpack.io' }
google()
mavenCentral()
}
}
rootProject.buildDir = '../build'
subprojects {
project.buildDir = "${rootProject.buildDir}/${project.name}"
}
subprojects {
project.evaluationDependsOn(':app')
}
tasks.register("clean", Delete) {
delete rootProject.buildDir
}
My build gradle module app
plugins {
id "com.android.application"
id "kotlin-android"
id "kotlin-kapt"
id "dev.flutter.flutter-gradle-plugin"
}
def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
localPropertiesFile.withReader('UTF-8') { reader ->
localProperties.load(reader)
}
}
def flutterVersionCode = localProperties.getProperty('flutter.versionCode')
if (flutterVersionCode == null) {
flutterVersionCode = '1'
}
def flutterVersionName = localProperties.getProperty('flutter.versionName')
if (flutterVersionName == null) {
flutterVersionName = '1.0'
}
android {
namespace "mypackagename_example"
compileSdkVersion flutter.compileSdkVersion
ndkVersion flutter.ndkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
}
dataBinding {
enabled = true
}
defaultConfig {
applicationId mypackagename_example
minSdkVersion 21
targetSdkVersion flutter.targetSdkVersion
versionCode flutterVersionCode.toInteger()
versionName flutterVersionName
}
buildTypes {
release {
signingConfig signingConfigs.debug
}
}
}
flutter {
source '../..'
}
dependencies {
}
and my plugin build gradle:
group 'mypackagename'
version '1.0-SNAPSHOT'
buildscript {
ext.kotlin_version = '1.9.10'
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.3.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}
}
allprojects {
repositories {
maven { url 'https://jitpack.io' }
google()
mavenCentral()
}
}
apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-kapt'
android {
if (project.android.hasProperty("namespace")) {
namespace 'mypackagename'
}
compileSdk 33
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
kotlinOptions {
jvmTarget = '17'
}
buildFeatures {
viewBinding true
}
dataBinding {
enabled = true
}
sourceSets {
main.java.srcDirs += 'src/main/kotlin'
test.java.srcDirs += 'src/test/kotlin'
}
defaultConfig {
minSdk 21
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.wajahatkarim:EasyFlipView:3.0.3'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.activity:activity-compose:1.3.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.navigation:navigation-fragment-ktx:2.5.3'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
implementation 'com.google.code.gson:gson:2.10.1'
implementation 'com.github.basis-theory:basistheory-android:3.2.0'
implementation('com.github.basis-theory:basistheory-java:1.1.0') {
exclude group: 'javax.ws.rs', module: 'javax.ws.rs-api'
}
implementation 'org.threeten:threetenbp:1.6.8'
testImplementation 'org.jetbrains.kotlin:kotlin-test'
testImplementation 'org.mockito:mockito-core:5.0.0'
}
testOptions {
unitTests.all {
useJUnitPlatform()
testLogging {
events "passed", "skipped", "failed", "standardOut", "standardError"
outputs.upToDateWhen {false}
showStandardStreams = true
}
}
}
}