I am trying to migrate from groovy gradle to kotlin gradle. But when I convert any app level or project level build.gradle file then I get the following exception while gradle sync.
Error
FAILURE: Build failed with an exception.
* What went wrong:
A problem occurred configuring project ':core'.
> java.util.zip.ZipException: zip END header not found
* Try:
> 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.
* Exception is:
org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':core'.
Original build.gradle
file of the core
module:
// Apply necessary plugins for Android library development, Kotlin
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.jetbrains.kotlin.kapt)
}
// Android library configuration
android {
namespace 'com.apoorvgupta.newsshots.core' // Package namespace for the library
compileSdk BuildConfig.compileSdk
// Default configuration for the Android library
defaultConfig {
minSdk BuildConfig.minSdk
targetSdk BuildConfig.targetSdk
}
// Configuration for different build types (e.g., release)
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
// Compilation options for the Android library
compileOptions {
sourceCompatibility JavaVersion.VERSION_17
targetCompatibility JavaVersion.VERSION_17
}
// Kotlin compiler options
kotlinOptions {
jvmTarget = BuildConfig.jvmTarget
}
// Packaging options to exclude specific resources
packagingOptions {
resources {
excludes += '/META-INF/{AL2.0,LGPL2.1}'
}
}
}
// Dependencies configuration
dependencies {
// Timber
implementation libs.timber
// Testing dependencies
testImplementation libs.junit
// Dagger Hilt for dependency injection
implementation libs.hilt.navigation.compose
kapt libs.hilt.android.compiler
}
Converted build.gradle.kts
// Apply necessary plugins for Android library development, Kotlin
plugins {
alias(libs.plugins.android.library)
alias(libs.plugins.jetbrains.kotlin.android)
alias(libs.plugins.jetbrains.kotlin.kapt)
}
// Android library configuration
android {
namespace = "com.apoorvgupta.newsshots.core" // Package namespace for the library
compileSdkVersion = BuildConfig.compileSdk
// Default configuration for the Android library
defaultConfig {
minSdk = BuildConfig.minSdk
}
lint {
targetSdk = BuildConfig.targetSdk // Optional: for lint checks
}
testOptions {
targetSdk = BuildConfig.targetSdk // Optional: for instrumented tests
}
// Configuration for different build types (e.g., release)
buildTypes {
release {
// Enable Progaurd/R8 for release variants
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
// Compilation options for the Android library
compileOptions {
sourceCompatibility = JavaVersion.VERSION_17
targetCompatibility = JavaVersion.VERSION_17
}
// Kotlin compiler options
kotlin {
compilerOptions {
jvmTarget.set(org.jetbrains.kotlin.gradle.dsl.JvmTarget.JVM_17)
}
}
// Packaging options to exclude specific resources
packaging {
resources {
excludes += "/META-INF/{AL2.0,LGPL2.1}"
}
}
}
// Dependencies configuration
dependencies {
// Timber
implementation(libs.timber)
// Testing dependencies
testImplementation(libs.junit)
// Dagger Hilt for dependency injection
implementation(libs.hilt.navigation.compose)
kapt(libs.hilt.android.compiler)
}
I have migrated settings.gradle.kts
file and it does not gives any error
// Plugin management configuration for Gradle build scripts
pluginManagement {
repositories {
google() // Google Maven repository
mavenCentral() // Maven Central repository
gradlePluginPortal() // Gradle Plugin Portal repository
}
}
// Dependency resolution management for Gradle build scripts
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google() // Google Maven repository
mavenCentral() // Maven Central repository
maven ( url="https://jitpack.io" )
}
}
// Root project configuration
rootProject.name = "newsshots"
// Project inclusion configuration
include (":app") // Main application module
include (":feature-home") // Feature module for Home
include (":feature-search") // Feature module for Search
include (":feature-bookmark") // Feature module for Bookmark
include (":capabilities") // Capabilities module
include (":core") // Core module
gradle-wrapper.properties
file
#Tue May 13 14:44:35 IST 2025
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-8.14-bin.zip
networkTimeout=10000
validateDistributionUrl=true
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
I also tried added new module in which build.gradle.kts
is created by default in that case also I faced same exception while syncing.
I have tried clear cache and restart but I still get the same error. But when I revert back build.gradle.kts
file to build.gradle
file then the error disappears.
Even while running gradle clean I face the same error.
As mentioned by Edric in a tweet, I updated both the Hilt dependency and the Hilt plugin to version 2.57, and I was able to sync and build the project successfully.
libs.version.toml
file snippet
hilt = "2.57"
dagger = "2.57"
[libraries]
hilt-android = { group = "com.google.dagger", name = "hilt-android", version.ref = "hilt" }
hilt-android-compiler = { group = "com.google.dagger", name = "hilt-android-compiler", version.ref = "hilt" }
[plugins]
dagger-hilt = { id = "com.google.dagger.hilt.android", version.ref = "dagger" }