I have a problem, Android Studio highlights by viewModels() as an error, but the code is successfully compiled and works. This problem occurs only in Activity, in Fragment there is no such error. The same will happen if I use by viewModel() (Koin) instead of by viewModels(). I’ve looked at a lot of decisions, but none of them helped me.
I tried:
Invalidate Caches
Restart IDE, PC...
Open a project on another PC
Tried this answer and this
Error
My dependencies (app):
implementation(project(":domain"))
implementation(project(":data"))
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.6.4'
def koin_version= "3.2.1"
implementation "io.insert-koin:koin-android:$koin_version"
implementation 'androidx.core:core-ktx:1.9.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.8.0-alpha01'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation "androidx.fragment:fragment-ktx:1.5.3"
implementation 'com.my.target:mytarget-sdk:5.15.4'
def lottieVersion = "5.2.0"
implementation "com.airbnb.android:lottie:$lottieVersion"
implementation 'com.google.firebase:firebase-crashlytics-ktx:18.2.13'
implementation 'com.google.firebase:firebase-config-ktx'
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation platform('com.google.firebase:firebase-bom:30.3.1')
implementation 'com.google.android.gms:play-services-auth:20.3.0'
implementation 'com.google.android.gms:play-services-oss-licenses:17.0.0'
implementation 'com.google.android.gms:play-services-location:20.0.0'
implementation 'com.github.bumptech.glide:glide:4.13.2'
annotationProcessor 'com.github.bumptech.glide:compiler:4.13.2'
Build gradle (project):
buildscript {
repositories {
google()
}
dependencies {
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.5'
classpath 'com.google.gms:google-services:4.3.14'
classpath 'com.android.tools.build:gradle:7.3.0'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
}
}
plugins {
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
id 'org.jetbrains.kotlin.android' version '1.7.10' apply false
id 'org.jetbrains.kotlin.jvm' version '1.7.10' apply false
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I have this issue also. AppCompatActivity is deriving from ComposeActivity but somehow Android Studio isn't getting this and showing it as an error.
Related
Directions parts are not generated in Java (Generated) even though I have specified fragment actions in Android Studio and many time rebuild project[enter image description here][1]. So I can't use directions. What would be the reason?
Builde.graddle
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:4.1.3'
def nav_version = "2.5.2"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
}
}
plugins {
id 'com.android.application' version '7.2.2' apply false
id 'com.android.library' version '7.2.2' apply false
}
allprojects {
repositories {
google()
mavenCentral()
}
}
build.graddle[app]
plugins {
id 'com.android.application'
id("androidx.navigation.safeargs")
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.6.1'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.5.1'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.5.1'
implementation 'androidx.navigation:navigation-fragment:2.5.2'
implementation 'androidx.navigation:navigation-ui:2.5.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation platform('com.google.firebase:firebase-bom:30.4.0')
implementation 'com.google.firebase:firebase-database:20.0.6'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.android.gms:play-services-auth:20.3.0'
}
Not generated(screenshot)
Hey guys how can I update to latest version because I cannot find the latest gradle-plugin. Can somone guide me on this?
build.gradle(ExampleApp)
buildscript {
ext {
kotlin_version = '1.6.10'
kotlin_serializtion_version = '1.5.21'
kotlin_coroutines_version = "1.6.0"
moshiVersion = "1.13.0"
retrofit2_version = "2.9.0"
okhttp3_version = "4.9.0"
mockk_version = "1.12.2"
picassoVersion = "2.71828"
lifecycle_version = "2.5.0"
koin_version = "3.2.0"
barcode_scanner_version = "16.1.1"
camerax_version = "1.0.0"
camera_view_version = "1.0.0-alpha22"
stripe_version = "19.1.0"
jacoco_version = "0.8.7"
room_version = "2.4.1"
glide_version = "4.12.0"
json_version = "20180813"
kotlin_reflect_version = "1.6.10"
compose_version = '1.2.0-rc03'
espresso_version = '3.4.0'
core_testing_version = '2.1.0'
pdf_view_version = '3.2.0-beta.1'
appboy_version = '21.0.0'
mp_chart_version = "3.1.0"
activity_compose = "1.5.0"
compose_material3 = "1.0.0-alpha14"
}
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
classpath 'com.google.gms:google-services:4.3.10'
classpath "org.jetbrains.kotlin:kotlin-serialization:$kotlin_serializtion_version"
classpath 'com.google.firebase:firebase-appdistribution-gradle:3.0.0'
}
}
plugins {
id "org.sonarqube" version "3.3"
}
apply from: "${rootDir}/config/sonarqube/sonarqube.gradle"
allprojects {
repositories {
google()
jcenter()
mavenCentral()
maven { url 'https://s3.amazonaws.com/salesforcesos.com/android/maven/release' }
maven { url 'https://mobile-sdk.jumio.com' }
maven { url "https://appboy.github.io/appboy-android-sdk/sdk" }
maven { url 'https://jitpack.io' }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
gradle-wrapper.properties
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-7.4.2-all.zip
build.gradle(:app)
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-parcelize'
apply plugin: 'com.google.firebase.crashlytics'
apply plugin: 'kotlin-kapt'
apply plugin: 'kotlinx-serialization'
apply plugin: 'com.google.firebase.appdistribution'
android {
compileSdkVersion 33
defaultConfig {
applicationId "com.example.app"
minSdkVersion 21
targetSdkVersion 33
.....
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = JavaVersion.VERSION_1_8.toString()
}
sourceSets {
test {
java.srcDirs =
[
"${project.projectDir}/src/test/java"
]
}
}
testOptions {
unitTests.returnDefaultValues = true
}
buildFeatures {
viewBinding true
compose true
}
composeOptions {
kotlinCompilerExtensionVersion = "1.2.0"
kotlinCompilerVersion kotlin_version
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_version"
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'androidx.browser:browser:1.4.0'
implementation 'androidx.appcompat:appcompat:1.4.2'
implementation "androidx.fragment:fragment-ktx:1.5.0"
implementation 'com.google.android.play:core:1.10.3'
implementation 'com.google.android.material:material:1.5.0'
// kotlin atomic
implementation 'org.jetbrains.kotlinx:atomicfu:0.17.1'
//Kotlin extensions library for Play Core
implementation 'com.google.android.play:core-ktx:1.8.1'
//Android Kotlin extensions
implementation "androidx.core:core-ktx:1.8.0"
//Unit test
testImplementation 'junit:junit:4.12'
testImplementation 'org.mockito:mockito-inline:3.4.0'
androidTestImplementation 'org.mockito:mockito-android:3.4.0'
testImplementation "com.nhaarman.mockitokotlin2:mockito-kotlin:2.2.0"
testImplementation 'androidx.arch.core:core-testing:2.1.0'
testImplementation "io.mockk:mockk:${mockk_version}"
testImplementation "org.json:json:$json_version"
//Moshi (JSON parser)
implementation "com.squareup.moshi:moshi-kotlin:$moshiVersion"
kapt "com.squareup.moshi:moshi-kotlin-codegen:$moshiVersion"
//Retrofit2
implementation "com.squareup.retrofit2:retrofit:$retrofit2_version"
implementation "com.squareup.retrofit2:converter-moshi:$retrofit2_version"
//Paging 3
implementation "androidx.paging:paging-runtime-ktx:3.1.1"
//Okhttp3
implementation "com.squareup.okhttp3:okhttp:$okhttp3_version"
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp3_version"
testImplementation "com.squareup.okhttp3:mockwebserver:$okhttp3_version"
//Kotlin Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:$kotlin_coroutines_version"
testImplementation "org.jetbrains.kotlinx:kotlinx-coroutines-test:$kotlin_coroutines_version"
//ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:$lifecycle_version"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:$lifecycle_version"
//HTML parser
implementation 'org.jsoup:jsoup:1.12.1'
//Payments
implementation 'com.google.android.gms:play-services-wallet:19.1.0'
implementation "com.stripe:stripe-android:$stripe_version"
//Firebase
implementation platform('com.google.firebase:firebase-bom:27.1.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.firebase:firebase-crashlytics-ktx'
implementation 'com.google.firebase:firebase-config-ktx'
implementation "com.google.firebase:firebase-messaging"
implementation "com.google.firebase:firebase-core"
//Pager indicator
implementation 'me.relex:circleindicator:2.1.4'
//Animations
implementation 'com.airbnb.android:lottie:3.2.2'
implementation 'pl.bclogic:pulsator4droid:1.0.3'
//Loading images
implementation "com.github.bumptech.glide:glide:$glide_version"
kapt "com.github.bumptech.glide:compiler:$glide_version"
//View container which can wrap content
implementation 'com.google.android:flexbox:2.0.1'
//Phone Authentication
implementation 'com.google.android.gms:play-services-auth:20.1.0'
implementation 'com.google.android.gms:play-services-auth-api-phone:18.0.1'
implementation 'com.googlecode.libphonenumber:libphonenumber:8.7.0'
//Video player
implementation 'com.google.android.exoplayer:exoplayer:2.11.3'
//Dependency injection - Koin AndroidX Scope features
implementation "io.insert-koin:koin-android:$koin_version"
implementation "io.insert-koin:koin-androidx-workmanager:$koin_version"
testImplementation "io.insert-koin:koin-test-junit4:$koin_version"
testImplementation "io.insert-koin:koin-test:$koin_version"
//WorkManager
implementation "androidx.work:work-runtime-ktx:2.7.1"
// App Startup
implementation "androidx.startup:startup-runtime:1.1.0"
//Progress button extension
implementation 'com.github.razir.progressbutton:progressbutton:2.1.0'
//PDF Viewer
implementation "com.github.barteksc:android-pdf-viewer:$pdf_view_version"
//Amplitude
implementation 'com.amplitude:android-sdk:2.25.2'
//Salesforce chat
implementation "com.salesforce.service:chat-ui:4.2.2"
//Jumio
implementation "com.jumio.android:core:3.9.2#aar" // Jumio Core library
implementation "com.jumio.android:nv:3.9.2#aar" // Netverify library
implementation "com.jumio.android:nv-barcode:3.9.2#aar" // Barcode scanning
implementation "com.jumio.android:nv-mrz:3.9.2#aar" // MRZ scanning
//AppsFlyer
implementation 'com.appsflyer:af-android-sdk:6.2.0'
implementation 'com.android.installreferrer:installreferrer:2.2'
// Code Scanner & Camera
implementation "com.google.mlkit:barcode-scanning:$barcode_scanner_version"
implementation "androidx.camera:camera-camera2:$camerax_version"
implementation "androidx.camera:camera-lifecycle:$camerax_version"
implementation "androidx.camera:camera-view:$camera_view_version"
// Braze (marketing push notifications)
implementation "com.appboy:android-sdk-ui:$appboy_version"
// Room
implementation "androidx.room:room-ktx:$room_version"
kapt "androidx.room:room-compiler:$room_version"
androidTestImplementation "androidx.room:room-testing:$room_version"
implementation "androidx.room:room-runtime:$room_version"
// Compose
implementation "androidx.compose.material3:material3:$compose_material3"
implementation "androidx.compose.runtime:runtime:$compose_version"
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.foundation:foundation:$compose_version"
implementation "androidx.compose.foundation:foundation-layout:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.runtime:runtime-livedata:$compose_version"
implementation "androidx.compose.ui:ui-tooling:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation "androidx.activity:activity-compose:$activity_compose"
androidTestImplementation "androidx.compose.ui:ui-test:$compose_version"
androidTestImplementation "androidx.compose.ui:ui-test-junit4:$compose_version"
debugImplementation "androidx.compose.ui:ui-test-manifest:$compose_version"
// MP Charts
implementation "com.github.PhilJay:MPAndroidChart:v$mp_chart_version"
// Testing dependencies
androidTestImplementation "androidx.arch.core:core-testing:$core_testing_version"
androidTestImplementation "androidx.test.espresso:espresso-contrib:$espresso_version"
androidTestImplementation "androidx.test.espresso:espresso-core:$espresso_version"
// Modules
lintChecks project(':lint')
// Miscellaneous
implementation "org.jetbrains.kotlin:kotlin-reflect:$kotlin_reflect_version"
//Memory leak analysis - should only run in dev builds (devqaImplementation)
//devqaImplementation 'com.squareup.leakcanary:leakcanary-android:2.2'
}
Getting this warning message, I updated already everything what I am missing can somone tell me?
We recommend using a newer Android Gradle plugin to use compileSdk = 33
This Android Gradle plugin (7.2.1) was tested up to compileSdk = 32
This warning can be suppressed by adding
android.suppressUnsupportedCompileSdk=33
to this project's gradle.properties
The build will continue, but you are strongly encouraged to update your project to
use a newer Android Gradle Plugin that has been tested with compileSdk = 33
thanks
As this message is just a warning, if your build is working fine, I'd suggest you to suppress the warning and don't update your Android Gradle plugin for now. Upgrading this plugin can bring you more trouble than good.
The Android Gradle plugin is published to the Google's Maven repository at maven.google.com.
The plugin's listing with all its versions can be found here. You can pick a version of that list and test your build.
Just update the following line of your build.gradle file with the desired version:
dependencies {
classpath 'com.android.tools.build:gradle:<NEW_VERSION_HERE>'
...
}
Keep in mind that you might need to update your Android Studio to the Beta or Canary channels do be able to use the newer versions of that plugin without problems.
The follwing changes works for me:
Ctrl+Alt+Shift+S
In ProjectStructure change the
Modules / Properties / Compile SDK version / 33
Modules / Default Config / Target SDK version / 33
Modules / Default Config / Min SDK version / 33
Than choose an emulator with API 33, example: Pixel 6 API 33
Update plugins in build.gradle (project)
id 'com.android.application' version '7.3.0' apply false
id 'com.android.library' version '7.3.0' apply false
It works for me.
I have such a problem I can't figure out how to solve it. I have a task to make geofencing + firebase token. Geofencing works well even in the background, but if I add com.google.gms.google-services it stops my geofencing in the background, I tried different versions but nothing works. Maybe someone had the same problem, help what you can., thank you! Here is my build.gradle.
/// 1
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.30"
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
classpath 'com.google.gms:google-services:4.3.10' // Google Services plugin
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
/// 2
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'kotlin-parcelize'
id 'com.google.gms.google-services'
id 'com.google.firebase.crashlytics'
}
dependencies {
//common
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'com.google.android.material:material:1.7.0-alpha01'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation("androidx.work:work-runtime-ktx:2.7.1")
implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.alimuzaffar.lib:pinentryedittext:2.0.6'
implementation "org.jetbrains.kotlin:kotlin-reflect:1.5.0"
//network
implementation 'com.google.code.gson:gson:2.8.7'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.5.0'
implementation 'com.jakewharton.retrofit:retrofit2-rxjava2-adapter:1.0.0'
implementation 'io.reactivex.rxjava2:rxandroid:2.0.1'
implementation 'io.reactivex.rxjava2:rxjava:2.2.5'
//dagger
kapt "com.google.dagger:dagger-compiler:2.17"
implementation "com.google.dagger:dagger:2.17"
//moxy
implementation 'tech.schoolhelper:moxy-x:1.7.0'
implementation 'tech.schoolhelper:moxy-x-androidx:1.7.0'
kapt 'tech.schoolhelper:moxy-x-compiler:1.7.0'
implementation 'com.github.orangegangsters:swipy:1.2.3#aar'
//firebase
implementation platform('com.google.firebase:firebase-bom:30.0.1')
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-messaging'
//locations
implementation "com.google.android.gms:play-services-location:18.0.0"
implementation 'com.google.android.gms:play-services-maps:18.0.0'
//billing
def billing_version = '4.1.0'
implementation "com.android.billingclient:billing-ktx:$billing_version"
implementation 'com.anjlab.android.iab.v3:library:2.0.3'
}
I have a problem with my hilt injection. Recently I started learning Kotlin and Hilt for my project. I watched some tutorials and afterwhile tried to write my own code
My build.gradle
dependencies {
classpath 'com.android.tools.build:gradle:4.2.1'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "com.google.dagger:hilt-android-gradle-plugin:2.28.3-alpha"
classpath 'com.google.gms:google-services:4.3.8'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
}
}
And this one build.gradle
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
debuggable true
signingConfig signingConfigs.config
}
debug {
signingConfig signingConfigs.config
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.3.1'
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'com.google.android.material:material:1.2.1'
implementation 'androidx.constraintlayout:constraintlayout:2.0.1'
implementation 'com.google.firebase:firebase-firestore:23.0.0'
implementation 'com.google.firebase:firebase-storage:20.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation platform('com.google.firebase:firebase-bom:28.0.1')
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.android.exoplayer:exoplayer:2.14.0'
implementation 'com.google.android.exoplayer:exoplayer-core:2.14.0'
implementation 'com.google.android.exoplayer:exoplayer-dash:2.14.0'
implementation 'com.google.android.exoplayer:exoplayer-ui:2.14.0'
// Material Design
implementation 'com.google.android.material:material:1.3.0-alpha02'
// Architectural Components
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
// Lifecycle
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.2.0"
implementation "androidx.lifecycle:lifecycle-runtime:2.2.0"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0"
// Coroutines
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.9'
implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.9'
// Coroutine Lifecycle Scopes
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.2.0"
implementation "androidx.lifecycle:lifecycle-runtime-ktx:2.2.0"
// Navigation Component
implementation "androidx.navigation:navigation-fragment-ktx:2.3.0"
implementation "androidx.navigation:navigation-ui-ktx:2.3.0"
// Glide
implementation 'com.github.bumptech.glide:glide:4.11.0'
// Activity KTX for viewModels()
implementation "androidx.activity:activity-ktx:1.1.0"
//Dagger - Hilt
implementation "com.google.dagger:hilt-android:2.28-alpha"
kapt 'com.google.dagger:hilt-android-compiler:2.28-alpha'
implementation "androidx.hilt:hilt-lifecycle-viewmodel:1.0.0-alpha02"
kapt 'androidx.hilt:hilt-compiler:1.0.0-alpha02'
}
I have a java.lang.reflect.InvocationTargetException (no error message) error
And just one message in console This one message
Whats wrong? I read a lot of suggestions but none of them helped
Injection code
Did you add hilt-android-gradle-plugin to your project's root build.gradle file? This is how my gradle looks like:
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-kapt'
id 'dagger.hilt.android.plugin'
id 'kotlin-parcelize'
}
Your classpath version should be the same as these two
implementation "com.google.dagger:hilt-android:2.28-alpha"
kapt 'com.google.dagger:hilt-android-compiler:2.28-alpha'
If it still doesn't work. Try to update all your hilt related to the lastest version, and make sure change your kotlin_version to 1.4.32. If you want to see the changes on hilt check out this: https://github.com/google/dagger/releases
just add this
hilt {
enableAggregatingTask = true
}
into your build.gradle modules like this
dependencies {
implementation project(path: ":core")
implementation project(path: ":domain")
implementation project(path: ":features:homepage")
implementation project(path: ":features:detailpage")
}
hilt {
enableAggregatingTask = true
}
I faced the same problem, and solved by updating Dagger Hilt dependencies to the latest version.
You can find the latest version in the documentation
i used '1.5.30' instead of '1.7.0' and it worked
id 'org.jetbrains.kotlin.android' version '1.5.30' apply false
I just changed my dependency of classpath version same as my hilt version in
buld.gradle file (Project level)
like this
dependencies {classpath("com.google.dagger:hilt-android-gradle-plugin:2.38.1")}
Your Class Path Hilt version and Your hilt version are not the same.
build.gradle(:app)
id 'com.google.dagger.hilt.android' version '2.44' apply false
build.gradle(Module)
def hilt_version="2.44"
implementation "com.google.dagger:hilt-android:$hilt_version"
kapt "com.google.dagger:hilt-compiler:$hilt_version"
I have some problems occur on my project which is :
android.annotation cannot be resolved.
For your information, I have migrated to androidx library. I assume that all my codes will be automatically change to androidx but only some of them changed. Current Version Android Studio is 3.5.
What have I done are
Invalidate and Restart
Clean and Rebuild
All path for sdk has been selected
The application installed on my devices, but keep stopping. Here are my details:
build.gradle(project)
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.0'
//classpath 'com.google.gms:google-services:3.2.0'
classpath 'com.google.gms:google-services:4.3.2'
//classpath 'com.google.gms:google-services:4.3.2'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(module app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
buildToolsVersion '28.0.3'
defaultConfig {
applicationId "com.kartik.barcode"
minSdkVersion 17
targetSdkVersion 26
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
//implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.legacy:legacy-support-core-utils:1.0.0'
implementation 'androidx.legacy:legacy-support-core-ui:1.0.0'
implementation 'androidx.fragment:fragment:1.0.0'
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.palette:palette:1.0.0'
implementation 'androidx.preference:preference:1.0.0'
implementation 'androidx.core:core:1.0.0'
implementation 'androidx.media:media:1.0.0'
implementation 'androidx.vectordrawable:vectordrawable-animated:1.0.0'
implementation 'androidx.browser:browser:1.0.0'
implementation 'com.journeyapps:zxing-android-embedded:3.0.2#aar'
implementation 'com.google.zxing:core:3.2.0'
implementation 'com.google.firebase:firebase-database:19.1.0'//for firebase
implementation 'com.google.firebase:firebase-auth:19.0.0'
implementation 'com.google.firebase:firebase-storage:19.0.1'
implementation 'com.google.firebase:firebase-messaging:20.0.0'
implementation 'com.google.firebase:firebase-appindexing:19.0.0'
implementation 'com.google.firebase:firebase-firestore:21.1.1'
implementation 'com.google.firebase:firebase-analytics:17.2.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.android.gms:play-services-ads:18.2.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.annotation:annotation:1.1.0'
//annotationProcessor 'androidx.annotation:annotation:1.1.0'
implementation 'com.android.support:support-annotations:28.0.0'
}
apply plugin: 'com.google.gms.google-services'
HERE THE PROBLEMS OCCUR
logcat
When I view the java class, the import still android and not androidx. Even I changed to androidx, it still cannot be resolved.
java class
Remove this
implementation 'androidx.annotation:annotation:1.1.0'
implementation 'com.android.support:support-annotations:28.0.0'
and delete yours imports once and reImport
like this
import android.annotation.SuppressLint;