Home > Software engineering >  How to use libraries other than google libraries in android studio 2021.1
How to use libraries other than google libraries in android studio 2021.1

Time:05-09

I created a blank android project that works very well but when I try to use this library found on github I get this error.

failed org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException: Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.miguelcatalan:materialsearchview:1.4.0.
org.gradle.internal.resolve.ModuleVersionNotFoundException: Could not find com.miguelcatalan:materialsearchview:1.4.0.

The error occurs when I use any github library but google libraries compile without problem. What should I do please?

Here is my build.gradle

plugins {
id 'com.android.application'
}

android {
compileSdk 32

defaultConfig {
    applicationId "com.example.myapplication"
    minSdk 21
    targetSdk 32
    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
}
}

dependencies {

//implementation 'com.google.android.material:material:1.4.0'
//implementation 'androidx.constraintlayout:constraintlayout:2.0.4'

implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'androidx.vectordrawable:vectordrawable-animated:1.1.0'
implementation 'androidx.exifinterface:exifinterface:1.3.3'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'com.google.firebase:firebase-analytics:20.1.2'

implementation 'org.apache.commons:commons-text:1.6'
implementation 'com.github.ksoichiro:simplealertdialog:1.2.1@aar'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'

implementation 'com.google.android.material:material:1.7.0-alpha01'
implementation 'androidx.recyclerview:recyclerview:1.3.0-alpha02'
implementation 'androidx.cardview:cardview:1.0.0'

implementation 'com.miguelcatalan:materialsearchview:1.4.0' //Here is github Library

testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}

And here is my settings.gradle

pluginManagement {
repositories {
    maven {url 'https://jitpack.io'}
    gradlePluginPortal()
    google()
    mavenCentral()

}
}
dependencyResolutionManagement {
repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
repositories {
    maven {url 'https://jitpack.io'}
    google()
    mavenCentral()

}
}
rootProject.name = "My Application"
include ':app'

I don't know what I did wrong. I'm really stuck I can't use the github libraries

CodePudding user response:

com.miguelcatalan:materialsearchview has not been updated in five years. I strongly recommend that you use libraries that are being actively maintained. A side-effect of using an actively-maintained library is that it will be in one of the artifact repositories that you use.

If you insist on using this library, change:

repositories {
    maven {url 'https://jitpack.io'}
    google()
    mavenCentral()

}

to:

repositories {
    maven {url 'https://jitpack.io'}
    google()
    mavenCentral()
    jcenter()
}
  • Related