首页 > 解决方案 > 在 android studio 中实现 com.amulyakhare 库

问题描述

您好,我正在尝试将一个名为 amulyakare 的库从 github 导入到我的 android studio 项目中,但同步后我一直收到以下错误:

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'
}

我不知道库是否有问题,或者我的代码中是否缺少某些内容。提前感谢那些可以提供帮助的人

标签: android-studioimportshared-librariesgithub-apiimplementation

解决方案


我想到了

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

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

推荐阅读