_From @vossad01 on October 28, 2016 21:16_
Using the instructions from the development workflow, the test runs on a clean checkout of this repository
npm install
npm run setup
tsc
tns run android --emulator --path tests
However, if tsc is run after the test run and you try to run the tests again, the tests fail.
npm install
npm run setup
tsc
tns run android --emulator --path tests
tsc
tns run android --emulator --path tests
Exception given in emulator
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{org.nativescript.tests/com.tns.NativeScriptActivity}: java.lang.ClassNotFoundException: Didn't find class "com.tns.NativeScriptActivity" on path: DexPathList[[zip file "/data/app/org.nativescript.tests-1/base.apk"],nativeLibraryDirectories=[/data/app/org.nativescript.tests-1/lib/x86, /data/app/org.nativescript.tests-1/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2548)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2707)
at android.app.ActivityThread.-wrap12(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1460)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6077)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:755)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.tns.NativeScriptActivity" on path: DexPathList[[zip file "/data/app/org.nativescript.tests-1/base.apk"],nativeLibraryDirectories=[/data/app/org.nativescript.tests-1/lib/x86, /data/app/org.nativescript.tests-1/base.apk!/lib/x86, /system/lib, /vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
at java.lang.ClassLoader.loadClass(ClassLoader.java:380)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at android.app.Instrumentation.newActivity(Instrumentation.java:1078)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2538)
... 9 more
Running tsc multiple times before running the tests is not a problem. Running the tests multiple times without runnning tsc is not a problem. The problem only presents when running tsc after a test run then trying to run tests again. This was observed both with my system's tsc and the local one, ./node_modules/.bin/tsc.
git clean -f -x -d clean the repository such that you can start over and run tests again.
Tested against 667f33b47e60bf7a8573fb029fb990a754f08bcd and c46f216d3156f1ba7b138b8bf79b55ff767fa064 on Linux Mint 18.
_Copied from original issue: NativeScript/NativeScript#2982_
Hey @vossad01
We have investigated the issue and can confirm that this case is reproduced with the steps you are describing. As a temporary workaround, you can delete the file cached.txt located in _build-toolsandroid-static-binding-generator_ before running the tests - we will post additional information once we have a solution.
Hi @vossad01,
There is a fix in master already, and you won't need to delete any files because, it will be done automatically. The related PR is already in master and you can try it out using @next.
You can give @next it a try, by running tns platform add android@next, and share if this solution works for you.
After entering the erroring state described in the first post, the following commands were run. Both test runs were successful. I did not test beyond that, but it seems likely to be fixed.
tns platform remove android --path tests
tns platform add android@next --path tests
tns run android --emulator --path tests
tsc
tns run android --emulator --path tests
Most helpful comment
After entering the erroring state described in the first post, the following commands were run. Both test runs were successful. I did not test beyond that, but it seems likely to be fixed.