square / otto

An enhanced Guava-based event bus with emphasis on Android support.
http://square.github.io/otto/
Apache License 2.0
5.17k stars 848 forks source link

java.lang.NoClassDefFoundError: com.squareup.otto.ThreadEnforcer #183

Closed harshgaba closed 8 years ago

harshgaba commented 8 years ago

i'm getting this issue in Bus bus=new Bus(); at runtime i'm getting java.lang.NoClassDefFoundError: com.squareup.otto.ThreadEnforcer

i installed otto as per doc on offical website. it works fine for API level above 19, but below or on API level 19 , app crashes. don't now how to fix. please resolve or assists.

X-Strange commented 8 years ago

I have the same issue, after add GCM to my app. I enabled multiDex compilation to solve 64k issue. My dependencies (fragment): compile 'com.squareup:otto:1.3.8'//Otto Bus compile 'com.squareup.picasso:picasso:2.5.2'//Picasso compile('com.squareup.retrofit:retrofit:2.0.0-beta2') { exclude module: 'okhttp' } compile 'com.squareup.okhttp:okhttp:2.5.0' //OkHttp compile 'com.squareup.retrofit:converter-gson:2.0.0-beta2' //Gson Anyone has an idea how to fix this?

nanzee commented 8 years ago

Same problem, looks to be happening only when multiDex is enabled and is only happening on emulator. No issue on physical device.

jjhesk commented 8 years ago

+1. i have the same error too. I found this on stackoverflow but im not sure if it is the real fix of it.

drakeet commented 8 years ago

BTW: Maybe you made a mistake on the onCreate method, the SDK add a new onCreate method after 21, many people will overwrite the method then made errors. 世外桃源 notifications@github.com于2016年5月13日 周五09:26写道:

I found this on stackoverflow http://stackoverflow.com/questions/28857860/classnotfoundexception-didnt-find-class-android-os-persistablebundle-otto-an but im not sure if it is the real fix of it.

— You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub https://github.com/square/otto/issues/183#issuecomment-218929839

JakeWharton commented 8 years ago

This class is included in the released jar so any classloading issues will be specific to your app, likely related to multidex.

kartiksetia commented 8 years ago

This is because of 64K android method error. you have to add multidex library in your application class . http://stackoverflow.com/questions/26609734/how-to-enable-multidexing-with-the-new-android-multidex-support-library