'I migrated existing android project to Android X using Android Studio, but I am unable to import/resolve any androidx library - what am i doing wrong?
I recently migrated an old android project to Android X using the automated Android Studio route. My gradle dependencies are all there, but I am unable to use any androidx library. Can you please advise on what I am doing wrong? Every time I try to import an Android X library (i.e. import androidx.fragment.app.Fragment) I get the cannot resolve error
compileSDKVersion and targetSdkVersion =32 and minSdkVersion =26
I also have gradle properties include the following
android.enableJetifier=true android.useAndroidX=true
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.6.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'com.android.volley:volley:1.1.0'
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]'
implementation 'androidx.drawerlayout:drawerlayout:1.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0'
implementation 'com.squareup.picasso:picasso:2.71828'
}
Project Level Gradle:
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:7.2.0'
classpath 'com.google.gms:google-services:4.3.10'
// 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
}
Solution 1:[1]
Add
implementation 'androidx.fragment:fragment-ktx:1.4.0'
and any other necessary dependencies in your build.gradle file. Sync project with gradle and everything should be fine.
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 | Chuba Samuel - DCOR |

