在 android studio 中实施 com.amulyakhare 库

implementing the com.amulyakhare library in android studio

你好,我正在尝试将 github 中名为 amulyakhare 的库导入到我的 android 工作室项目中,但在同步后我不断收到以下错误:

Failed to resolve: com.amulyakhare:com.amulyakhare.textdrawable:1.0.1
Show in Project Structure dialog
Affected Modules: app

您可以在此处找到图书馆的 github 页面:

@github/amulyakhare

这是 build.gradle(app) 中的代码:

apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'



android {
    compileSdkVersion 30

    defaultConfig {
        applicationId "com.example.androidnewchatapp"
        minSdkVersion 28
        targetSdkVersion 30
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {


    implementation platform('com.google.firebase:firebase-bom:27.1.0')

    implementation 'androidx.appcompat:appcompat:1.2.0'
    implementation 'com.google.android.material:material:1.3.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'



    //Firebase UI
    implementation 'com.firebaseui:firebase-ui-auth:7.1.1'
    implementation 'com.firebaseui:firebase-ui-database:7.1.1'



    //viewPager 2
    implementation 'androidx.viewpager2:viewpager2:1.1.0-alpha01'

    //ButterKnife
    implementation 'com.jakewharton:butterknife:10.2.3'
    annotationProcessor'com.jakewharton:butterknife-compiler:10.2.3'

    //Dexter
    implementation 'com.karumi:dexter:6.1.2'

    //TextDrawable (The amulyakhare Library)
    implementation 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'

    //EventBus
    implementation 'org.greenrobot:eventbus:3.2.0'

    //Glide
    implementation 'com.github.bumptech.glide:glide:4.12.0'
    annotationProcessor'com.github.bumptech.glide:compiler:4.11.0'


    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.2'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
    implementation 'com.google.firebase:firebase-analytics'
}

我不知道是库有问题还是我的代码中缺少什么。预先感谢那些可以提供帮助的人

我想通了

1)在你的项目级别gradle添加jcenter()

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

JCenter Maven 存储库不再接收更新:更新的库版本可能在其他地方可用

所以您需要在其他地方找到相同的库。或者你可以 fork 自己并上传到 jitpack

将其添加到您的根 build.gradle 存储库末尾:

allprojects {
    repositories {
        ...
        maven { url 'https://jitpack.io' }
    }
}

添加依赖

dependencies {
        implementation 'com.github.alvinhkh:TextDrawable:f9f516c43b'
}

https://jitpack.io/#alvinhkh/TextDrawable/f9f516c43b

将此添加到您的 settings.gradle

   jcenter()
    maven {
        url 'https://jitpack.io'
    }

如果你使用的是 android studio bumblebee settings.gradle 应该是这样的

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        mavenCentral()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        mavenCentral()
        jcenter()
        maven {
            url 'https://jitpack.io'
        }
    }
}
rootProject.name = "You App Name"
include ':app'

如果不行,尝试导入jar文件,从this

下载