I have an app that works properly. Anyway, I have a "strange" behaviour of Android studio, in fact for the xml files it is not able to solve some classes, i.e. drawerLayout, constraintLayout, CircleImage etc. (see the image below)
Before opening android studio I have a warning about adding project dependencies:
Problem: Inconsistencies in the existing project dependencies found. Version incompatibility between:
- androidx.navigation:navigation-ui:2.5.1@aar and:
- androidx.appcompat:appcompat:1.5.0@aar
With the dependency:
- androidx.annotation:*1.1.0
- androidx.annotation:*.2.0.0
What I tried:
- invalidating caches and restarting app
- update my gradle file, as shown below:
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
id 'androidx.navigation.safeargs'
}
apply plugin: "androidx.navigation.safeargs"
sourceSets {
main {
java {
}
}
}
android {
compileSdk 32
defaultConfig {
applicationId "com.example.frangela"
minSdk 21
targetSdk 31
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'de.hdodenhof:circleimageview:3.1.0'
implementation 'androidx.appcompat:appcompat:1.5.0'
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.1"
implementation "androidx.navigation:navigation-ui:2.5.1"
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.firebase:firebase-database:20.0.5'
implementation 'com.google.firebase:firebase-common-ktx:20.1.1'
implementation 'com.google.android.gms:play-services-maps:18.1.0'
implementation 'com.google.android.gms:play-services-location:20.0.0'
implementation 'com.google.firebase:firebase-crashlytics-buildtools:2.9.1'
implementation platform('com.google.firebase:firebase-bom:30.3.1')
implementation 'com.google.firebase:firebase-functions'
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation 'com.firebaseui:firebase-ui-database:8.0.1'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.android.gms:play-services-auth:20.2.0'
implementation 'com.squareup.picasso:picasso:2.8'
implementation 'com.google.firebase:firebase-messaging'
implementation "androidx.constraintlayout:constraintlayout:2.1.4"
implementation "androidx.constraintlayout:constraintlayout-compose:1.0.1"
}
My gradle Module:
buildscript {
repositories {
google()
mavenCentral()
maven { url 'https://repo1.maven.org/maven2' }
}
dependencies {
def nav_version = "2.5.1"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
classpath 'com.android.tools.build:gradle:7.2.2'
classpath 'com.google.gms:google-services:4.3.13'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I think that there could be problems with the dependencies, but for example I cannot find any of that regarding annotation in my gradle file. Thank you in advance for anyone that could help me.
CodePudding user response:
You're applying androidx.navigation.safeargs
twice and srcDirs = 'build/generated/source/navigation-args'
also is useless. With high probability, this project is lacking a proper repositories configuration, while the question complete ignores this part. In case there should be any jcenter()
repository, replace that with mavenCentral()
or google()
.
CodePudding user response:
After hours of works, I solved in a pretty easy way. Copy all the project in another location on my PC, then reopen the project. After opening it from Android Studio everything works fine