I have been using TedBottomPicker
library for picking image from camera and gallery. Also am using Glide
in my project. Recently i have updated Glide
library to latest version and TedBottomPicker
library also. Now i am facing problem while am calling the accessing the camera or gallery using the TedBottomPicker
library.
FATAL EXCEPTION: main
Process: com.fooddoof.fuddict, PID: 2284 java.lang.NoSuchMethodError: No virtual method load(Landroid/net/Uri;)Lcom/bumptech/glide/DrawableTypeRequest; in class Lcom/bumptech/glide/RequestManager; or its super classes (declaration of 'com.bumptech.glide.RequestManager' appears in /data/app/com.fooddoof.fuddict-1/split_lib_dependencies_apk.apk) at gun0912.tedbottompicker.adapter.GalleryAdapter.onBindViewHolder(GalleryAdapter.java:163) at gun0912.tedbottompicker.adapter.GalleryAdapter.onBindViewHolder(GalleryAdapter.java:32) at android.support.v7.widget.RecyclerView$Adapter.onBindViewHolder(RecyclerView.java:6508) at android.support.v7.widget.RecyclerView$Adapter.bindViewHolder(RecyclerView.java:6541) at android.support.v7.widget.RecyclerView$Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5484) at android.support.v7.widget.RecyclerView$Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5750) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5589) at android.support.v7.widget.RecyclerView$Recycler.getViewForPosition(RecyclerView.java:5585) at android.support.v7.widget.LinearLayoutManager$LayoutState.next(LinearLayoutManager.java:2231) at android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:556) at android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1518) at android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:610) at android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170) at android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3719) at android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3135) at android.view.View.measure(View.java:19734) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464) at android.widget.LinearLayout.measureVertical(LinearLayout.java:758) at android.widget.LinearLayout.onMeasure(LinearLayout.java:640) at android.view.View.measure(View.java:19734) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:19734) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:719) at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:791) at android.view.View.measure(View.java:19734) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:19734) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139) at android.view.View.measure(View.java:19734) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:19734) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at android.view.View.measure(View.java:19734) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464) at android.widget.LinearLayout.measureVertical(LinearLayout.java:758) at android.widget.LinearLayout.onMeasure(LinearLayout.java:640) at android.view.View.measure(View.java:19734) at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) at android.widget.FrameLayout.onMeasure(FrameLayout.java:185) at com.android.internal.policy.DecorView.onMeasure(DecorView.java:687)
12-14 09:52:42.908 2284-2284/com.fooddoof.fuddict E/AndroidRuntime:
at android.view.View.measure(View.java:19734) at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2271) at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1358) at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1607) at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1246) at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6301) at android.view.Choreographer$CallbackRecord.run(Choreographer.java:871) at android.view.Choreographer.doCallbacks(Choreographer.java:683) at android.view.Choreographer.doFrame(Choreographer.java:619) at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:857) at android.os.Handler.handleCallback(Handler.java:751) at android.os.Handler.dispatchMessage(Handler.java:95) 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:866) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
The above exception is shown in logcat. I have tried with other different library also but this error is seen.
my dependencies
dependencies {
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:appcompat-v7:27.0.2'
compile 'com.android.volley:volley:1.0.0'
compile 'gun0912.ted:tedbottompicker:1.1.0'
compile 'com.github.bumptech.glide:glide:4.4.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.4.0'
compile 'com.github.chrisbanes:PhotoView:2.0.0'
compile 'de.hdodenhof:circleimageview:2.2.0'
compile 'uk.co.chrisjenx:calligraphy:2.3.0'
compile 'com.android.support:multidex:1.0.2'
compile 'gun0912.ted:tedpermission:2.1.0'
compile 'com.android.support:recyclerview-v7:27.0.2'
}
Accessing library
PermissionListener permissionlistener1 = new PermissionListener() {
@Override
public void onPermissionGranted() {
TedBottomPicker tedBottomPicker = new TedBottomPicker.Builder(PostActivity.this)
.setOnImageSelectedListener(new TedBottomPicker.OnImageSelectedListener() {
@Override
public void onImageSelected(Uri uri) {
// here is selected uri
}
})
.create();
tedBottomPicker.show(getSupportFragmentManager());
}
@Override
public void onPermissionDenied(ArrayList<String> deniedPermissions) {
Toast.makeText(PostActivity.this, "Permission Denied\n" + deniedPermissions.toString(), Toast.LENGTH_SHORT).show();
}
};
Gallery Adapter.java
public class GalleryAdapter extends RecyclerView.Adapter<GalleryAdapter.MyViewHolder> {
private ArrayList<descusers> images;
private Context mContext;
public class MyViewHolder extends RecyclerView.ViewHolder {
public ImageView thumbnail;
public MyViewHolder(View view) {
super(view);
thumbnail = view.findViewById(R.id.thumbnail);
}
}
public GalleryAdapter(Context context, ArrayList<descusers> images) {
mContext = context;
this.images = images;
}
@Override
public GalleryAdapter.MyViewHolder onCreateViewHolder(ViewGroup parent, int viewType) {
View itemView = LayoutInflater.from(parent.getContext())
.inflate(R.layout.gallery_thumbnail, parent, false);
return new MyViewHolder(itemView);
}
@Override
public void onBindViewHolder(GalleryAdapter.MyViewHolder holder, int position) {
descusers image = images.get(position);
Glide.with(mContext).load(image.getimage())
.into(holder.thumbnail);
}
@Override
public int getItemCount() {
return images.size();
}
public interface ClickListener {
void onClick(View view, int position);
void onLongClick(View view, int position);
}
public static class RecyclerTouchListener implements RecyclerView.OnItemTouchListener {
private GestureDetector gestureDetector;
private GalleryAdapter.ClickListener clickListener;
public RecyclerTouchListener(Context context, final RecyclerView recyclerView, final GalleryAdapter.ClickListener clickListener) {
this.clickListener = clickListener;
gestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
@Override
public boolean onSingleTapUp(MotionEvent e) {
return true;
}
@Override
public void onLongPress(MotionEvent e) {
View child = recyclerView.findChildViewUnder(e.getX(), e.getY());
if (child != null && clickListener != null) {
clickListener.onLongClick(child, recyclerView.getChildAdapterPosition(child));
}
}
});
}
@Override
public boolean onInterceptTouchEvent(RecyclerView rv, MotionEvent e) {
View child = rv.findChildViewUnder(e.getX(), e.getY());
if (child != null && clickListener != null && gestureDetector.onTouchEvent(e)) {
clickListener.onClick(child, rv.getChildAdapterPosition(child));
}
return false;
}
@Override
public void onTouchEvent(RecyclerView rv, MotionEvent e) {
}
@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {
}
}
}
I understand what the error is. The library TedBottomPicker taht you are using uses glide version 3.6.1. But you use v4 of glide. This leads to error as both cannot be used at the same time. You have these options now:
Hope this helps.
new Glide4Engine()
instead of new GlideEngine()
Matisse.from(ChatActivity.this)
.choose(MimeType.ofAll(), false)
.countable(true)
.maxSelectable(MAX_SELECTABLE)
.restrictOrientation(ActivityInfo.SCREEN_ORIENTATION_UNSPECIFIED)
.thumbnailScale(0.85f)
.imageEngine(new Glide4Engine()) // for Glide V4
.maxOriginalSize(10)
// .imageEngine(new GlideEngine()) // for Glide V3
.forResult(PICK_GALLERY_REQUEST);
public class Glide4Engine implements ImageEngine {
@Override
public void loadThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView, Uri uri) {
Glide.with(context)
.asBitmap() // some .jpeg files are actually gif
.load(uri)
.apply(new RequestOptions()
.override(resize, resize)
.placeholder(placeholder)
.centerCrop())
.into(imageView);
}
@Override
public void loadGifThumbnail(Context context, int resize, Drawable placeholder, ImageView imageView,
Uri uri) {
Glide.with(context)
.asBitmap() // some .jpeg files are actually gif
.load(uri)
.apply(new RequestOptions()
.override(resize, resize)
.placeholder(placeholder)
.centerCrop())
.into(imageView);
}
@Override
public void loadImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) {
Glide.with(context)
.load(uri)
.apply(new RequestOptions()
.override(resizeX, resizeY)
.priority(Priority.HIGH)
.fitCenter())
.into(imageView);
}
@Override
public void loadGifImage(Context context, int resizeX, int resizeY, ImageView imageView, Uri uri) {
Glide.with(context)
.asGif()
.load(uri)
.apply(new RequestOptions()
.override(resizeX, resizeY)
.priority(Priority.HIGH)
.fitCenter())
.into(imageView);
}
@Override
public boolean supportAnimatedGif() {
return true;
}
}
I also facing this issue but i solved this using latest version of glide
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With