'core-ktx 1.7.0 and Hilt
I've just updated my project's core-ktx (androidx.core:core-ktx) version to 1.7.0, and now I can't compile my project. In fact, at my PC everything works OK, but in Github Actions the build is broken.
At first I was getting this error:
* What went wrong:
Execution failed for task ':core:verifyReleaseResources'.
> A failure occurred while executing com.android.build.gradle.tasks.VerifyLibraryResourcesTask$Action
> Android resource linking failed
ERROR:/home/runner/.gradle/caches/transforms-3/cf34be3e77386540a828d329143911c7/transformed/core-1.7.0/res/values/values.xml:105:5-114:25: AAPT: error: resource android:attr/lStar not found.
But updating to SDK 31 fixed this issue. Now I'm getting the following one:
> Task :core:hiltAggregateDepsDebugUnitTest
WARNING: [Processor] Library '/home/runner/.gradle/caches/transforms-3/fd6df19df5b3c35086ae117610be6db2/transformed/browser-1.0.0-api.jar' contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.
Example of androidX reference: 'androidx/browser/R$styleable'
Example of support library reference: 'android/support/customtabs/ICustomTabsCallback$Stub$Proxy'
WARNING: [Processor] Library '/home/runner/.gradle/caches/transforms-3/fc7ccfb37357e9edd2e98ab346848a40/transformed/core-1.7.0-api.jar' contains references to both AndroidX and old support library. This seems like the library is partially migrated. Jetifier will try to rewrite the library anyway.
Example of androidX reference: 'androidx/core/R$styleable'
Example of support library reference: 'android/support/v4/app/INotificationSideChannel$Default'
> Task :core:javaPreCompileReleaseUnitTest
> Task :core:compileReleaseUnitTestJavaWithJavac NO-SOURCE
> Task :core:createFullJarRelease
/home/runner/work/Android/Android/core/build/generated/hilt/component_sources/debugUnitTest/com/***/.../core/shared/Hilt_App.java:20: error: cannot find symbol
return DaggerApp_HiltComponents_SingletonC.builder()
> Task :core:hiltJavaCompileDebugUnitTest FAILED
^
symbol: variable DaggerApp_HiltComponents_SingletonC
1 error
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':core:hiltJavaCompileDebugUnitTest'.
> Compilation failed; see the compiler error output for details.
This is my build.gradle:
plugins {
id 'com.android.library'
id 'kotlin-android'
id 'kotlin-parcelize'
id 'org.jetbrains.dokka'
id 'org.jetbrains.kotlin.kapt'
id 'dagger.hilt.android.plugin'
}
android {
compileSdk 31
buildToolsVersion "31.0.0"
defaultConfig {
minSdk 24
targetSdk 31
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles "consumer-rules.pro"
vectorDrawables {
useSupportLibrary true
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
compose true
}
composeOptions {
kotlinCompilerExtensionVersion compose_version
}
}
tasks.named("dokkaHtmlPartial") {
dokkaSourceSets {
configureEach {
noAndroidSdkLink.set(false)
}
}
}
dependencies {
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.5.31'
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.preference:preference-ktx:1.1.1'
// Testing
testImplementation 'junit:junit:4.13.2'
testImplementation 'org.mockito:mockito-core:4.0.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// KotlinX Coroutines
api 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.2'
api 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.2'
api 'org.jetbrains.kotlinx:kotlinx-coroutines-play-services:1.5.2'
// Android Jetpack
def jetpack_work_version = '2.7.0'
api "androidx.work:work-runtime-ktx:$jetpack_work_version"
api "androidx.work:work-gcm:$jetpack_work_version"
androidTestApi "androidx.work:work-testing:$jetpack_work_version"
api "androidx.startup:startup-runtime:1.1.0"
// Jetpack compose
api "androidx.compose.ui:ui:$compose_version"
api "androidx.compose.ui:ui-tooling:$compose_version"
api "androidx.compose.foundation:foundation:$compose_version"
api "androidx.compose.material:material:$compose_version"
api "androidx.compose.material:material-icons-core:$compose_version"
api "androidx.compose.material:material-icons-extended:$compose_version"
api "androidx.compose.runtime:runtime-livedata:$compose_version"
api "androidx.compose.runtime:runtime-rxjava2:$compose_version"
api 'androidx.activity:activity-compose:1.4.0'
api 'androidx.lifecycle:lifecycle-viewmodel-compose:2.4.0'
api 'androidx.navigation:navigation-compose:2.4.0-beta02'
api 'com.google.accompanist:accompanist-appcompat-theme:0.20.1'
androidTestApi "androidx.compose.ui:ui-test-junit4:$compose_version"
// Coil image loading
api 'io.coil-kt:coil:1.4.0'
api 'io.coil-kt:coil-compose:1.4.0'
// Live Data
api 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0'
// Google Play Core
api 'com.google.android.play:core:1.10.2'
api 'com.google.android.play:core-ktx:1.8.1'
// App Search
def appsearch_version = "1.0.0-alpha04"
api "androidx.appsearch:appsearch:$appsearch_version"
// Use kapt instead of annotationProcessor if writing Kotlin classes
kapt "androidx.appsearch:appsearch-compiler:$appsearch_version"
api "androidx.appsearch:appsearch-local-storage:$appsearch_version"
// Google Firebase
api platform('com.google.firebase:firebase-bom:29.0.0')
api 'com.google.firebase:firebase-analytics-ktx'
api 'com.google.firebase:firebase-firestore-ktx'
api 'com.google.firebase:firebase-storage-ktx'
api 'com.google.firebase:firebase-crashlytics-ktx'
api 'com.google.firebase:firebase-config-ktx'
api 'com.google.firebase:firebase-perf-ktx'
api 'com.google.firebase:firebase-dynamic-links-ktx'
api 'com.google.firebase:firebase-functions-ktx'
api 'com.google.firebase:firebase-auth-ktx'
api 'com.google.firebase:firebase-messaging-ktx'
api 'com.google.firebase:firebase-messaging-directboot:23.0.0'
// Google Firebase Auth Google Sign-In
api 'com.google.android.gms:play-services-auth:19.2.0'
// Hilt dependency injection
api "com.google.dagger:hilt-android:2.40"
kapt "com.google.dagger:hilt-compiler:2.40"
// Gson for JSON parsing
implementation 'com.google.code.gson:gson:2.8.9'
// Maps SDK
api 'com.google.android.gms:play-services-maps:18.0.0'
// Timber
api 'com.jakewharton.timber:timber:5.0.1'
// Custom Views
api 'com.github.PhilJay:MPAndroidChart:v3.1.0'
}
If any extra info is required please ask, my build workflow has been broken for a week :(
Thanks in advance
Solution 1:[1]
Implement a new version of androidx.core-ktx in your project .
implementation 'androidx.core:core-ktx:1.8.0-alpha03'
then force the project to use the new version of it.
configurations.all {
resolutionStrategy { force 'androidx.core:core-ktx:1.8.0-alpha03' }
}
Solution 2:[2]
just only remove line
implementation 'androidx.core:core-ktx:1.7.0'
that should fix the warning
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | behrad |
| Solution 2 | Mehmet |
