Robolectric test throwing IllegalArgumentException with no message

Multi tool use
Multi tool use












4















RobolectricTestRunner::class in my unit tests is throwing IllegalArgumentException with no message with this stack-trace:



My unit test class:



@RunWith(RobolectricTestRunner::class)
class UnitTest {
@Test
fun testEncodeDecode() {
}
}


The output stacktrace:



java.lang.IllegalArgumentException
at org.objectweb.asm.AnnotationVisitor.<init>(Unknown Source)
at org.objectweb.asm.AnnotationVisitor.<init>(Unknown Source)
at org.objectweb.asm.tree.AnnotationNode.<init>(AnnotationNode.java:77)
at org.objectweb.asm.tree.AnnotationNode.<init>(AnnotationNode.java:63)
at org.objectweb.asm.tree.ClassNode.visitAnnotation(ClassNode.java:208)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.objectweb.asm.ClassReader.accept(Unknown Source)
at org.robolectric.internal.bytecode.ClassInstrumentor.analyzeClass(ClassInstrumentor.java:63)
at org.robolectric.internal.bytecode.SandboxClassLoader.lambda$maybeInstrumentClass$1(SandboxClassLoader.java:121)
at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:50)
at org.robolectric.internal.bytecode.SandboxClassLoader.maybeInstrumentClass(SandboxClassLoader.java:120)
at org.robolectric.internal.bytecode.SandboxClassLoader.lambda$findClass$0(SandboxClassLoader.java:111)
at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:50)
at org.robolectric.internal.bytecode.SandboxClassLoader.findClass(SandboxClassLoader.java:110)
at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
at org.robolectric.RobolectricTestRunner.getHooksInterface(RobolectricTestRunner.java:551)
at org.robolectric.RobolectricTestRunner.configureSandbox(RobolectricTestRunner.java:235)
at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:230)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:130)
at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:42)
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.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:84)
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:68)
at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
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 com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)









share|improve this question





























    4















    RobolectricTestRunner::class in my unit tests is throwing IllegalArgumentException with no message with this stack-trace:



    My unit test class:



    @RunWith(RobolectricTestRunner::class)
    class UnitTest {
    @Test
    fun testEncodeDecode() {
    }
    }


    The output stacktrace:



    java.lang.IllegalArgumentException
    at org.objectweb.asm.AnnotationVisitor.<init>(Unknown Source)
    at org.objectweb.asm.AnnotationVisitor.<init>(Unknown Source)
    at org.objectweb.asm.tree.AnnotationNode.<init>(AnnotationNode.java:77)
    at org.objectweb.asm.tree.AnnotationNode.<init>(AnnotationNode.java:63)
    at org.objectweb.asm.tree.ClassNode.visitAnnotation(ClassNode.java:208)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at org.objectweb.asm.ClassReader.accept(Unknown Source)
    at org.robolectric.internal.bytecode.ClassInstrumentor.analyzeClass(ClassInstrumentor.java:63)
    at org.robolectric.internal.bytecode.SandboxClassLoader.lambda$maybeInstrumentClass$1(SandboxClassLoader.java:121)
    at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:50)
    at org.robolectric.internal.bytecode.SandboxClassLoader.maybeInstrumentClass(SandboxClassLoader.java:120)
    at org.robolectric.internal.bytecode.SandboxClassLoader.lambda$findClass$0(SandboxClassLoader.java:111)
    at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:50)
    at org.robolectric.internal.bytecode.SandboxClassLoader.findClass(SandboxClassLoader.java:110)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
    at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
    at org.robolectric.RobolectricTestRunner.getHooksInterface(RobolectricTestRunner.java:551)
    at org.robolectric.RobolectricTestRunner.configureSandbox(RobolectricTestRunner.java:235)
    at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:230)
    at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:130)
    at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:42)
    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.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:84)
    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:68)
    at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
    at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
    at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
    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 com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)









    share|improve this question



























      4












      4








      4








      RobolectricTestRunner::class in my unit tests is throwing IllegalArgumentException with no message with this stack-trace:



      My unit test class:



      @RunWith(RobolectricTestRunner::class)
      class UnitTest {
      @Test
      fun testEncodeDecode() {
      }
      }


      The output stacktrace:



      java.lang.IllegalArgumentException
      at org.objectweb.asm.AnnotationVisitor.<init>(Unknown Source)
      at org.objectweb.asm.AnnotationVisitor.<init>(Unknown Source)
      at org.objectweb.asm.tree.AnnotationNode.<init>(AnnotationNode.java:77)
      at org.objectweb.asm.tree.AnnotationNode.<init>(AnnotationNode.java:63)
      at org.objectweb.asm.tree.ClassNode.visitAnnotation(ClassNode.java:208)
      at org.objectweb.asm.ClassReader.accept(Unknown Source)
      at org.objectweb.asm.ClassReader.accept(Unknown Source)
      at org.robolectric.internal.bytecode.ClassInstrumentor.analyzeClass(ClassInstrumentor.java:63)
      at org.robolectric.internal.bytecode.SandboxClassLoader.lambda$maybeInstrumentClass$1(SandboxClassLoader.java:121)
      at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:50)
      at org.robolectric.internal.bytecode.SandboxClassLoader.maybeInstrumentClass(SandboxClassLoader.java:120)
      at org.robolectric.internal.bytecode.SandboxClassLoader.lambda$findClass$0(SandboxClassLoader.java:111)
      at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:50)
      at org.robolectric.internal.bytecode.SandboxClassLoader.findClass(SandboxClassLoader.java:110)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      at org.robolectric.RobolectricTestRunner.getHooksInterface(RobolectricTestRunner.java:551)
      at org.robolectric.RobolectricTestRunner.configureSandbox(RobolectricTestRunner.java:235)
      at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:230)
      at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:130)
      at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:42)
      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.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:84)
      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:68)
      at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
      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 com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)









      share|improve this question
















      RobolectricTestRunner::class in my unit tests is throwing IllegalArgumentException with no message with this stack-trace:



      My unit test class:



      @RunWith(RobolectricTestRunner::class)
      class UnitTest {
      @Test
      fun testEncodeDecode() {
      }
      }


      The output stacktrace:



      java.lang.IllegalArgumentException
      at org.objectweb.asm.AnnotationVisitor.<init>(Unknown Source)
      at org.objectweb.asm.AnnotationVisitor.<init>(Unknown Source)
      at org.objectweb.asm.tree.AnnotationNode.<init>(AnnotationNode.java:77)
      at org.objectweb.asm.tree.AnnotationNode.<init>(AnnotationNode.java:63)
      at org.objectweb.asm.tree.ClassNode.visitAnnotation(ClassNode.java:208)
      at org.objectweb.asm.ClassReader.accept(Unknown Source)
      at org.objectweb.asm.ClassReader.accept(Unknown Source)
      at org.robolectric.internal.bytecode.ClassInstrumentor.analyzeClass(ClassInstrumentor.java:63)
      at org.robolectric.internal.bytecode.SandboxClassLoader.lambda$maybeInstrumentClass$1(SandboxClassLoader.java:121)
      at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:50)
      at org.robolectric.internal.bytecode.SandboxClassLoader.maybeInstrumentClass(SandboxClassLoader.java:120)
      at org.robolectric.internal.bytecode.SandboxClassLoader.lambda$findClass$0(SandboxClassLoader.java:111)
      at org.robolectric.util.PerfStatsCollector.measure(PerfStatsCollector.java:50)
      at org.robolectric.internal.bytecode.SandboxClassLoader.findClass(SandboxClassLoader.java:110)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:424)
      at java.lang.ClassLoader.loadClass(ClassLoader.java:357)
      at org.robolectric.RobolectricTestRunner.getHooksInterface(RobolectricTestRunner.java:551)
      at org.robolectric.RobolectricTestRunner.configureSandbox(RobolectricTestRunner.java:235)
      at org.robolectric.internal.SandboxTestRunner$2.evaluate(SandboxTestRunner.java:230)
      at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:130)
      at org.robolectric.internal.SandboxTestRunner.runChild(SandboxTestRunner.java:42)
      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.internal.SandboxTestRunner$1.evaluate(SandboxTestRunner.java:84)
      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:68)
      at com.intellij.rt.execution.junit.IdeaTestRunner$Repeater.startRunnerWithArgs(IdeaTestRunner.java:47)
      at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:242)
      at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:70)
      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 com.intellij.rt.execution.application.AppMainV2.main(AppMainV2.java:131)






      android unit-testing android-studio jvm robolectric






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited Dec 31 '18 at 12:26









      Rahul

      9121521




      9121521










      asked Dec 31 '18 at 12:04









      Saeed EntezariSaeed Entezari

      1,198718




      1,198718
























          1 Answer
          1






          active

          oldest

          votes


















          4














          Going through the classes AnnotationNode and AnnotationVisitor I noticed that there is a api argument passed to the super(api) of AnnotationVisitor which was supposed to be one of Opcodes#ASM4 or Opcodes#ASM5 or Opcodes#ASM6 or Opcodes#ASM7 but the constructor was only accepting the first two.



          I noticed that there are two dependencies of org.ow2.asm:asm with two different versions org.ow2.asm:asm:7.0 and org.ow2.asm:asm:5.0.4 which was the source of problem.



          To resolve the issue you must force the Gradle to import only the 7.0 version like this:



          android {
          allprojects {
          configurations {
          all {
          resolutionStrategy {
          force "org.ow2.asm:asm:7.0"
          }
          }
          }
          }





          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            autoActivateHeartbeat: false,
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














            draft saved

            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53987300%2frobolectric-test-throwing-illegalargumentexception-with-no-message%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown

























            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes









            4














            Going through the classes AnnotationNode and AnnotationVisitor I noticed that there is a api argument passed to the super(api) of AnnotationVisitor which was supposed to be one of Opcodes#ASM4 or Opcodes#ASM5 or Opcodes#ASM6 or Opcodes#ASM7 but the constructor was only accepting the first two.



            I noticed that there are two dependencies of org.ow2.asm:asm with two different versions org.ow2.asm:asm:7.0 and org.ow2.asm:asm:5.0.4 which was the source of problem.



            To resolve the issue you must force the Gradle to import only the 7.0 version like this:



            android {
            allprojects {
            configurations {
            all {
            resolutionStrategy {
            force "org.ow2.asm:asm:7.0"
            }
            }
            }
            }





            share|improve this answer




























              4














              Going through the classes AnnotationNode and AnnotationVisitor I noticed that there is a api argument passed to the super(api) of AnnotationVisitor which was supposed to be one of Opcodes#ASM4 or Opcodes#ASM5 or Opcodes#ASM6 or Opcodes#ASM7 but the constructor was only accepting the first two.



              I noticed that there are two dependencies of org.ow2.asm:asm with two different versions org.ow2.asm:asm:7.0 and org.ow2.asm:asm:5.0.4 which was the source of problem.



              To resolve the issue you must force the Gradle to import only the 7.0 version like this:



              android {
              allprojects {
              configurations {
              all {
              resolutionStrategy {
              force "org.ow2.asm:asm:7.0"
              }
              }
              }
              }





              share|improve this answer


























                4












                4








                4







                Going through the classes AnnotationNode and AnnotationVisitor I noticed that there is a api argument passed to the super(api) of AnnotationVisitor which was supposed to be one of Opcodes#ASM4 or Opcodes#ASM5 or Opcodes#ASM6 or Opcodes#ASM7 but the constructor was only accepting the first two.



                I noticed that there are two dependencies of org.ow2.asm:asm with two different versions org.ow2.asm:asm:7.0 and org.ow2.asm:asm:5.0.4 which was the source of problem.



                To resolve the issue you must force the Gradle to import only the 7.0 version like this:



                android {
                allprojects {
                configurations {
                all {
                resolutionStrategy {
                force "org.ow2.asm:asm:7.0"
                }
                }
                }
                }





                share|improve this answer













                Going through the classes AnnotationNode and AnnotationVisitor I noticed that there is a api argument passed to the super(api) of AnnotationVisitor which was supposed to be one of Opcodes#ASM4 or Opcodes#ASM5 or Opcodes#ASM6 or Opcodes#ASM7 but the constructor was only accepting the first two.



                I noticed that there are two dependencies of org.ow2.asm:asm with two different versions org.ow2.asm:asm:7.0 and org.ow2.asm:asm:5.0.4 which was the source of problem.



                To resolve the issue you must force the Gradle to import only the 7.0 version like this:



                android {
                allprojects {
                configurations {
                all {
                resolutionStrategy {
                force "org.ow2.asm:asm:7.0"
                }
                }
                }
                }






                share|improve this answer












                share|improve this answer



                share|improve this answer










                answered Dec 31 '18 at 12:04









                Saeed EntezariSaeed Entezari

                1,198718




                1,198718
































                    draft saved

                    draft discarded




















































                    Thanks for contributing an answer to Stack Overflow!


                    • Please be sure to answer the question. Provide details and share your research!

                    But avoid



                    • Asking for help, clarification, or responding to other answers.

                    • Making statements based on opinion; back them up with references or personal experience.


                    To learn more, see our tips on writing great answers.




                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53987300%2frobolectric-test-throwing-illegalargumentexception-with-no-message%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest















                    Required, but never shown





















































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown

































                    Required, but never shown














                    Required, but never shown












                    Required, but never shown







                    Required, but never shown







                    x6xV A8D51z2ugUMnE7DPGnZcsHOtT0RQIMHPBZq,zUjg xM qQJkoUw
                    u8F0uTN BInJB4wGcw4jhH2 W8Pkt60qBkLy,BwONvv1qwEZzW QNxsV5Fpj1neOSuTv,x68UPQScZN8f

                    Popular posts from this blog

                    Monofisismo

                    Angular Downloading a file using contenturl with Basic Authentication

                    Olmecas