lucasr / twoway-view

[DEPRECATED] RecyclerView made simple
5.23k stars 1.02k forks source link

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

Open jmodrako opened 8 years ago

jmodrako commented 8 years ago

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)

Spotik commented 8 years ago

Same thing here.

ekinguvencoglu commented 8 years ago

I cannot find the solution of that problem, please help

fondesa commented 8 years ago

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

hehuelet commented 8 years ago

me too~

ekinguvencoglu commented 8 years ago

is there any solution about that?

rajeevjaiswal commented 8 years ago

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

SeanGallahad commented 8 years ago

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

lemoncola commented 8 years ago

@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

rajeevjaiswal commented 8 years ago

Thanks I will look into it On 04-Mar-2016 9:44 am, "LemonCola" notifications@github.com 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 commented 8 years ago

@lemoncola I modified the code but still it is crashing

ekinguvencoglu commented 8 years ago

@lemoncola thanks a lot, you save my day

Spotik commented 8 years ago

@lemoncola still with problem =/

ekinguvencoglu commented 8 years ago

@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?

Spotik commented 8 years ago

@ekinguvencoglu which folder should I run the command?

ekinguvencoglu commented 8 years ago

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

Spotik commented 8 years ago

@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>"

ekinguvencoglu commented 8 years ago

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

Spotik commented 8 years ago

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

lemoncola commented 8 years ago

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

ekinguvencoglu commented 8 years ago

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

anantshah93 commented 8 years ago

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'

MustafaAdil commented 8 years ago

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

simonwzb commented 8 years ago

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

pvllnspk commented 7 years ago

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();
            }
        }));
seerazz commented 7 years ago

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

jayakrishnan-pm commented 7 years ago

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) {

}

}`

jiulian commented 6 years ago

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));