I’m building a movies app and trying to import some online libraries. However, when I try to use them in another file, it shows “unresolved reference.” I’ve tried everything to fix it but there’s still no change. I followed each and every step given by ChatGPT and also from similar questions asked here.
Libraries I’m using:
File name: libs.versions.toml
[versions]
appcompat = "1.7.0"
material = "1.12.0"
activity = "1.9.0"
constraintlayout = "2.1.4"
glide = "4.12.0"
gson = "2.10.1"
volley = "1.2.1"
junit = "4.13.2"
extjunit = "1.1.3"
espresso = "3.4.0"
[libraries]
appcompat = { group = "androidx.appcompat", name = "appcompat", version.ref = "appcompat" }
material = { group = "com.google.android.material", name = "material", version.ref = "material" }
activity = { group = "androidx.activity", name = "activity", version.ref = "activity" }
constraintlayout = { group = "androidx.constraintlayout", name = "constraintlayout", version.ref = "constraintlayout" }
glide = { group = "com.github.bumptech.glide", name = "glide", version.ref = "glide" }
gson = { group = "com.google.code.gson", name = "gson", version.ref = "gson" }
volley = { group = "com.android.volley", name = "volley", version.ref = "volley" }
junit = { group = "junit", name = "junit", version.ref = "junit" }
ext.junit = { group = "androidx.test.ext", name = "junit", version.ref = "extjunit" }
espresso.core = { group = "androidx.test.espresso", name = "espresso-core", version.ref = "espresso" }
settings file to use the lib file
File name: settings.gradle.kts
pluginManagement {
repositories {
google {
content {
includeGroupByRegex("com\.android.*")
includeGroupByRegex("com\.google.*")
includeGroup("androidx.*")
}
}
mavenCentral()
gradlePluginPortal()
}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
google()
mavenCentral()
}
versionCatalogs {
create("libs") {
from(files("gradle/libs.versions.toml"))
}
}
}
rootProject.name = "PoPoMovies"
include(":app")
Build File
plugins {
alias(libs.plugins.android.application)
}
android {
namespace = "com.example.popomovies"
compileSdk = 34
defaultConfig {
applicationId = "com.example.popomovies"
minSdk = 26
targetSdk = 34
versionCode = 1
versionName = "1.0"
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
isMinifyEnabled = false
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
compileOptions {
sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
}
}
dependencies {
implementation(libs.appcompat)
implementation(libs.material)
implementation(libs.activity)
implementation(libs.constraintlayout)
implementation(libs.glide) // not importing this
implementation(libs.gson) // not importing this
implementation(libs.volley) // not importing this
testImplementation(libs.junit)
androidTestImplementation(libs.ext.junit)
androidTestImplementation(libs.espresso.core)
}
It also gives this error which i am not able to fix
FAILURE: Build failed with an exception. * What went wrong: org.gradle.api.InvalidUserDataException:
On library declaration 'ext' expected to find any of 'group', 'module', 'name', or 'version' but found unexpected key 'junit'. >
On library declaration 'ext' expected to find any of 'group', 'module', 'name', or 'version' but found unexpected key 'junit'.