【问题标题】:Android Glide can't resolve symbolAndroid Glide 无法解析符号
【发布时间】:2020-06-07 20:09:37
【问题描述】:

我在两个项目中使用这个版本的 Glide

compile 'com.github.bumptech.glide:glide:3.7.0'

我不知道如何以及为什么,但 Android Studio 无法解析符号“asBitmap() 和 GlideAnimation

 Glide.with(this).load(path).asBitmap().override(200, 200).into(new SimpleTarget<Bitmap>() {
        @Override
        public void onResourceReady(Bitmap resource, GlideAnimation glideAnimation) {
            RoundedBitmapDrawable circularBitmapDrawable = RoundedBitmapDrawableFactory.create(getResources(), resource);
            circularBitmapDrawable.setCircular(true);
            mImageViewProfilePic.setImageDrawable(circularBitmapDrawable);

        }

        @Override
        public void onLoadFailed(Exception e, Drawable errorDrawable) {
            // Do something.
            mImageViewProfilePic.setImageDrawable(getResources().getDrawable(R.drawable.placeholder_photo_profile));
        }
    });

现在它要求我像在版本 4+ 中一样使用它?

public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {

即使在那之后它也无法解决这个方法....

然后我尝试删除 Glide 库,但项目仍然找到导入(“import com.bumptech.glide.request.animation.GlideAnimation”除外)

我清理、重建、使缓存无效....我有与我的其他项目相同的东西,它运行良好。

apply plugin: 'com.android.application'
apply plugin: 'io.fabric'

android {
    compileSdkVersion 27
    buildToolsVersion "27.0.2"
    useLibrary  'org.apache.http.legacy'

dexOptions {
    javaMaxHeapSize "4g"
    jumboMode true
}

defaultConfig {
    applicationId "fr.my.app"
    minSdkVersion 17
    targetSdkVersion 27
    versionCode 6
    versionName "2.1"
    multiDexEnabled true
    vectorDrawables.useSupportLibrary = true

}


buildTypes {
    debug {
        buildConfigField "boolean", "PRE_PROD", "false"
        applicationIdSuffix '.debug'
        versionNameSuffix '.D'
    }
}

packagingOptions {
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE-FIREBASE.txt'
    exclude 'META-INF/NOTICE'
}
}

ext.ANDROID_SUPPORT_LIBRARY_VERSION = "27.0.2"
ext.GOOGLE_PLAY_VERSION = "11.8.0"


dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:' + ANDROID_SUPPORT_LIBRARY_VERSION
implementation 'com.android.support:support-v4:' + ANDROID_SUPPORT_LIBRARY_VERSION
implementation 'com.android.support:design:' + ANDROID_SUPPORT_LIBRARY_VERSION
implementation 'com.android.support:cardview-v7:' + ANDROID_SUPPORT_LIBRARY_VERSION

implementation 'com.google.android.gms:play-services-location:' + GOOGLE_PLAY_VERSION
implementation 'com.google.android.gms:play-services-places:' + GOOGLE_PLAY_VERSION
implementation 'com.google.android.gms:play-services:' + GOOGLE_PLAY_VERSION
implementation 'com.google.maps.android:android-maps-utils:0.5'

// Graph Lib
implementation 'com.github.PhilJay:MPAndroidChart:v3.0.3'


// Android NetWorking Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
implementation 'com.squareup.okhttp3:okhttp:3.4.1'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.1.0'
implementation 'com.squareup.okio:okio:1.13.0'

// JSON Parsing
implementation 'com.google.code.gson:gson:2.6.1'
implementation 'com.squareup.retrofit2:converter-gson:2.1.0'

//The string required for Firebase integration
implementation 'com.google.firebase:firebase-core:' + GOOGLE_PLAY_VERSION
implementation 'com.google.firebase:firebase-messaging:' + GOOGLE_PLAY_VERSION

implementation('com.crashlytics.sdk.android:crashlytics:2.6.8@aar') {
    transitive = true;
}


//SMOOCH
implementation 'io.smooch:core:latest.release'
implementation 'io.smooch:ui:latest.release'

implementation 'uk.co.chrisjenx:calligraphy:2.1.0'
implementation 'com.aurelhubert:ahbottomnavigation:2.1.0'

// AWESOOOOOOME TOAST LIB
implementation 'com.irozon.sneaker:sneaker:1.0.2'

// PHONE NUMBER LIB
implementation('com.lamudi.phonefield:phone-field:0.1.3@aar') {
    transitive = true
}

implementation 'de.greenrobot:eventbus:2.4.0'
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.facebook.android:facebook-login:[4,5)'

// PHOTO LOADER
implementation'com.github.bumptech.glide:glide:3.7.0'
}
apply plugin: 'com.google.gms.google-services'

更新 1

我在我的外部库中看到 gradle 正在构建版本 4.6.1

我试图删除 .iml 和 .idea 文件夹...没有变化 Glide 仍然是 bug,即使我删除了 lib,仍然存在。

更新 2

    compile group: 'com.github.bumptech.glide', name: 'glide', version: '4.6.1'

然后我在我的代码中更新了 Glide 的方法,现在我收到了这条消息:

Multiple dex files define Lcom/google/android/gms/internal/zzcms

我尝试将 GOOGLE_PLAY_VERSION 更改为 gms 并将 firebase 更改为相同但没有更改。

【问题讨论】:

  • 尝试使用最新版本,看看它是否有效。最新版本是4.7.0

标签: android android-glide


【解决方案1】:

不要使用编译。使用实现:

implementation'com.github.bumptech.glide:glide:3.7.0'

另外,请确认您是否选中了“离线工作”。

【讨论】:

  • 好的,现在我已经“实施”了,我尝试了所有的“离线工作”检查,但没有检查。我认为问题来自宇宙的尽头。如果我删除我的 MPchart 库,导入丢失,但如果我删除 Glide 库,importe 仍然在这里。
  • 是的,但我的答案无需标记。谈论忘恩负义。另外,如果您需要更多帮助,为什么不发布您的 gradle 文件(build.gradle)?您是否设置了 Maven 存储库?您是否验证了“路径”变量?
  • 我对记下你的答案很不好,我什至没有注意到。我用 build.gradle 更新我的帖子
  • 没关系,伙计。只是想达到 50 个代表;)我看不出你的 gradle 文件有什么问题。也许您的路径变量不正确?我会记录下来只是为了确保。
  • 而不是实现'com.github.bumptech.glide:glide:3.7.0',尝试编译组:'com.github.bumptech.glide',名称:'glide',版本:' 4.6.1'
【解决方案2】:

你必须像这样使用它

Glide.with(this).asBitmap()

这样就可以解决问题了

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-05-03
    • 1970-01-01
    • 2016-06-15
    • 2017-02-09
    • 2015-12-28
    • 2016-03-03
    相关资源
    最近更新 更多