You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Repository navigation
This repository was archived by the owner on Feb 26, 2023. It is now read-only.
Annotated code: Empty Activity with @EActivity annotation
Actual generated code: Looks correct, no issues here.
We want to use AndroidAnnotation generated classes in tests (unit/instrumentation) but since Kotlin 1.1.3 this does not work anymore. Tests implemented in Java instead of Kotlin work fine however.
Easiest way to reproduce (unit test):
Kotlin app project with AndroidAnnotations
enhance an activity with annotation @EActivity
write Kotlin unit test which creates an AndroidAnnotation generated activity instance (ExampleActivity_) and call setContentView(null)
expected is a stacktrace which contains information about AndroidAnnotation generated activity class
result is stacktrace with direct call to base class (skipping the generated one)
Other way to reproduce (instrumentation test):
This issue occurs also within Espresso tests. Espresso test references generated class, but it uses the base activity during runtime.
java.lang.RuntimeException: Could not launch activity
at android.support.test.runner.MonitoringInstrumentation.startActivitySync(MonitoringInstrumentation.java:430)
at android.support.test.rule.ActivityTestRule.launchActivity(ActivityTestRule.java:332)
at android.support.test.rule.ActivityTestRule$ActivityStatement.evaluate(ActivityTestRule.java:431)
at org.junit.rules.RunRules.evaluate(RunRules.java:20)
...
at android.support.test.internal.runner.TestExecutor.execute(TestExecutor.java:58)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:375)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1932)
Caused by: java.lang.RuntimeException: Unable to resolve activity for: Intent { act=android.intent.action.MAIN flg=0x10000000 cmp=com.company.myapp/.ui.MyActivity }
at android.app.Instrumentation.startActivitySync(Instrumentation.java:396)
at android.support.test.runner.MonitoringInstrumentation.access$101(MonitoringInstrumentation.java:96)
at android.support.test.runner.MonitoringInstrumentation$4.call(MonitoringInstrumentation.java:410)
at android.support.test.runner.MonitoringInstrumentation$4.call(MonitoringInstrumentation.java:407)
at java.util.concurrent.FutureTask.run(FutureTask.java:237)
...
Already tried:
use different Kotlin versions
with all Kotlin 1.1.2-* versions its works fine, with 1.1.3 this issue occurs
with Kotlin 1.1.51 the issue still exists
tools like dbflow looks working (possible not comparable)
I am afraid this is out of of the processor's reach, we cannot really do anything about this. But you can share the example project so we can take a look.
There are also other libraries included where I can access the generated classes in Kotlin based tests without any issue. Also the Java based tests work without any issue.
@nenick i checked your project, it is really strange... For some reason MainActivity_::class returns the Kotlin class for MainActivity. But this is only happening in the instrumented test, not in the app. It is also happening in the unit test. You should report this error in the upstream project (i am not sure which), because we cannot do anything from AA-side. :(
@WonderCsabo do you know why all classes generated by AndroidAnnotations have the @Metadata(...) annotation? When i remove this annotation from generated classes then tests work fine.
This line effects which class is loaded "Lde/nenick/example/MainActivity;",
tests load the correct class when it gets changed to "Lde/nenick/example/MainActivity_;",
Edit: @Metadata(...) is only added when enhanced class is written in kotlin. What works is to write an abstract enhanced kotlin class and extend it by an enhanced java class. But this results in uggly boilerplate code.
I just got feedback and it seems that after all this is an issue within android annotations as we copy annotations from the enhanced class and those include the kotlin.Metadata.
AndroidAnnotations version: 4.4.0
Android compile SDK version: 25
Annotated code: Empty Activity with
@EActivityannotationActual generated code: Looks correct, no issues here.
We want to use AndroidAnnotation generated classes in tests (unit/instrumentation) but since Kotlin 1.1.3 this does not work anymore. Tests implemented in Java instead of Kotlin work fine however.
Easiest way to reproduce (unit test):
@EActivitysetContentView(null)Other way to reproduce (instrumentation test):
This issue occurs also within Espresso tests. Espresso test references generated class, but it uses the base activity during runtime.
Already tried: