我一直在使用TedBottomPicker
库从相机和图库中挑选图片。我也在我的项目中使用Glide
。最近我将Glide
库更新到最新版本和TedBottomPicker
库。现在,我正在使用TedBottomPicker
库调用访问摄像头或图库时遇到问题。
致命例外:主要 过程:com.fooddoof.fuddict,PID:2284 java.lang.NoSuchMethodError:没有虚方法 负载(Landroid /净/ URI)LCOM / bumptech /滑行/ DrawableTypeRequest;在 class Lcom / bumptech / glide / RequestManager;或者它的超级课程 (声明' com.bumptech.glide.RequestManager'出现在 /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) 在android.support.v7.widget.RecyclerView $ Adapter.onBindViewHolder(RecyclerView.java:6508) 在android.support.v7.widget.RecyclerView $ Adapter.bindViewHolder(RecyclerView.java:6541) 在android.support.v7.widget.RecyclerView $ Recycler.tryBindViewHolderByDeadline(RecyclerView.java:5484) 在android.support.v7.widget.RecyclerView $ Recycler.tryGetViewHolderForPositionByDeadline(RecyclerView.java:5750) 在android.support.v7.widget.RecyclerView $ Recycler.getViewForPosition(RecyclerView.java:5589) 在android.support.v7.widget.RecyclerView $ Recycler.getViewForPosition(RecyclerView.java:5585) 在android.support.v7.widget.LinearLayoutManager $ LayoutState.next(LinearLayoutManager.java:2231) 在android.support.v7.widget.GridLayoutManager.layoutChunk(GridLayoutManager.java:556) 在android.support.v7.widget.LinearLayoutManager.fill(LinearLayoutManager.java:1518) 在android.support.v7.widget.LinearLayoutManager.onLayoutChildren(LinearLayoutManager.java:610) 在android.support.v7.widget.GridLayoutManager.onLayoutChildren(GridLayoutManager.java:170) 在android.support.v7.widget.RecyclerView.dispatchLayoutStep2(RecyclerView.java:3719) 在android.support.v7.widget.RecyclerView.onMeasure(RecyclerView.java:3135) 在android.view.View.measure(View.java:19734) 在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) 在android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464) 在android.widget.LinearLayout.measureVertical(LinearLayout.java:758) 在android.widget.LinearLayout.onMeasure(LinearLayout.java:640) 在android.view.View.measure(View.java:19734) 在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) 在android.widget.FrameLayout.onMeasure(FrameLayout.java:185) 在android.view.View.measure(View.java:19734) 在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) 在android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:719) 在android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:791) 在android.view.View.measure(View.java:19734) 在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) 在android.widget.FrameLayout.onMeasure(FrameLayout.java:185) 在android.view.View.measure(View.java:19734) 在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) 在android.widget.FrameLayout.onMeasure(FrameLayout.java:185) 在android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139) 在android.view.View.measure(View.java:19734) 在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) 在android.widget.FrameLayout.onMeasure(FrameLayout.java:185) 在android.view.View.measure(View.java:19734) 在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) 在android.widget.FrameLayout.onMeasure(FrameLayout.java:185) 在android.view.View.measure(View.java:19734) 在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) 在android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1464) 在android.widget.LinearLayout.measureVertical(LinearLayout.java:758) 在android.widget.LinearLayout.onMeasure(LinearLayout.java:640) 在android.view.View.measure(View.java:19734) 在android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6120) 在android.widget.FrameLayout.onMeasure(FrameLayout.java:185) 在com.android.internal.policy.DecorView.onMeasure(DecorView.java:687)
12-14 09:52:42.908 2284-2284 / com.fooddoof.fuddict E / AndroidRuntime:
在android.view.View.measure(View.java:19734) 在android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2271) 在android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1358) 在android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1607) 在android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1246) 在android.view.ViewRootImpl $ TraversalRunnable.run(ViewRootImpl.java:6301) 在android.view.Choreographer $ CallbackRecord.run(Choreographer.java:871) 在android.view.Choreographer.doCallbacks(Choreographer.java:683) 在android.view.Choreographer.doFrame(Choreographer.java:619) 在android.view.Choreographer $ FrameDisplayEventReceiver.run(Choreographer.java:857) 在android.os.Handler.handleCallback(Handler.java:751) 在android.os.Handler.dispatchMessage(Handler.java:95) 在android.os.Looper.loop(Looper.java:154) 在android.app.ActivityThread.main(ActivityThread.java:6077) at java.lang.reflect.Method.invoke(Native Method) 在com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:866) 在com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)
上面的异常显示在logcat中。我也试过了其他不同的库,但是看到了这个错误。
我的依赖
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'
}
访问图书馆
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) {
}
}
}
答案 0 :(得分:3)
我明白错误是什么。您正在使用的库 TedBottomPicker 使用滑动版本3.6.1。但是你使用v4滑行。这导致错误,因为两者不能同时使用。你现在有这些选择:
希望这有帮助。
答案 1 :(得分:0)
new Glide4Engine()
代替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;
}
}
答案 2 :(得分:0)
我也面临这个问题,但是我使用最新版本的glide解决了这个问题
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'
答案 3 :(得分:0)
升级到最新版本的 Glide 以解决问题。
简单来说,您当前使用的TedBottomPicker版本,需要相应版本的glide才能正常工作,但是您当前的glide版本基本不能满足要求,因此报错。