簡體   English   中英

如何在 androidx 中使用 picasso 庫

[英]How to use picasso library with androidx

我有一個一年前的代碼,我努力工作,這段代碼在某些地方使用picasso庫來下載圖像並使用它們。 今天我嘗試改進我的代碼,遷移到androidx並將Gradle升級到最新版本,但它似乎不再同步gradle 文件,當我評論picasso庫的實現時,同步再次順利進行。

Google 建議遷移到 androidx 以便能夠提供最新的 android 版本、最新的播放服務和 jetpack 庫。 問題是什么? 以及如何解決?

這是我的 Gradle 應用級文件:

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"

    defaultConfig {
        applicationId "com.ramikabbani.sheikhsouk"
        minSdkVersion 19
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"

        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }

    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }

}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])

    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'

    // Picasso
    implementation 'com.squareup.picasso:picasso:2.71828'

    // Glide
    implementation 'com.github.bumptech.glide:glide:4.9.0'

    implementation 'com.google.android.material:material:1.1.0'
//

}

這是我的頂級項目 gradle 文件:

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

buildscript {

    repositories {
        google()
        jcenter()

    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.1'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()

    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

這是舊項目應用程序級別 gradle 文件:apply plugin: 'com.android.application'

    android {
        compileSdkVersion 29
        defaultConfig {
            applicationId "com.dalilukom.dalilukom"
            minSdkVersion 19
            targetSdkVersion 29
            versionCode 21
            versionName "1.21"
            testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        }
    }

    dependencies {
        implementation fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'com.android.support:appcompat-v7:26.1.0'
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'
        implementation 'pl.droidsonroids.gif:android-gif-drawable:1.2.16'
        implementation 'com.squareup.picasso:picasso:2.71828'
        implementation 'com.github.bumptech.glide:glide:3.8.0'
        //implementation 'com.android.volley:volley:1.1.1'
        implementation 'com.android.support:design:26.1.0'
        implementation 'com.android.support:support-v4:26.1.0'
    //    implementation 'com.amitshekhar.android:android-networking:1.0.2'
    //    implementation 'com.android.support:design:26.1.0'
    //    implementation 'com.android.support:appcompat-v7:27.1.1'
    //    implementation 'com.android.support:design:27.1.1'
    //implementation 'com.nostra13.universalimageloader:universal-image-loader:1.9.5'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'com.android.support.test:runner:1.0.2'
    androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}

這也是舊項目的頂級 gradle 文件:

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

buildscript {

    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.6.1'


        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}

allprojects {
    repositories {
        google()
        jcenter()
    }
}

task clean(type: Delete) {
    delete rootProject.buildDir
}

只需遷移到 androidx 並在你的成績文件中獲取 androidx 的 Picasso 依賴項。 你應該沒事

暫無
暫無

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

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