You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Android Studio无法引入android-gif-drawable依赖求助

无法导入android-gif-drawable库的问题求助

我尝试将android-gif-drawable库引入Android项目,已配置implementation依赖及相关设置,但无法导入或使用该库。

我的配置文件

build.gradle(:app)

plugins {
    id 'com.android.application'
    id 'org.jetbrains.kotlin.android'
}

android {
    compileSdk 32

    defaultConfig {
        applicationId "com.example.androidapp"
        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
    }
    kotlinOptions {
        jvmTarget = '1.8'
    }
    buildFeatures {
        viewBinding true
    }
}

dependencies {

    implementation 'androidx.core:core-ktx:1.7.0'
    implementation 'androidx.appcompat:appcompat:1.3.0'
    implementation 'com.google.android.material:material:1.4.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
    implementation 'androidx.navigation:navigation-fragment-ktx:2.3.5'
    implementation 'androidx.navigation:navigation-ui-ktx:2.3.5'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'

    implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.25'
    implementation 'com.squareup.picasso:picasso:2.8'
}

settings.gradle(AndroidApp)

import org.gradle.api.initialization.resolve.RepositoriesMode

pluginManagement {
    repositories {
        gradlePluginPortal()
        google()
        //jcenter()
        mavenCentral()
    }
}
dependencyResolutionManagement {
    repositoriesMode.set(RepositoriesMode.FAIL_ON_PROJECT_REPOS)
    repositories {
        google()
        //jcenter()
        mavenCentral()
        //maven { url "https://oss.sonatype.org/content/repositories/snapshots" }
       // maven { url 'https://jitpack.io' }
    }
}
rootProject.name = "AndroidApp"
include ':app'

遇到的错误

每次尝试导入pl.droidsonroids.gif.GifImageView或在布局中使用<pl.droidsonroids.gif.GifImageView>时,都会出现以下错误:

  • import pl.droidsonroids.gif.GifImageView; -> Unresolved reference: pl
  • <pl.droidsonroids.gif.GifImageView -> Cannot resolve class pl.droidsonroids.gif.GifImageView

我曾按照官方文档配置buildscript和allprojects,但出现错误:

Build was configured to prefer settings repositories over project repositories but repository 'MavenRepo' was added by build file 'app\build.gradle'

目前无法确认库是否正确加载,也找不到解决办法,特此求助。


内容的提问来源于stack exchange,提问作者Samael

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.08.03 04:55:17