jmartinesp / SwissKnife

A multi-purpose library containing view injection and threading for Android using annotations
Apache License 2.0
254 stars 24 forks source link

Exception when using @InjectViews #8

Closed JoanZapata closed 9 years ago

JoanZapata commented 9 years ago

Hi, first of all thanks for this great library, it really helps getting into groovy on android!

When I try to use @InjectView like this:

    @InjectViews([R.id.btn_twitter_login, R.id.btn_facebook_login])
    List<View> buttons;

I get that:

Error:Groovyc: org.codehaus.groovy.runtime.typehandling.GroovyCastException: Cannot cast object 'java.util.List <View> -> java.util.List <E extends java.lang.Object -> java.lang.Object>' with class 'org.codehaus.groovy.ast.ClassNode' to class 'java.lang.Class' due to: java.lang.ClassNotFoundException: java.util.List <View> -> java.util.List <E extends java.lang.Object -> java.lang.Object>
    at org.codehaus.groovy.runtime.typehandling.ShortTypeHandling.castToClass(ShortTypeHandling.java:35)
    at com.arasthel.swissknife.annotations.InjectViewsTransformation.visit(InjectViewsTransformation.groovy:32)
    at org.codehaus.groovy.transform.ASTTransformationVisitor.visitClass(ASTTransformationVisitor.java:132)
    at org.codehaus.groovy.transform.ASTTransformationVisitor$2.call(ASTTransformationVisitor.java:176)
    at org.codehaus.groovy.control.CompilationUnit.applyToPrimaryClassNodes(CompilationUnit.java:1047)
    at org.codehaus.groovy.control.CompilationUnit.doPhaseOperation(CompilationUnit.java:583)
    at org.codehaus.groovy.control.CompilationUnit.processPhaseOperations(CompilationUnit.java:561)
    at org.codehaus.groovy.control.CompilationUnit.compile(CompilationUnit.java:538)
    at org.jetbrains.groovy.compiler.rt.GroovyCompilerWrapper.compile(GroovyCompilerWrapper.java:54)
    at org.jetbrains.groovy.compiler.rt.DependentGroovycRunner.runGroovyc(DependentGroovycRunner.java:87)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at org.jetbrains.groovy.compiler.rt.GroovycRunner.main(GroovycRunner.java:100)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.CommandLineWrapper.main(CommandLineWrapper.java:130)

This error message is obscure to me. Other annotations work as expected.

Any idea ?

eugene-kamenev commented 9 years ago

Hi, yes a bug in transformation. Thanks for reply.

jmartinesp commented 9 years ago

Should be fixed in e0fec2d67bdde73ab5c2b5139e37abef44d795b0. Thanks for reporting :+1:

JoanZapata commented 9 years ago

Awesome, thanks for the quick reply!