Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Multi dex installation failed. SDK 1 is unsupported. Min SDK version is 4. #2683

Closed
jonneymendoza opened this issue Oct 17, 2016 · 5 comments

Comments

@jonneymendoza
Copy link

Description

Multi dex installation failed. SDK 1 is unsupported. Min SDK version is 4.

Steps to Reproduce

execute a unit test through gradle using ./gradlew test

Robolectric & Android Version

robolectric 2.4, Android minSdk 4.4

@emartynov
Copy link

Can you try latest Robolectric? Do you also have the dependency to shadows-multidex?

@jonneymendoza
Copy link
Author

We are stuck on using 2.4 unless we completely refactor all our test classes. Is there no way other fix?

@emartynov
Copy link

Up to you, but new Robolectric is more shiny and bright. For example, Shadow multidex is only available from 3.x.

But you can still fix it with next workaround:

  1. Change your application from extending MultiDexApplication and do multidex install in method:
  @Override
  protected void attachBaseContext(Context base)
  {
    super.attachBaseContext(base);
    installMultidex(base);
  }

  protected void installMultidex(Context base) {
    MultiDex.install(base);
  }
  1. Create class in test sources in the same package as yours app with name Test<YourAppName> (example your application name is com.mycompany.android.SuperUsefulApplication then class in test sources should be com.mycompany.android.TestSuperUsefulApplication. And override next mutlidex install method:
class TestSuperUsefulApplication extends SuperUsefulApplication {
  @Override
  protected void installMultidex(Context base) {
     //do nothing for tests
  }
}

@jaredsburrows
Copy link
Contributor

This is not a Robolectric issue. Robolectric 2.4 is old, please update. Robolectric min sdk is API 16.

@jongerrish
Copy link
Contributor

Closing this as it hasn't been updated in a while. If its still an issue with Robolectric 4.0 please reopen with a reproducible test case and we'll prioritize.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants