Instead of having gradle fetch MpAndroidChart's code from Maven, I am downloading the library's code locally (because I need to do some modifications on the library to improve performance) and then manually add it to my project.
I executed the below steps:
Moved the code into RootOfProjectFolder/libs/MpAndroidChart.
Made the following changes to my project:
a. Added the library to settings.gradle:
include ':MpAndroidChart' project(':MpAndroidChart').projectDir = new File('libs/MpAndroidChart')
b. Including the library as a dependency in app-level build.gradle:
implementation project(":MpAndroidChart")
But I still get this error:
No matching variant of project :MpAndroidChart was found. The consumer was configured to find a library for use during compile-time, preferably optimized for Android, as well as attribute 'com.android.build.api.attributes.AgpVersionAttr' with value '8.5.0', attribute 'com.android.build.api.attributes.BuildTypeAttr' with value 'debug', attribute 'org.jetbrains.kotlin.platform.type' with value 'androidJvm' but:
- No variants exist.
I have no idea what that means.
Below is all the code of my project's build.gradle files:
App-level:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'androidx.navigation.safeargs.kotlin'
apply plugin: 'kotlin-kapt'
apply plugin: 'com.chaquo.python'
apply from: 'artifacts.gradle'
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
namespace rootProject.ext.applicationId
compileSdk rootProject.extpileSdkVersion
ndkVersion '24.0.8079956'
defaultConfig {
applicationId rootProject.ext.applicationId
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode project.version_code
versionName project.version_name
//testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
kapt {
arguments {
arg("room.schemaLocation", "$projectDir/schemas".toString())
arg("room.incremental", "true")
arg("room.expandProjection", "true")
}
}
resourceConfigurations += ['en']
resValue "string", "app_name", "${rootProject.name}"
ndk {
//abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64"
//noinspection ChromeOsAbiSupport
abiFilters "arm64-v8a"
}
python {
version "3.8"
pip {
install "numpy"
install "heartpy"
install "matplotlib"
install "pandas"
install "scipy"
install "openpyxl"
install "torch"
install "cvxopt"
install "scikit-learn"
}
}
}
sourceSets {
main {
java.srcDirs += 'src/main/kotlin'
res.srcDirs = [
'src/main/res',
file('src/main/res/features/').listFiles()
]
}
}
/*bundle {
storeArchive {
enable = false
}
}*/
compileOptions {
sourceCompatibility JavaVersion.VERSION_21
targetCompatibility JavaVersion.VERSION_21
}
kotlin {
jvmToolchain(21)
}
packagingOptions {
jniLibs {
excludes += ['META-INF/**']
}
resources {
excludes += ['META-INF/**']
}
}
buildFeatures {
dataBinding true
viewBinding true
buildConfig true
}
signingConfigs {
debug {
storeFile file(keystoreProperties['storeFileDebug'])
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storePassword keystoreProperties['storePassword']
}
emulator {
storeFile file(keystoreProperties['storeFileDebug'])
}
release {
storeFile file(keystoreProperties['storeFile'])
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storePassword keystoreProperties['storePassword']
}
}
buildTypes {
debug {
resValue "string", "app_name", "dev ${rootProject.name}"
applicationIdSuffix = ".dev"
versionNameSuffix "-dev"
resValue "string", "app_version", "${defaultConfig.versionName}${versionNameSuffix}"
debuggable true
minifyEnabled false
shrinkResources false
signingConfig signingConfigs.debug
manifestPlaceholders.crashlyticsCollectionEnabled = true
buildConfigField "String", "SERVER_IP_ADDRESS", "\"192.168.0.100\""
}
emulator {
resValue "string", "app_name", "dev ${rootProject.name}"
applicationIdSuffix = ".dev"
versionNameSuffix "-dev"
resValue "string", "app_version", "${defaultConfig.versionName}${versionNameSuffix}"
debuggable true
minifyEnabled false
shrinkResources false
signingConfig signingConfigs.debug
manifestPlaceholders.crashlyticsCollectionEnabled = false
buildConfigField "String", "SERVER_IP_ADDRESS", "\"192.168.0.100\""
}
/*qa {
resValue "string", "app_name", "${rootProject.name}"
resValue "string", "app_version", "${defaultConfig.versionName}${versionNameSuffix}"
debuggable true
minifyEnabled false
shrinkResources false
firebaseCrashlytics {
mappingFileUploadEnabled false
}
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
manifestPlaceholders.crashlyticsCollectionEnabled = true
buildConfigField "String", "SERVER_IP_ADDRESS", "\"192.168.0.100\""
}*/
release {
resValue "string", "app_name", "${rootProject.name}"
resValue "string", "app_version", "${defaultConfig.versionName}${versionNameSuffix}"
debuggable true
minifyEnabled false
shrinkResources false
firebaseCrashlytics {
mappingFileUploadEnabled false
}
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
manifestPlaceholders.crashlyticsCollectionEnabled = true
buildConfigField "String", "SERVER_IP_ADDRESS", "\"192.168.0.100\""
}
}
lint {
checkReleaseBuilds true
}
}
dependencies {
// Shimmer
implementation fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
implementation 'org.apachemons:commons-math:2.2'
implementation 'javax.vecmath:vecmath:1.5.2'
implementation 'org.apachemons:commons-lang3:3.13.0'
// Support
implementation 'androidx.core:core-ktx:1.15.0'
implementation 'androidx.appcompat:appcompat:1.7.0'
// AndroidX UI
implementation "androidx.constraintlayout:constraintlayout:2.2.0"
implementation "androidx.fragment:fragment-ktx:1.8.5"
// RecyclerView
implementation "androidx.recyclerview:recyclerview:1.3.2"
implementation "androidx.recyclerview:recyclerview-selection:1.1.0"
// AndroidX Navigation
implementation "androidx.navigation:navigation-fragment-ktx:2.8.5"
implementation "androidx.navigation:navigation-ui-ktx:2.8.5"
//implementation "androidx.navigation:navigation-dynamic-features-fragment:2.5.2"
// AndroidX lifecycle ViewModel and LiveData
def lifecycleVersion = '2.6.1'
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycleVersion"
implementation "androidx.lifecycle:lifecycle-common-java8:$lifecycleVersion"
// Room
def roomVersion = '2.6.1'
implementation "androidx.room:room-runtime:$roomVersion"
kapt "androidx.room:room-compiler:$roomVersion"
implementation "androidx.room:room-ktx:$roomVersion"
// Material
implementation "com.google.android.material:material:1.9.0"
// Kotlin
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.9.0'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.9.0'
//implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.21'
//implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.4"
//implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4"
// Koin
implementation 'io.insert-koin:koin-core:3.3.3'
implementation 'io.insert-koin:koin-android:3.3.3'
implementation 'io.insert-koin:koin-androidx-navigation:3.3.3'
// Glide
def glideVersion = '4.15.1'
implementation "com.github.bumptech.glide:glide:$glideVersion"
implementation "com.github.bumptech.glide:okhttp3-integration:$glideVersion"
kapt "com.github.bumptech.glide:compiler:$glideVersion"
// Retrofit
implementation "com.squareup.retrofit2:retrofit:2.9.0"
implementation "com.squareup.retrofit2:converter-gson:2.9.0"
// OkHttp
implementation "com.squareup.okhttp3:okhttp:5.0.0-alpha.3"
implementation "com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.3"
// Gson
implementation 'com.google.code.gson:gson:2.10.1'
// Encapsulates server response with sealed class NetworkResponse
implementation 'com.github.haroldadmin:NetworkResponseAdapter:5.0.0'
// Firebase
implementation 'com.google.firebase:firebase-crashlytics-ktx:18.3.7'
//implementation 'com.google.firebase:firebase-analytics-ktx:21.1.1'
// Tools
implementation 'org.ocpsoft.prettytime:prettytime:5.0.6.Final'
implementation 'pub.devrel:easypermissions:3.0.0'
implementation 'com.github.AbedElazizShe:LightCompressor:1.2.0'
//implementation 'com.github.stfalcon-studio:StfalconImageViewer:v1.0.1'
// ExoPlayer
implementation "com.google.android.exoplayer:exoplayer-core:2.18.6"
implementation "com.google.android.exoplayer:exoplayer-ui:2.18.6"
// Ktor Server
def ktorVersion = '2.3.13'
implementation "io.ktor:ktor-server-core:$ktorVersion"
implementation "io.ktor:ktor-server-netty:$ktorVersion"
implementation "io.ktor:ktor-server-compression:$ktorVersion"
implementation "io.ktor:ktor-server-call-logging:$ktorVersion"
implementation "io.ktor:ktor-server-default-headers:$ktorVersion"
implementation "io.ktor:ktor-server-content-negotiation:$ktorVersion"
// Ktor Client
implementation("io.ktor:ktor-client-core:$ktorVersion")
implementation "io.ktor:ktor-client-cio:$ktorVersion"
implementation "io.ktor:ktor-client-content-negotiation:$ktorVersion"
// Ktor Serialization
implementation "io.ktor:ktor-serialization-gson:$ktorVersion"
// noinspection GradleDependency upgrading this will not work. comenting this since will not work with moquette.
//implementation 'ch.qos.logback:logback-classic:1.2.3'
// jUnit
//testImplementation 'junit:junit:4.13.2'
// Tests Koin
// Koin Test features
// testImplementation "io.insert-koin:koin-test:$koin_version"
// Koin for JUnit 4
// testImplementation "io.insert-koin:koin-test-junit4:$koin_version"
// Koin for JUnit 5
// testImplementation "io.insert-koin:koin-test-junit5:$koin_version"
// Tests Ktor
//testImplementation("io.ktor:ktor-server-test-host:$ktorVersion")
//testImplementation("org.jetbrains.kotlin:kotlin-test")
//testImplementation "io.ktor:ktor-client-cio:$ktorVersion"
//testImplementation "io.ktor:ktor-client-okhttp:$ktorVersion"
// Instrumented Tests
//androidTestImplementation 'androidx.test.ext:junit:1.1.3'
//androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// Charts
implementation project(":MpAndroidChart")
implementation 'com.github.ggalmazor:lt_downsampling_java8:0.0.6'
def camerax_version = "1.4.1"
implementation "androidx.camera:camera-core:${camerax_version}"
implementation "androidx.camera:camera-camera2:${camerax_version}"
implementation "androidx.camera:camera-lifecycle:${camerax_version}"
implementation "androidx.camera:camera-video:${camerax_version}"
implementation "androidx.camera:camera-view:${camerax_version}"
implementation "androidx.camera:camera-extensions:${camerax_version}"
// MQTT Broker
implementation('io.moquette:moquette-broker:0.16') {
//exclude group: "org.slf4j"
}
//implementation 'org.slf4j:slf4j-simple:1.7.36'
implementation 'androidx.datastore:datastore-preferences:1.0.0'
// MQTT Client
implementation 'org.eclipse.paho:org.eclipse.paho.client.mqttv3:1.2.5'
// implementation 'org.eclipse.paho:org.eclipse.paho.android.service:1.1.1'
// implementation project(path: ':mqtt')
// AWS Services
implementation 'com.amazonaws:aws-android-sdk-s3:2.7.4'
// Location
implementation("com.google.android.gms:play-services-location:21.3.0")
}
Project-level:
apply from: 'version.gradle'
buildscript {
ext {
applicationId = 'com.sampleApp.v1'
targetSdkVersion = 35
minSdkVersion = 31
compileSdkVersion = targetSdkVersion
}
repositories {
google()
mavenCentral()
maven { url '' }
}
dependencies {
classpath 'com.android.tools.build:gradle:8.5.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.9.25"
classpath "com.google.gms:google-services:4.4.2"
classpath "com.google.firebase:firebase-crashlytics-gradle:3.0.2"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.8.5"
classpath "com.chaquo.python:gradle:13.0.0"
}
}
allprojects {
repositories {
google()
mavenCentral()
maven { url "; }
}
gradle.projectsEvaluated {
tasks.withType(JavaCompile).tap {
configureEach {
optionspilerArgs << "-Xlint:deprecation"
}
}
}
}
tasks.register('clean', Delete) {
delete rootProject.layout.buildDirectory
}