Home > Mobile >  Android studio can't find dependencies android-gif-drawable
Android studio can't find dependencies android-gif-drawable

Time:01-28

i'm trying to import this android-gif-drawable to my project, but even if i did set the emplementation and settings, i can't import or use it.

Here my build.graddle(: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'
}

And my 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'

But everytime i try to import it or use it i got errors: import pl.droidsonroids.gif.GifImageView; -> Unresolved reference: pl

<pl.droidsonroids.gif.GifImageView -> Cannot resolve class pl.droidsonroids.gif.GifImageView

I tried to set as specified on the coral page with the "buildscript" before the "plugins" and "allproject" after, but of course i have the error: Build was configured to prefer settings repositories over project repositories but repository 'MavenRepo' was added by build file 'app\build.gradle'

I can't find a way to make it work or at least see if the library is correctly loaded (but since i don't have an error for the dependency as some other posts, i imagine it found it).

CodePudding user response:

Hum...ok so its's working now... while it wasn't working i restarted android studio, closed the app, clean and rebuilded the project many time, and it was still not working.

I sleeped, restarted to work ( android wasn't closed) and it worked.. I suposed it was stil loading yesterday when i tried? honnestly i dont get it.

hope this will help someone in the same situation

  • Related