我无法使用自动图像滑块,但无法这样做

问题描述 投票:0回答:4

我只是想使用自动图像滑块,但在添加所有依赖项和其他要求(如 jitpack.io)后,我仍然无法使用自动图像滑块的 sliderLayout,现在我已经尝试了每个 stackoverflow 解决方案

这是我的 build.gradle(:app) 文件

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

这是我的build.gradle(项目)

// 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) 详细信息如下

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'

这是我尝试使用自动图像滑块布局/视图的文件

<?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>

请有人帮助我

java android android-studio kotlin android-layout
4个回答
1
投票

setting.gradle

中添加一行
jcenter()

0
投票

您添加了

autoimageslider
库的依赖项。请从您的 build.gradle 中删除此
implementation 'com.github.smarteist:autoimageslider:1.4.0-appcompat
依赖项,然后再次删除
sync
。因为这个依赖项
implementation 'com.github.smarteist:autoimageslider:1.4.0-appcompat'
适用于
AndroidX
,而这个依赖项
implementation 'com.github.smarteist:autoimageslider:1.4.0'
适用于android appcompact。

因此,从 build.gradle 中删除如下所示的依赖项。

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

如果您的问题仍然存在,请告诉我


0
投票

使用 jcenter 对我有用,尽管它要求我将 jcenter 替换为 mavencenteral


0
投票

使用这个更新的植入

implementation 'com.github.smarteist:Android-Image-Slider:1.4.0'
© www.soinside.com 2019 - 2024. All rights reserved.