如何在 android studio 2021.1 中使用 google 库以外的库
How to use libraries other than google libraries in android studio 2021.1
我创建了一个运行良好的空白 android 项目,但是当我尝试使用在 github 上找到的这个库时,我收到了这个错误。
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.
当我使用任何 github 库但 google 库编译没有问题时会发生错误。请问我该怎么办?
这是我的 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'
}
这是我的 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'
我不知道我做错了什么。我真的卡住了,我无法使用 github 库
com.miguelcatalan:materialsearchview
has not been updated in five years。我强烈建议您使用正在积极维护的库。使用 actively-maintained 库的一个 side-effect 是它将在您使用的工件存储库之一中。
如果你坚持要用这个库,改:
repositories {
maven {url 'https://jitpack.io'}
google()
mavenCentral()
}
至:
repositories {
maven {url 'https://jitpack.io'}
google()
mavenCentral()
jcenter()
}
我创建了一个运行良好的空白 android 项目,但是当我尝试使用在 github 上找到的这个库时,我收到了这个错误。
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.
当我使用任何 github 库但 google 库编译没有问题时会发生错误。请问我该怎么办?
这是我的 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'
}
这是我的 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'
我不知道我做错了什么。我真的卡住了,我无法使用 github 库
com.miguelcatalan:materialsearchview
has not been updated in five years。我强烈建议您使用正在积极维护的库。使用 actively-maintained 库的一个 side-effect 是它将在您使用的工件存储库之一中。
如果你坚持要用这个库,改:
repositories {
maven {url 'https://jitpack.io'}
google()
mavenCentral()
}
至:
repositories {
maven {url 'https://jitpack.io'}
google()
mavenCentral()
jcenter()
}