Materialdrawer: Error with internet url in withIcon() function

Created on 5 Apr 2015  ·  11Comments  ·  Source: mikepenz/MaterialDrawer

Url valid.
In avatar area shown default image.

Offline mode turned off.

dependency:

compile('com.mikepenz.materialdrawer:library:2.7.0@aar') {
        transitive = true
    }

Code:

String userPic = "http://......."
IProfile profile = new ProfileDrawerItem().withName("Mike Penz").withEmail("[email protected]").withIcon(userPic);

headerResult = new AccountHeader()
                .withActivity(this)
                .withHeaderBackground(R.drawable.user_bg_light)
                .addProfiles(profile)
                .withOnAccountHeaderListener(new AccountHeader.OnAccountHeaderListener() {
                    @Override
                    public boolean onProfileChanged(View view, IProfile profile, boolean currentProfile) {
                        return false;
                    }
                })
                .build();

logcat:

Could not find class 'com.mikepenz.materialdrawer.view.BezelImageView$CustomOutline', referenced from method com.mikepenz.materialdrawer.view.BezelImageView.onSizeChanged
W/dalvikvm﹕ VFY: unable to resolve new-instance 2793 (Lcom/mikepenz/materialdrawer/view/BezelImageView$CustomOutline;) in Lcom/mikepenz/materialdrawer/view/BezelImageView;
D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x0006
W/dalvikvm﹕ Unable to resolve superclass of Lcom/mikepenz/materialdrawer/view/BezelImageView$CustomOutline; (1580)
W/dalvikvm﹕ Link of class 'Lcom/mikepenz/materialdrawer/view/BezelImageView$CustomOutline;' failed
D/dalvikvm﹕ DexOpt: unable to opt direct call 0x62f4 at 0x08 in Lcom/mikepenz/materialdrawer/view/BezelImageView;.onSizeChanged
I/dalvikvm﹕ Could not find method android.content.res.Resources.getDrawable, referenced from method com.mikepenz.materialdrawer.util.UIUtils.getCompatDrawable
W/dalvikvm﹕ VFY: unable to resolve virtual method 478: Landroid/content/res/Resources;.getDrawable (ILandroid/content/res/Resources$Theme;)Landroid/graphics/drawable/Drawable;
D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0018
D/dalvikvm﹕ GC_FOR_ALLOC freed 209K, 3% free 11123K/11463K, paused 57ms, total 59ms
I/dalvikvm-heap﹕ Grow heap (frag case) to 11.221MB for 298012-byte allocation
D/dalvikvm﹕ GC_FOR_ALLOC freed 3K, 4% free 11411K/11783K, paused 24ms, total 24ms
D/dalvikvm﹕ GC_FOR_ALLOC freed 25K, 4% free 11388K/11783K, paused 117ms, total 117ms
I/dalvikvm-heap﹕ Grow heap (frag case) to 12.332MB for 1192012-byte allocation
D/dalvikvm﹕ GC_FOR_ALLOC freed <1K, 4% free 12552K/12999K, paused 23ms, total 23ms
D/dalvikvm﹕ GC_CONCURRENT freed 0K, 4% free 12552K/12999K, paused 13ms+13ms, total 29ms
I/MaterialDrawer﹕ you have not specified a ImageLoader implementation through the DrawerImageLoader.init(IDrawerImageLoader) method
I/dalvikvm﹕ Could not find method android.support.v4.widget.DrawerLayout$LayoutParams.setMarginEnd, referenced from method com.mikepenz.materialdrawer.Drawer.processDrawerLayoutParams
W/dalvikvm﹕ VFY: unable to resolve virtual method 7419: Landroid/support/v4/widget/DrawerLayout$LayoutParams;.setMarginEnd (I)V
D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0023
I/dalvikvm﹕ Could not find method android.support.v4.widget.DrawerLayout$LayoutParams.setMarginEnd, referenced from method com.mikepenz.materialdrawer.Drawer.processDrawerLayoutParams
W/dalvikvm﹕ VFY: unable to resolve virtual method 7419: Landroid/support/v4/widget/DrawerLayout$LayoutParams;.setMarginEnd (I)V
D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0044
I/dalvikvm﹕ Could not find method android.view.Window.setStatusBarColor, referenced from method com.mikepenz.materialdrawer.Drawer.build
W/dalvikvm﹕ VFY: unable to resolve virtual method 14013: Landroid/view/Window;.setStatusBarColor (I)V
D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x0073
question

All 11 comments

@Remie-l Is that logcat from pre-Lollipop? The "could not find class" message is normal (and ignorable) if you aren't on Lollipop. See issue #166 for confirmation from Mike.

The reason your image isn't loading is because of a different line in the logcat:

I/MaterialDrawer﹕ you have not specified a ImageLoader implementation through the DrawerImageLoader.init(IDrawerImageLoader) method

You need to define the ImageLoader logic. See CustomApplication.java in the included sample app for an example. The library itself doesn't know how to handle URIs, it requires that you tell it how to retrieve the image.

@wKovacs64 thanks for your help.

@Remie-l please see @wKovacs64 's answer. You have missed the implementation how images are loaded. This has to be provided because the MaterialDrawer does not include a image loader library.

I will add a new section to the readme about this.

Thanks!

why i can't call function init on DrawerImageLoader, i try to make like CustomApplication.java, but when i call DrawerImageLoader.init() <- nothing this function. just two, IDdrawerimageloader and tags. please ur help @mikepenz

sorry for my language. im from indonesian

@PutraJuke you don't have to call init the DrawerImageLoader is just required that the MaterialDrawer has the logic in place how images are loaded. Everything is then handled behind the curtains. You just have to provide the logic, (and a library like picasso or glide) after this you just have to set a url for a profile ( not available on DrawerItems ) and it will load the image

@mikepenz how i get imageview on headerdrawer to load with Glide/Picasso ?

@PutraJuke for the background of the header just get the view from the AccountHeader and set it normally as you would do it on any other view

@mikepenz sorry, i mean the profile photo imageview not headerbackground. i want to change profile photo with load url.

this is my code on mainactivity :

.addProfiles(new ProfileDrawerItem()
                        .withName(name).withEmail(email)
                        .withIcon("URL")

i want to profile icon load image with url, is it possible ?

@mikepenz

@PutraJuke yes exactly. That's what is also done in the sample app:

In my CustomApplication I define my DrawerImageLoader and define that I want to use Glide
https://github.com/mikepenz/MaterialDrawer/blob/develop/app/src/main/java/com/mikepenz/materialdrawer/app/CustomApplication.java#L42
(In case you have not used your own Application class: https://www.mobomo.com/2011/5/how-to-use-application-object-of-android/)

And then I just provide the url for the image. Everything else is handled then:
https://github.com/mikepenz/MaterialDrawer/blob/develop/app/src/main/java/com/mikepenz/materialdrawer/app/DrawerActivity.java#L64

Whats different using uri.parse? And the others? @mikepenz . I will try later, thanks a lot.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

y2kshane picture y2kshane  ·  4Comments

pranjal-joshi picture pranjal-joshi  ·  3Comments

hosseiniSeyRo picture hosseiniSeyRo  ·  3Comments

Meeks91 picture Meeks91  ·  3Comments

Ahmed-Emad picture Ahmed-Emad  ·  4Comments