Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Glide 4.0.0-RC0: AbstractMethodError on registerComponents() #1974

Closed
anthony3444 opened this issue May 29, 2017 · 23 comments
Closed

Glide 4.0.0-RC0: AbstractMethodError on registerComponents() #1974

anthony3444 opened this issue May 29, 2017 · 23 comments

Comments

@anthony3444
Copy link

anthony3444 commented May 29, 2017

Glide Version: 4.0.0-RC0
Integration libraries: okhttp3-integration

In my gradle:

    compile 'com.github.bumptech.glide:glide:4.0.0-RC0'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC0'
    compile ('com.github.bumptech.glide:okhttp3-integration:1.5.0@aar'){
        exclude group: 'glide-parent'
    }

My new Glide configuration:

@GlideModule
public class GlideConfiguration extends AppGlideModule {
    @Override
    public void applyOptions(Context context, GlideBuilder builder) {
        // Apply options to the builder here.
        RequestOptions requestOptions = new RequestOptions();
        requestOptions.format(DecodeFormat.PREFER_ARGB_8888);
        builder.setDefaultRequestOptions(requestOptions);
    }

    @Override
    public void registerComponents(Context context, Registry registry) {
        final OkHttpClient.Builder builder = RestCoreRetrofit.getInitialOkHttpClientBuilder();
        registry.append(GlideUrl.class, InputStream.class, new OkHttpUrlLoader.Factory(builder.build()));
    }
}

For information getInitialOkHttpClientBuilder():

public static OkHttpClient.Builder getInitialOkHttpClientBuilder() {
        OkHttpClient.Builder httpClient = new OkHttpClient.Builder();

        // Setup timeouts
        httpClient.connectTimeout(20, TimeUnit.SECONDS);
        httpClient.readTimeout(60, TimeUnit.SECONDS);
        httpClient.writeTimeout(60, TimeUnit.SECONDS);

        return httpClient;
    }

So, I've migrated v3 to v4 (http://bumptech.github.io/glide/doc/migrating.html). Migration and build are successful, but when I start my App, I have this crash now directly from the first GlideApp calling:

In my fragment:

GlideApp.with(this)
                    .load(resourceId)
                    .into(mBgImageView);

java.lang.AbstractMethodError: abstract method "void com.bumptech.glide.module.RegistersComponents.registerComponents(android.content.Context, com.bumptech.glide.Registry)"
at com.bumptech.glide.Glide.initGlide(Glide.java:217)
at com.bumptech.glide.Glide.get(Glide.java:154)
at com.bumptech.glide.Glide.getRetriever(Glide.java:513)
at com.bumptech.glide.Glide.with(Glide.java:585)
at com.myapp.util.GlideApp.with(GlideApp.java:92)

I can't understand why. I checked several times the documentation.

Thank you very much for your support guys!

@TWiStErRob
Copy link
Collaborator

TWiStErRob commented May 29, 2017

You're using 3.8.0's integration: 1.5.0@aar (also that exclude became irrelevant with 1.5.0)

@TWiStErRob
Copy link
Collaborator

@sjudd what would you think about adding a version mapping for all possible dependencies to the migration page?

@sjudd
Copy link
Collaborator

sjudd commented May 31, 2017

I'd be totally happy to review a change: http://bumptech.github.io/glide/dev/contributing.html#documentation

@jimitpatel
Copy link

Even I am getting the problem without any customization.
Also I am using Glide for the first time.
Here is what I am using

Gradle-


    compile "com.android.support:support-v4:25.3.1"
    //Glide
    compile "com.github.bumptech.glide:glide:4.0.0-RC0"
    annotationProcessor "com.github.bumptech.glide:compiler:4.0.0-RC0"
    compile ("com.github.bumptech.glide:okhttp3-integration:1.5.0@aar") {
        exclude group: 'glide-parent'
    }
    compile "com.squareup.okhttp3:okhttp:3.8.0"

In my Activity-

Glide.with(getApplicationContext())
                    .asBitmap()
                    .load(toolbar)
                    .into(new SimpleTarget<Bitmap>() {
                        @Override
                        public void onResourceReady(Bitmap resource, Transition<? super Bitmap> transition) {
                            Drawable drawable = new BitmapDrawable(getResources(), resource);
                            header.setBackground(drawable);
                        }
                    });
java.lang.AbstractMethodError: abstract method "void com.bumptech.glide.module.RegistersComponents.registerComponents(android.content.Context, com.bumptech.glide.Registry)"
                                                                           at com.bumptech.glide.Glide.initGlide(Glide.java:217)
                                                                           at com.bumptech.glide.Glide.get(Glide.java:154)
                                                                           at com.bumptech.glide.Glide.getRetriever(Glide.java:513)
                                                                           at com.bumptech.glide.Glide.with(Glide.java:539)
                                                                           at com.myapp.www.utils.common.ToolbarActivity.init(ToolbarActivity.java:38)
                                                                           at com.myapp.www.utils.common.FooterActivity.init(FooterActivity.java:24)
                                                                           at com.myapp.www.modules.home.HomeActivity.onCreate(HomeActivity.java:41)
                                                                           at android.app.Activity.performCreate(Activity.java:6664)
                                                                           at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1118)
                                                                           at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2599)
                                                                           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
                                                                           at android.app.ActivityThread.-wrap12(ActivityThread.java)
                                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
                                                                           at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                           at android.os.Looper.loop(Looper.java:154)
                                                                           at android.app.ActivityThread.main(ActivityThread.java:6077)
                                                                           at java.lang.reflect.Method.invoke(Native Method)
                                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)

@sjudd
Copy link
Collaborator

sjudd commented Jun 20, 2017

@jimitpatel do you have a GlideModule listed somewhere in your AndroidManifest.xml?

@jimitpatel
Copy link

@sjudd
No I haven't listed anything about Glide in Manifest. But I just added an empty class after reading from this link: http://sjudd.github.io/glide/doc/generatedapi.html

The class is as follows -

@GlideModule
public class CustomAppGlideModule extends AppGlideModule {
}

After this I have changed the word Glide to GlideApp but result is same

@TWiStErRob
Copy link
Collaborator

OkHttp3 integration shouldn't be 1.5.0, that's for 3.8.0.

@TWiStErRob
Copy link
Collaborator

That gets merged into your manifest (see build directory for merged manifest).
Change to 2.0.0-RC0 iirc

@jimitpatel
Copy link

@TWiStErRob I am not sure what you trying to say. Is that you want me to change version of com.github.bumptech.glide:okhttp3-integration: or you want me to change version of com.squareup.okhttp3:okhttp:

I am new to Glide, in fact today is the first day I started using it. So can you please provide more detail of what shall I do?

@MFlisar
Copy link

MFlisar commented Jun 20, 2017

To make it clear, following will currently work:

compile 'com.squareup.okhttp3:okhttp:3.8.1'
compile 'com.github.bumptech.glide:okhttp3-integration:4.0.0-RC0@aar'
compile 'com.github.bumptech.glide:glide:4.0.0-RC0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.0.0-RC0'

@TWiStErRob
Copy link
Collaborator

@jimitpatel sorry, hasty texting while walking, thanks @MFlisar

@mhdtouban
Copy link

getting same error on glide version 4.1.1
java.lang.AbstractMethodError: abstract method "void com.bumptech.glide.module.RegistersComponents.registerComponents(android.content.Context, com.bumptech.glide.Glide, com.bumptech.glide.Registry)"
at com.bumptech.glide.Glide.initializeGlide(Glide.java:231)

@TWiStErRob
Copy link
Collaborator

@mhdtouban can you please show your version of the libs that @MFlisar listed? from your grade file or gradlew dependencies.

@mhdtouban
Copy link

mhdtouban commented Sep 7, 2017

@TWiStErRob here you go
implementation 'com.squareup.okhttp3:okhttp:3.8.1'
implementation 'com.github.bumptech.glide:okhttp3-integration:4.1.1'
implementation 'com.github.bumptech.glide:glide:4.1.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.1.1'

@Pei116
Copy link

Pei116 commented Sep 20, 2017

Hey guys, why don't you update the documentation? There's still an old code snippet there.

@sjudd
Copy link
Collaborator

sjudd commented Sep 20, 2017

@Pei116 Mind pointing out what part of the document you're referring to?

@Pei116
Copy link

Pei116 commented Sep 20, 2017

@sjudd I have to spend minutes to find out this latest code to integrate with OkHttp.

    implementation 'com.github.bumptech.glide:okhttp3-integration:4.1.1@aar'
    implementation 'com.github.bumptech.glide:glide:4.1.1'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.1.1'

There's stupid code snippets titled 'OkHttp' and 'OkHttp 3' in your documentation.

@TWiStErRob
Copy link
Collaborator

@Pei116 which page are you talking about?

@SagarLimbani
Copy link

SagarLimbani commented Sep 21, 2017

@TWiStErRob gettting some error in glide v4.1.1

java.lang.AbstractMethodError: abstract method "void com.bumptech.glide.module.RegistersComponents.registerComponents(android.content.Context, com.bumptech.glide.Glide, com.bumptech.glide.Registry)"
at com.bumptech.glide.Glide.initializeGlide(Glide.java:231)

Gradle :

    implementation 'com.squareup.okhttp3:okhttp:3.9.0'
    implementation 'com.github.bumptech.glide:glide:4.1.1'
    implementation 'com.github.bumptech.glide:okhttp3-integration:4.1.1@aar'
    annotationProcessor 'com.github.bumptech.glide:compiler:4.1.1'

@talosdev
Copy link

talosdev commented Oct 3, 2017

Check your transitive dependencies.
I was getting the same error with 4.1.1 because of another library I was including, that depended on glide 3.7.0.
I had to go back to using 3.7.0 (couldn't resolve it by excluding the 3.7.0 in the other library, since the modules api has changed a lot)

@stale
Copy link

stale bot commented Nov 11, 2017

This issue has been automatically marked as stale because it has not had activity in the last seven days. It will be closed if no further activity occurs within the next seven days. Thank you for your contributions.

@damien5314
Copy link

FYI the documentation to which everyone's referring as being out-of-date is located here:

https://github.com/bumptech/glide/wiki/Integration-Libraries#okhttp-3-with-gradle

But the 4.1.1 version of the integration library seems to work for me. Thanks!

@a1265137718
Copy link

add "@GlideModule"

@GlideModule
public class MyGlideMoudle extends AppGlideModule {
...
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests