I was making an android app using jetpack compose (I am new to this) and everything was very fine, all the projects even the large ones would take like a minute to build and run in emulator but the problem started since I used Glide library (To load images from web) So after implementing this lib to my project, Build time of the project jumped from 10-20 seconds to 9-10 minutes, I deleted the implementation of that library which was from https://mvnrepository.com/artifact/com.github.bumptech.glide/compose/1.0.0-beta01 then I synced my project and the Gradle was taking so much time to build the project (Still 9-10 minutes)
I restarted system, relaunched the IDE, but still it wasn't building it under 10 minutes, I did a lot things like I changed things in gradle.property but still not working (I Tried every single problem that was kinda same on StackOverFlow but still wasn't fixing my problem) So I just made another project (An empty jetpack compose test project) And when I want to run it, it will take 6-7 minutes! Just an empty one with no code (only has default jetpack compose Greeting() function) So I don't know what to do please help, It was working fine for like 2-3 months but this just happened after I implemented that Glide lib in the project...Does reinstalling android studio fix the problem?!
Also this is what is it in the build panel: Starting Gradle Daemon... Gradle Daemon started in 2 s 441 ms
Task :app:createDebugVariantModel Task :app:preBuild UP-TO-DATE Task :app:preDebugBuild UP-TO-DATE Task :app:mergeDebugNativeDebugMetadata NO-SOURCE Task :app:generateDebugResValues Task :app:checkDebugAarMetadata Task :app:mapDebugSourceSetPaths Task :app:generateDebugResources Task :app:packageDebugResources Task :app:createDebugCompatibleScreenManifests Task :app:extractDeepLinksDebug Task :app:parseDebugLocalResources Task :app:processDebugMainManifest Task :app:processDebugManifest Task :app:mergeDebugResources Task :app:javaPreCompileDebug Task :app:mergeDebugShaders Task :app:compileDebugShaders NO-SOURCE Task :app:generateDebugAssets UP-TO-DATE Task :app:mergeDebugAssets Task :app:compressDebugAssets Task :app:desugarDebugFileDependencies Task :app:mergeDebugJniLibFolders Task :app:checkDebugDuplicateClasses Task :app:mergeDebugNativeLibs NO-SOURCE Task :app:stripDebugDebugSymbols NO-SOURCE Task :app:validateSigningDebug Task :app:processDebugManifestForPackage Task :app:mergeLibDexDebug Task :app:writeDebugAppMetadata Task :app:writeDebugSigningConfigVersions Task :app:processDebugResources Task :app:mergeExtDexDebug Task :app:compileDebugKotlin Task :app:compileDebugJavaWithJavac NO-SOURCE Task :app:processDebugJavaRes Task :app:dexBuilderDebug Task :app:mergeProjectDexDebug Task :app:mergeDebugJavaResource Task :app:packageDebug Task :app:createDebugApkListingFileRedirect Task :app:assembleDebug
BUILD SUCCESSFUL in 6m 58s 32 actionable tasks: 32 executed
As i said, this one is an empty jetpack compose project and it is taking 7 minutes to build!
Edit: So I just realised even stopping a gradle building task (Canceling building process) is taking much more time than before, now it is taking about 1 minutes to only stop the building but before it would take around 5-10 seconds... I made a new empty project (Jetpack compose) and I changed my gradle.properties to this :
org.gradle.jvmargs=-Xmx2048m
org.gradle.parallel=true
android.useAndroidX=true
android.enableJetifier=false
android.injected.testOnly = false
org.gradle.caching=true
org.gradle.daemon=true
org.gradle.configureondemand=true
kotlin.incremental=true
kapt.classloaders.cache.size=5
kapt.include.compile.classpath=false
So nothing just chaged, Here's my other gradle files configurations:
build.gradle (my application) :
// Top-level build file where you can add configuration options common to all sub-projects/modules.
plugins {
id("com.android.application") version "8.1.1" apply false
id("org.jetbrains.kotlin.android") version "1.8.10" apply false
}
build.gradle (module: app) :
plugins {
id("com.android.application")
id("org.jetbrains.kotlin.android")
}
android {
namespace = "com.example.myapplication"
compileSdk = 33
defaultConfig {
applicationId = "com.example.myapplication"
minSdk = 21
targetSdk = 33
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables {
useSupportLibrary = true
}
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_11
targetCompatibility = JavaVersion.VERSION_11
}
kotlinOptions {
jvmTarget = "11"
}
buildFeatures {
compose = true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.4.3"
}
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}
dependencies {
implementation("androidx.core:core-ktx:1.9.0")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.6.2")
implementation("androidx.activity:activity-compose:1.7.2")
implementation(platform("androidx.compose:compose-bom:2023.03.00"))
implementation("androidx.compose.ui:ui")
implementation("androidx.compose.ui:ui-graphics")
implementation("androidx.compose.ui:ui-tooling-preview")
implementation("androidx.compose.material3:material3")
testImplementation("junit:junit:4.13.2")
androidTestImplementation("androidx.test.ext:junit:1.1.5")
androidTestImplementation("androidx.test.espresso:espresso-core:3.5.1")
androidTestImplementation(platform("androidx.compose:compose-bom:2023.03.00"))
androidTestImplementation("androidx.compose.ui:ui-test-junit4")
debugImplementation("androidx.compose.ui:ui-tooling")
debugImplementation("androidx.compose.ui:ui-test-manifest")
}
So after 2 days of suffering the problem is finally fixed! The gradle build timer went from +10mins to "successful build in 2s" so the problem was solved just by updating the IDE and SDK build tools to the latest version...
Also thanks @Robert for taking the time to reply to my question.
I live in a third world country and everything even google and all its services are filtered here, that's why I couldn't get the new update of ide and sdk.