Android Question java.lang.NoClassDefFoundError ...MotionEventCompat;(SOLVED)

iCAB

Well-Known Member
Licensed User
Longtime User
Hi All,

I am getting this error now. It happens whenever I click a SlideSwitch.

java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/v4/view/MotionEventCompat;

I believe it is related to upgrading to B4A 10.2 and/or the android_sdk

Last actions:
  1. re-installed B4A 10.2
  2. fresh install of android SDK manager
  3. deleted appcompat from internal libraries folders
  4. downloaded appcompat 4.0 and unzipped in internal folder.

I am also attaching the full error log.

Can someone help please.

Thanks,
ICAB
 

Attachments

  • ErrorLog.txt
    4.1 KB · Views: 1,624

DonManfred

Expert
Licensed User
Longtime User
deleted appcompat from internal libraries folders
WHY? NO single reason to delete any of the internal libbraries.

Where does the dependency of android/support/v4/view/MotionEventCompat come from?
Try to change the dependency to the matching AndroidX Artifact.
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
Thanks Don for your reply

WHY? NO single reason to delete any of the internal libbraries.

I was reading this thread: https://www.b4x.com/android/forum/t...-view-viewconfigurationcompat.117655/#content, in post #13 Erel suggested to delete the internal appcompat and install the latest one, so I tried it just in case. It didn't make a difference. I can restore the old one if needed.

Where does the dependency of android/support/v4/view/MotionEventCompat come from?
Try to change the dependency to the matching AndroidX Artifact.
I have no idea, to be honest with you. All what I know is that this code was working for years as is. I am not sure at which point this started happening.
Also I am not sure if it makes any difference, but it is worth mentioning that the SlideSwitch was added using code and the the designer.

Other posts suggested to run Jetify, which I did as well,

Any ideas?

Thanks,
iCAB
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
I have followed the instructions several times and installed B4A from scratch on multiple stations.
Some of the libraries that we are using require updating some of the packages in the SDK Manager, and therefore after completing the instructions I find that I still have to run the SDK manager GUI and install the recommended updates.
Is there anything that I can try without having to uninstall and re-install everything?
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
Hi Erel

You need to run the jetifier tool. SlideSwitch is based on the old Android Support library.
Sorry I forgot to mention that I already did that

Why aren't you using the nicer, cross platform B4XSwitch view?
Up until this incident, the code is working good for me, as I can control the slideswitch a bit more, in terms of size & color.

I would like to have this issue resolved somehow as I hate to change the current layout, and the exact same code is used in several apps.

Please let me know what else I can try.

Thanks,
iCAB
 
Upvote 0

iCAB

Well-Known Member
Licensed User
Longtime User
It's working after moving the SlideSwitch library to the additional libraries folder and running jetifier.

Thanks for the exceptional support. You're the best.
iCAB
 
Upvote 0
Top