2

I have a strange error adding new module (https://github.com/lomza/android-color-picker) to my project. Without this module project runs fine, but if add this project as module to my main project and compile it - everything looks good, but app starts and force closes instantly giving me this error:

FATAL EXCEPTION: main
    java.lang.NoClassDefFoundError: android.support.v4.app.NavUtilsJB
            at android.support.v4.app.NavUtils$NavUtilsImplJB.getParentActivityName(NavUtils.java:125)
            at android.support.v4.app.NavUtils.getParentActivityName(NavUtils.java:302)
            at android.support.v4.app.NavUtils.getParentActivityName(NavUtils.java:281)
            at android.support.v7.app.ActionBarActivityDelegateBase.onCreate(ActionBarActivityDelegateBase.java:142)
            at android.support.v7.app.ActionBarActivity.onCreate(ActionBarActivity.java:123)
            at app.user.views.ActivityWelcome.onCreate(ActivityWelcome.java:33)
            at android.app.Activity.performCreate(Activity.java:5133)
            at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
            at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
            at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
            at android.app.ActivityThread.access$600(ActivityThread.java:141)
            at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
            at android.os.Handler.dispatchMessage(Handler.java:99)
            at android.os.Looper.loop(Looper.java:137)
            at android.app.ActivityThread.main(ActivityThread.java:5103)
            at java.lang.reflect.Method.invokeNative(Native Method)
            at java.lang.reflect.Method.invoke(Method.java:525)
            at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
            at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
            at dalvik.system.NativeStart.main(Native Method)

ActivityWelcome.java 33 line is super.onCreate(savedInstanceState);

If I remove this module from project - everything runs fine again. I have same problem adding any new module to my project. Where is the problem?

EDIT: I find out that project runs fine on API 21, but if I run it on API 18, I am getting error.

Eddwhis
  • 1,124
  • 2
  • 16
  • 33

2 Answers2

7

I found solution for this problem. I was using multidexing and it is available only in Lolipop devices, so, to use it in pre-Lolipop devices I needed to add this line

compile 'com.android.support:multidex:1.0.0' to build.gradle file

and this one line android:name="android.support.multidex.MultiDexApplication" to AndroidManifest.xml in <appplication tag.

For me - now everything works fine.

EDIT: instead of adding line to android:name in manifest, you can add multiDexEnabled = true to gradle file in defaultConfig.

Eddwhis
  • 1,124
  • 2
  • 16
  • 33
1

Based on the stack trace, I would strongly suspect a problem with support library version mismatches. For example, it appears that the android-color-picker library relies on a quite outdated version of the support library (updated over a year ago). Perhaps your main project is using a more recent version of the support library? In order to avoid this crash, I would recommend reconfiguring the android-color-picker library to use the same version of the support library that you are using elsewhere in your project.

Scott W
  • 9,742
  • 2
  • 38
  • 53
  • Yes, I know about this. First thing which I did after library import was `android-color-picker` buiild.gradle file configuration. I changed support library version to the same as project, but this not solves problem. – Eddwhis Feb 17 '15 at 14:37
  • Hello, I found problem. It was related with multidexing nad not with color picker. Posted it as an answer. – Eddwhis Feb 27 '15 at 14:25