'I am unable to use auto Image slider but not able to do so

I just wanted to use Auto image Slider, but after adding all the dependencies and other requirments like jitpack.io still I am unable to use sliderLayout of auto Image slider and now I have tried every stackoverflow solution

this is my build.gradle(:app)file

plugins {
    id 'com.android.application'
}
android {
    compileSdk 31 
    defaultConfig {
    applicationId "com.example.mycollege"
    minSdk 21
    targetSdk 31
    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 'androidx.appcompat:appcompat:1.4.1'
    implementation 'com.google.android.material:material:1.5.0'
    implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
    implementation 'androidx.legacy:legacy-support-v4:1.0.0'
    testImplementation 'junit:junit:4.13.2'
    androidTestImplementation 'androidx.test.ext:junit:1.1.3'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
    implementation 'androidx.navigation:navigation-fragment:2.4.1'
    implementation 'androidx.navigation:navigation-ui:2.4.1'
    implementation 'androidx.compose.material3:material3:1.0.0-alpha08'
    implementation 'com.github.bumptech.glide:glide:4.13.1'
    implementation 'com.github.smarteist:autoimageslider:1.4.0'
    implementation 'com.github.smarteist:autoimageslider:1.4.0-appcompat'
    implementation 'com.github.jitpack:gradle-simple:1.0'
}

here is my build.gradle(project)

// Top-level build file where you can add configuration options common to all sub- 
projects/modules.

plugins {
    id 'com.android.application' version '7.1.2' apply false
    id 'com.android.library' version '7.1.2' apply false
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

settings:gradle(project) details are as follows

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

here is the file in which I am trying to use the auto image slider layout/view

<?xml version="1.0" encoding="utf-8"?>
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:tools="http://schemas.android.com/tools"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".UI.Home.HomeFragment">

    <ScrollView
        android:layout_width="match_parent"
        android:layout_height="match_parent">

        <LinearLayout
            android:layout_width="match_parent"
            android:layout_height="match_parent"
            android:orientation="vertical">

           <com.smarteist.autoimageslider.SliderLayout> 
           </com.smarteist.autoimageslider.SliderLayout>
                 // its showing error called "Class referenced in the layout file, 
                 com.smarteist.autoimageslider.SliderLayout, was not found in the 
                 project or the libraries
                 Cannot resolve class com.smarteist.autoimageslider.SliderLayout "

        </LinearLayout>

    </ScrollView>

</FrameLayout>

please somebody help me out



Solution 1:[1]

You added both dependency of autoimageslider library. PLease remove this implementation 'com.github.smarteist:autoimageslider:1.4.0-appcompat dependency from your build.gradle and sync again. Because this dependency implementation 'com.github.smarteist:autoimageslider:1.4.0-appcompat' is for AndroidX and this dependency implementation 'com.github.smarteist:autoimageslider:1.4.0' for android appcompact.

So, remove the dependency shown below from your build.gradle.

implementation 'com.github.smarteist:autoimageslider:1.4.0-appcompat

If your problem is still, Let me know

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1