2

My tests work perfectly on devices with API level 20 and above but fail for API level 19 and below. Issue seems to be with roboguice but I am unable to find a solution for it. Please help. The logs are as below.

03-15 05:06:54.600 1748-1748/? E/AndroidRuntime: FATAL EXCEPTION: main
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime: Process: com.rr.rruniversal.mobile, PID: 1748
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime: java.lang.NoClassDefFoundError: roboguice.inject.AssetManagerProvider
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at roboguice.config.DefaultRoboModule.configure(DefaultRoboModule.java:155)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at com.google.inject.AbstractModule.configure(AbstractModule.java:78)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:252)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at com.google.inject.spi.Elements.getElements(Elements.java:107)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at com.google.inject.util.Modules$OverrideModule.configure(Modules.java:174)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at com.google.inject.AbstractModule.configure(AbstractModule.java:78)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at com.google.inject.spi.Elements$RecordingBinder.install(Elements.java:252)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at com.google.inject.spi.Elements.getElements(Elements.java:107)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at com.google.inject.internal.InjectorShell$Builder.build(InjectorShell.java:135)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at com.google.inject.internal.InternalInjectorCreator.build(InternalInjectorCreator.java:104)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at com.google.inject.Guice.createInjector(Guice.java:100)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at com.google.inject.Guice.createInjector(Guice.java:87)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at roboguice.RoboGuice.createGuiceInjector(RoboGuice.java:186)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at roboguice.RoboGuice.getOrCreateBaseApplicationInjector(RoboGuice.java:114)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at net.doo.snap.ScanbotSDKInitializer.initialize(SourceFile:119)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at com.rruniversal.mobilelib.imagecapture.ImageCaptureInitializer.initialize(Unknown Source)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at com.hello.appuniversal.RRUniversalApp.onCreate(RRUniversalApp.java:126)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1007)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at android.support.test.runner.MonitoringInstrumentation.callApplicationOnCreate(MonitoringInstrumentation.java:325)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4328)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at android.app.ActivityThread.access$1500(ActivityThread.java:135)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:136)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5001)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at java.lang.reflect.Method.invokeNative(Native Method)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:515)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:785)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:601)
03-15 05:06:54.600 1748-1748/? E/AndroidRuntime:     at dalvik.system.NativeStart.main(Native Method)
03-15 05:06:54.600 532-707/? W/ActivityManager: Error in app com.rruniversal.app.mobile running instrumentation ComponentInfo{com.rr.rruniversal.test/android.support.test.runner.AndroidJUnitRunner}:
03-15 05:06:54.600 532-707/? W/ActivityManager:   java.lang.NoClassDefFoundError
03-15 05:06:54.600 532-707/? W/ActivityManager:   java.lang.NoClassDefFoundError: roboguice.inject.AssetManagerProvider

Where am I going wrong? Is there anything in particular I need to include in build.gradle as dependencies? The dependencies I added are as below:

androidTestCompile ('com.android.support.test.espresso:espresso-core:2.2.1') {
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude group: 'com.google.code.findbugs', 'module': 'jsr305'
    }

    // Espresso-web for WebView support
    androidTestCompile ('com.android.support.test.espresso:espresso-web:2.2.1') {
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude group: 'com.google.code.findbugs', 'module': 'jsr305'
    }

The exclusions were done since I was getting conflicts on syncing. And I am using SDK Level 23 for my App. Any help will do. Thanks in advance!

Azerot
  • 21
  • 2
  • Did you tried with this, please check this link - http://mbcdev.com/2012/07/01/noclassdeffounderror-for-javax-inject-provider-after-upgrading-to-roboguice-2-0-6/ – kalpana c Mar 15 '16 at 09:39
  • Do you support multidex? – Uriel Frankel Mar 15 '16 at 11:53
  • @UrielFrankel, Yes, the project does support multidex. – Azerot Mar 15 '16 at 12:37
  • @Kedi, I don't think that link is relevant in my case, One of my dependencies is using roboguice-3.0.1 jar, due to which I am getting the error mentioned in API level 19 and below. – Azerot Mar 15 '16 at 12:38
  • I think roboguice and guice are different thing. As per this line - To get things working you’ll need to add another jar in addition to roboguice2 and guice3(no aop). The new jar is “javax.inject.jar” and you can extract it from the zip distribution of Guice 3.0. You should try with this zip. – kalpana c Mar 16 '16 at 06:41
  • No this is not working. Any other suggestions???? – Azerot Mar 18 '16 at 06:55

1 Answers1

0

I had the same issue as you and finally got it working on KitKat... Here's my current working configuration:

  • RoboGuice 3.0.1
  • a bunch of Android Support Libraries at 23.4.0
  • Google Play Services 8.4.0
  • Butterknife etc.

  • Android Gradle Plugin 2.1.0

  • Build tools 23.0.3
  • target and compile SDK 23
  • min SDK 15
  • Android Support Multidex 1.0.1
  • a bunch of other dependencies...

And for android tests specifically in dependencies I have:

androidTestCompile ("com.android.support.test:runner:$runnerVersion")
androidTestCompile ("com.android.support.test:rules:$rulesVersion")
androidTestCompile ("com.android.support:support-annotations:$androidSupportLibraryVersion")
androidTestCompile ("com.android.support.test.espresso:espresso-core:$espressoVersion") {
    exclude group: 'javax.inject'
}
androidTestCompile ("com.android.support.test.espresso:espresso-intents:$espressoVersion") {
    exclude group: 'com.android.support.test.espresso', module: 'espresso-core'
}
androidTestCompile ("org.mockito:mockito-core:$mockitoVersion") {
    force = true
}
androidTestCompile ("com.crittercism.dexmaker:dexmaker:$dexmakerVersion")
androidTestCompile ("com.crittercism.dexmaker:dexmaker-dx:$dexmakerVersion")
androidTestCompile ("com.crittercism.dexmaker:dexmaker-mockito:$dexmakerVersion")

where

    mockitoVersion                      = "1.10.19"
    runnerVersion                       = "0.5"
    rulesVersion                        = "0.5"
    espressoVersion                     = "2.2.2"
    dexmakerVersion                     = "1.4"

In your case you might want to add:

androidTestCompile ("com.android.support.test.espresso:espresso-web:$espressoVersion") {
    exclude group: 'com.android.support.test.espresso', module: 'espresso-core'
}

If you're not using mockito then I guess you could skip the dexmaker dependencies - they were needed only to get mockito working (at least in my project).

Hope this solves your problem!

Piotr Zawadzki
  • 1,678
  • 1
  • 18
  • 24