簡體   English   中英

我無法使用自動圖像 slider 但無法這樣做

[英]I am unable to use auto Image slider but not able to do so

我只想使用自動圖像 Slider,但是在添加所有依賴項和其他要求(如 jitpack.io)之后,我仍然無法使用自動圖像 slider 的滑塊布局,現在我已經嘗試了所有 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(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) 詳情如下

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'

這是我嘗試在其中使用自動圖像 slider 布局/視圖的文件

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

請有人幫幫我

您添加了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

如果您的問題仍然存在,請告訴我

在設置中添加一行。gradle

中心()

使用 jcenter 對我有用,盡管它要求我將 jcenter 替換為 mavencenteral

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM