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

Robolectric Test Error related to GIfs #422

Open
sreekanth8 opened this issue Jun 22, 2017 · 1 comment
Open

Robolectric Test Error related to GIfs #422

sreekanth8 opened this issue Jun 22, 2017 · 1 comment

Comments

@sreekanth8
Copy link

Hi,

My Robolectric unit test is failing with the gifs, with the error inflating the class. Below is the stack trace. Please help me to sort out this issue.

Robolectric Version - 3.1.4

android.view.InflateException: XML file build/intermediates/res/merged/mockTest/debug/layout/xxx_activity.xml line #-1 (sorry, not yet implemented): Error inflating class pl.droidsonroids.gif.GifImageView

at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.view.View.inflate(View.java:17426)
at com.test.view.activity.MainActivity.onCreate(MainActivity.java:178)
at android.app.Activity.performCreate(Activity.java:5243)
at org.robolectric.util.ReflectionHelpers.callInstanceMethod(ReflectionHelpers.java:195)
at org.robolectric.util.ActivityController$1.run(ActivityController.java:126)
at org.robolectric.shadows.ShadowLooper.runPaused(ShadowLooper.java:356)
at org.robolectric.shadows.CoreShadowsAdapter$2.runPaused(CoreShadowsAdapter.java:40)
at org.robolectric.util.ActivityController.create(ActivityController.java:123)
at org.robolectric.util.ActivityController.create(ActivityController.java:133)
at com.test.view.activity.testmethodName.testInitializedProperly_multipleItems(testmethodName.java:79)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:498)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:245)
at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:171)
at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:137)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.$$robo$$createView(LayoutInflater.java:594)
at android.view.LayoutInflater.createView(LayoutInflater.java)
at android.view.LayoutInflater.$$robo$$createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java)
at android.view.LayoutInflater.$$robo$$rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.rInflate(LayoutInflater.java)
at android.view.LayoutInflater.$$robo$$inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java)
at android.view.LayoutInflater.$$robo$$inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java)
at android.view.LayoutInflater.$$robo$$inflate(LayoutInflater.java:353)
at android.view.LayoutInflater.inflate(LayoutInflater.java)
at android.view.View.$$robo$$inflate(View.java:17426)
at android.view.View.inflate(View.java)
at com.test.view.activity.MainActivity.onCreate(MainActivity.java:178)
at com.test.view.activity.FeatureTourActivity.onCreate(FeatureTourActivity.java:67)
at android.app.Activity.$$robo$$performCreate(Activity.java:5243)
at android.app.Activity.performCreate(Activity.java)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.robolectric.util.ReflectionHelpers.callInstanceMethod(ReflectionHelpers.java:195)
at org.robolectric.util.ActivityController$1.run(ActivityController.java:126)
at org.robolectric.shadows.ShadowLooper.runPaused(ShadowLooper.java:356)
at org.robolectric.shadows.CoreShadowsAdapter$2.runPaused(CoreShadowsAdapter.java:40)
at org.robolectric.util.ActivityController.create(ActivityController.java:123)
at org.robolectric.util.ActivityController.create(ActivityController.java:133)
at com.test.view.activity.testmethodName.testInitializedProperly_multipleItems(testmethodName.java:79)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:498)
at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:245)
at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:171)
at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:47)
at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:137)
at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
... 1 more
Caused by: java.lang.ExceptionInInitializerError
at pl.droidsonroids.gif.GifDrawable.(GifDrawable.java:160)
at pl.droidsonroids.gif.GifDrawable.(GifDrawable.java:95)
at pl.droidsonroids.gif.GifViewUtils.setResource(GifViewUtils.java:53)
at pl.droidsonroids.gif.GifViewUtils.getResourceId(GifViewUtils.java:41)
at pl.droidsonroids.gif.GifViewUtils.initImageView(GifViewUtils.java:29)
at pl.droidsonroids.gif.GifImageView.(GifImageView.java:41)
... 63 more
Caused by: java.lang.IllegalStateException: Could not open APK file:
at pl.droidsonroids.gif.ReLinker.openZipFile(ReLinker.java:172)
at pl.droidsonroids.gif.ReLinker.unpackLibrary(ReLinker.java:95)
at pl.droidsonroids.gif.ReLinker.loadLibrary(ReLinker.java:58)
at pl.droidsonroids.gif.LibraryLoader.loadLibrary(LibraryLoader.java:52)
at pl.droidsonroids.gif.GifInfoHandle.(GifInfoHandle.java:21)
... 69 more

@koral--
Copy link
Owner

koral-- commented Jun 22, 2017

Robolectric tests won't work unless you compile the native library for your host machine.
robolectric/robolectric#1171
It should be possible to create native methods stubs and compile them using gradle c plugin.
I'll keep this issue open but can't promise any ETA. PRs are welcome.

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

No branches or pull requests

2 participants