我一直在使用TedBottomPicker
库从相机和相册中选择图片。同时,在我的项目中使用了Glide
。最近,我将Glide
库更新到了最新版本并且也更新了TedBottomPicker
库。现在,当我使用TedBottomPicker
库调用并访问相机或相册时,遇到了问题。
进程:com.fooddoof.fuddict,PID:2284
java.lang.NoSuchMethodError:在类Lcom / bumptech / glide / RequestManager中没有虚拟方法load(Landroid / net / Uri;)Lcom / bumptech / glide / DrawableTypeRequest;或其超类('com.bumptech.glide.RequestManager'的声明出现在/data/app/com.fooddoof.fuddict-1/split_lib_dependencies_apk.apk中)
在gun0912.tedbottompicker.adapter.GalleryAdapter.onBindViewHolder(GalleryAdapter.java:163)处
在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.measure
上述异常在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();
}
};
相册适配器.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) {
}
}
}
RequestManager
类问题...请参考https://github.com/myinnos/AwesomeImagePicker/issues/11 - Ramesh sambu