カメラおよびギャラリーから画像を選択するためにTedBottomPicker
ライブラリを使用しています。また、私のプロジェクトではGlide
を使用しています。最近、Glide
ライブラリを最新バージョンに更新しました。TedBottomPicker
ライブラリも更新しました。 TedBottomPicker
ライブラリを使用してカメラまたはギャラリーへのアクセスを呼び出しているときに問題が発生しました。
致命的な例外:メイン
プロセス:com.fooddoof.fuddict、PID:2284 Java.lang.NoSuchMethodError:仮想メソッドのロードがありません(Landroid/net/Uri;)Lcom /バンプテック/グライド/ DrawableTypeRequest;クラスLcom /バンプテック/グライド/リクエストマネージャー;またはそのスーパークラス(「com.bumptech.glide.RequestManager」の宣言は/data/app/com.fooddoof.fuddict-1/split_lib_dependencies_apk.apkに表示されます)(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.tryGetViewHolderForPositionByDe :5750)Android.support.v7.widget.RecyclerView $ Recycler.getViewForPosition(RecyclerView.Java:5589)at Android.support.v7.widget.RecyclerView $ Recycler.getViewForPosition(RecyclerView.Java:5585)atAndroid.support。 v7.widget.LinearLayoutManager $ LayoutState.next(LinearLayoutManage r.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) Android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.Java:1464)at Android.widget.LinearLayout.measureVertical(LinearLayout.Java:758)at Android.widget.LinearLayout.onMeasure(LinearLayout.Java:640)atAndroid.view。 Android.widgetのAndroid.view.ViewGroup.measureChildWithMargins(ViewGroup.Java:6120)のView.measure(View.Java:19734) .FrameLayout.onMeasure(FrameLayout.Java:185)at Android.view.View.measure(View.Java:19734)at Android.view.ViewGroup.measureChildWithMargins(ViewGroup.Java:6120)atAndroid.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(Vi ew.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) 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)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 $ MethodAndA com.Android.internal.os.ZygoteInit.main(ZygoteInit.Java:756)のrgsCaller.run(ZygoteInit.Java:866)
上記の例外は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) {
}
}
}
エラーが何であるかを理解しています。使用しているライブラリTedBottomPicker tahtはglideバージョン3.6.1を使用しています。ただし、glideのv4を使用します。両方を同時に使用することはできないため、これはエラーにつながります。現在、次のオプションがあります。
お役に立てれば。
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;
}
}
私もこの問題に直面していますが、最新バージョンのグライドを使用してこれを解決しました
implementation 'com.github.bumptech.glide:glide:4.9.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.9.0'