twoway-view icon indicating copy to clipboard operation
twoway-view copied to clipboard

Support Library 23.2.0, java.lang.IncompatibleClassChangeError: org.lucasr.twowayview.ClickItemTouchListener$ItemClickGestureDetector

Open jmodrako opened this issue 9 years ago • 27 comments

After upgrading support library to 23.2 this issue occured:

java.lang.IncompatibleClassChangeError: org.lucasr.twowayview.ClickItemTouchListener$ItemClickGestureDetector at org.lucasr.twowayview.ClickItemTouchListener.(ClickItemTouchListener.java:19) at org.lucasr.twowayview.ItemClickSupport$TouchListener.(ItemClickSupport.java:115) at org.lucasr.twowayview.ItemClickSupport.(ItemClickSupport.java:54) at org.lucasr.twowayview.ItemClickSupport.addTo(ItemClickSupport.java:85)

jmodrako avatar Feb 25 '16 09:02 jmodrako

Same thing here.

Spotik avatar Feb 25 '16 17:02 Spotik

I cannot find the solution of that problem, please help

ekinguvencoglu avatar Feb 25 '16 17:02 ekinguvencoglu

Same thing here. That happens because with support-v4:23.2.0 GestureDetectorCompat became final

fondesa avatar Feb 26 '16 08:02 fondesa

me too~

hehuelet avatar Feb 26 '16 09:02 hehuelet

is there any solution about that?

ekinguvencoglu avatar Feb 28 '16 10:02 ekinguvencoglu

Same issue but I am not using Support Library 23.2.0 even then I am getting those errors

rajeevjaiswal avatar Mar 03 '16 14:03 rajeevjaiswal

Also getting this issue - is there a work-around? Thanks!

SeanGallahad avatar Mar 03 '16 15:03 SeanGallahad

@rajeevjaiswal for my case, facebook SDK 'secretly' pulled the version to 23.2.0 even though I have the line:

compile 'com.android.support:support-v4:23.1.1' 

I need to explicitly exclude the dependency like this to get back 23.1.1:

    compile ('com.facebook.android:facebook-android-sdk:4.10.0'){
        // Avoid pulling to latest 23.2.0
        // https://code.google.com/p/android/issues/detail?id=72430
        exclude group: 'com.android.support', module:'support-v4'
        exclude group: 'com.android.support', module:'cardview-v7'
    }

To make sure your dependencies are not force upgraded, run the following command in the terminal ./gradlew app:dependencies

And look for 23.2.0

lemoncola avatar Mar 04 '16 04:03 lemoncola

Thanks I will look into it On 04-Mar-2016 9:44 am, "LemonCola" [email protected] wrote:

@rajeevjaiswal https://github.com/rajeevjaiswal for my case, facebook SDK 'secretly' pulled the version to 23.2.0 even though I have the line:

compile 'com.android.support:support-v4:23.1.1'

I need to explicitly exclude the dependency like this to get back 23.1.1:

compile ('com.facebook.android:facebook-android-sdk:4.10.0'){
    // Avoid pulling to latest 23.2.0
    // https://code.google.com/p/android/issues/detail?id=72430
    exclude group: 'com.android.support', module:'support-v4'
    exclude group: 'com.android.support', module:'cardview-v7'
}

To make sure your dependencies are not force upgraded, run the following command in the terminal

./gradlew app:dependencies

And look for 23.2.0

— Reply to this email directly or view it on GitHub https://github.com/lucasr/twoway-view/issues/266#issuecomment-192091192.

rajeevjaiswal avatar Mar 04 '16 04:03 rajeevjaiswal

@lemoncola I modified the code but still it is crashing

rajeevjaiswal avatar Mar 04 '16 07:03 rajeevjaiswal

@lemoncola thanks a lot, you save my day

ekinguvencoglu avatar Mar 04 '16 09:03 ekinguvencoglu

@lemoncola still with problem =/

Spotik avatar Mar 05 '16 17:03 Spotik

@Spotik hi, I found many other 3rd party and some offical libraries still demand to use 23.2 support library, did you check that with ./gradlew app:dependencies command?

ekinguvencoglu avatar Mar 05 '16 17:03 ekinguvencoglu

@ekinguvencoglu which folder should I run the command?

Spotik avatar Mar 05 '16 18:03 Spotik

@Spotik it can be run in terminal window at Android Studio

ekinguvencoglu avatar Mar 05 '16 18:03 ekinguvencoglu

@ekinguvencoglu i got the msg: "is not recognized as an internal or external command operable program or batch file"

On android studio terminal, the patch is "C:\Users\myuser\Projetos Android\my-project>"

Spotik avatar Mar 06 '16 00:03 Spotik

@Spotik do you set the gradle path to your os?

ekinguvencoglu avatar Mar 07 '16 09:03 ekinguvencoglu

@ekinguvencoglu hmmm i dont think so... how I do that? And thks for helping!

Spotik avatar Mar 07 '16 14:03 Spotik

Thanks @ekinguvencoglu for helping~ @Spotik let's try the GUI way~

  1. Open Gradle Panel (View > Tool Windows > Gradle) screen shot 2016-03-09 at 12 47 57 am

  2. Click the 'Execute Gradle Task' button in the toolbar of the Gradle Panel screen shot 2016-03-09 at 12 48 34 am

  3. In the dialog, fill in "Command Line" with "app:dependencies" screen shot 2016-03-09 at 12 49 09 am

  4. Then in the Gradle output, you should see a module dependency tree. Search or scroll down to make sure your support lib is not upgraded due to requirements by some 3rd-party library. screen shot 2016-03-09 at 12 49 36 am

lemoncola avatar Mar 08 '16 16:03 lemoncola

@lemoncola it's also very helpful explanation for me, thanks

ekinguvencoglu avatar Mar 08 '16 20:03 ekinguvencoglu

same error but ii will try above solution still wanted to ask is there any other solution we can use with latest version of support library with this library.Is it possible without changing to compile 'com.android.support:support-v4:23.1.1'

anantshah93 avatar Apr 12 '16 07:04 anantshah93

I'm also facing this issue... whats the proper solution to this?

MustafaAdil avatar May 16 '16 13:05 MustafaAdil

I will have to remove this library, because the auther doesnt upgrade it anymore.

simonwzb avatar Jul 11 '16 03:07 simonwzb

what about adding a click listener to a cell view inside adapter?

@Override
    public void onBindViewHolder(SimpleViewHolder holder, final int position) {
        ....
        itemView.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                mOnClickListener.onClick(v, position);
            }
        });

and then

  mRecyclerView.setAdapter(new GridAdapter(getActivity(), items, new GridAdapter.GridAdapterListener() {
            @Override
            public void onClick(View v, int position) {
                Toast.makeText(getActivity(), String.valueOf(items.get(position).getId()), Toast.LENGTH_SHORT).show();
            }
        }));

pvllnspk avatar Jul 29 '16 09:07 pvllnspk

Hi i face the same problem too, just use this class to solve the issue https://gist.github.com/nesquena/231e356f372f214c4fe6

seerazz avatar Aug 11 '16 03:08 seerazz

I fixed this issue by adding a separate on item click listener to it like,

           mRecyclerView.addOnItemTouchListener(
            new RecyclerItemClickListener(getApplicationContext(), new  RecyclerItemClickListener.OnItemClickListener() {
                @Override
                public void onItemClick(View view, int position) {

                    Toast.makeText(getApplicationContext(), "selected " + textColorList.get(position), Toast.LENGTH_SHORT).show();

                }
            })
    );

` RecyclerItemClickListener.java

 import android.content.Context;
 import android.support.v7.widget.RecyclerView;
 import android.view.GestureDetector;
 import android.view.MotionEvent;
 import android.view.View;

 public class RecyclerItemClickListener implements RecyclerView.OnItemTouchListener {
 private OnItemClickListener mListener;

 public interface OnItemClickListener {
    public void onItemClick(View view, int position);
 }



GestureDetector mGestureDetector;

public RecyclerItemClickListener(Context context, OnItemClickListener listener) {
    mListener = listener;
    mGestureDetector = new GestureDetector(context, new GestureDetector.SimpleOnGestureListener() {
        @Override
        public boolean onSingleTapUp(MotionEvent e) {
            return true;
        }


    });
}

@Override
public boolean onInterceptTouchEvent(RecyclerView view, MotionEvent e) {
    View childView = view.findChildViewUnder(e.getX(), e.getY());
    if (childView != null && mListener != null && mGestureDetector.onTouchEvent(e)) {
        mListener.onItemClick(childView, view.getChildAdapterPosition(childView));
    }
    return false;
}

@Override
public void onTouchEvent(RecyclerView view, MotionEvent motionEvent) {
}

@Override
public void onRequestDisallowInterceptTouchEvent(boolean disallowIntercept) {

}

}`

jayakrishnan-pm avatar Dec 03 '16 14:12 jayakrishnan-pm

mGestureDetector = new ItemClickGestureDetector(hostView.getContext(), new ItemClickGestureListener(hostView));

I solved the problem by change the ItemClickGestureDetector to GestureDetectorCompat

mGestureDetector = new GestureDetectorCompat(hostView.getContext(), new ItemClickGestureListener(hostView));

jiulian avatar Oct 17 '17 08:10 jiulian