No class def found error for JUnit Test on android - android

I am having some very bizarre behaviour. I have a large number of test cases for my Android application, and they all work except for one. When I run this one I get a java.lang.NoClassDefFoundError: org.JUnit.test
Yes, I have the JUnit 4 library imported into the project, and my other JUnit tests are running without any problems. What is particularly bizarre is that before I hit this problem I had an error in my code- basically, I tried writing a file to a read only folder. When that occurred, the JUnitTest would execute up to the point where it would hit an IO exception for accessing a part of memory it cannot access. I fix this problem, and suddenly the Android emulator doesn't seem to know what org.JUnit.test is.
I have examined the run configuration for this test class, and it is the same as my others. It is in the same folder as the other tests as well. It also uses the same import statements. Any idea on what is going on?
I am using the Android 10 emulator, and eclipse version 3.7.2.
Edit: To clarify, the error I get appears on Logcat and not in my Eclipse project.

Related

IDE Fatal Error: Write access is allowed from write-safe contexts only

I have built simple Hello World application and ran it from IntelliJ on my Android device. When application starts, IDE error occur:
Write access is allowed from write-safe contexts only. Please ensure you're using invokeLater/invokeAndWait with a correct modality state (not "any"). See TransactionGuard documentation for details.
In the following window:
Simultaneously, application runs ok.
What is the reason and how to get rid of this message?
Got this same error after upgrading from a 2015 edition of IntelliJ to 2016.3.3.
After restarting the IDE, I took the suggested popup's guidance to upgrade Gradle, which then resynced and this error went away.
My project runs now and doesn't produce this error anymore.
If you are in a similar situation, I can recommend the above, as it removed this exact error in my setup.

Android IntelliJ IDEA 14.1: No main class for module

I previously had a working android project when I was using IntelliJ IDEA 14. I could run the project by pressing the play button, and it would install and start the application on my device.
I recently updated to 14.1. The code still appears to compile fine, I can see that it generates an APK and I can view it in the output folder (out/production/myapp/myapp.apk), but now I get an error when I attempt to run the project:
Error:No main class for module: app
I've tried creating two new projects, one based on the Android->Application Module template and another based on the Android->Gradle: Application Module template, and both have the same issue - they spit out the error above with the default configuration.
I assume that this must work on other users boxes, particularly because I haven't found anything online or any bug reports about it, but I guess there is a very minute possibility that I'm the first one to find this.
Is this an issue with IntelliJ IDEA 14.1 or just my box? Any ideas on how to fix it or where to start would be greatly appreciated.
I was having similar issue.
Do you have haxe plugin installed? Try to uninstall and try after that and it should work.

Why does android studio allow me to compile with syntax errors

Hi this may sound like a weird question, but I am new to Android Studio. So far I really like it, but there is one thing that is bugging me. In Eclipse if I ever had a syntax error in my code for example I forgot a ; or something like that. It would not allow me to build my project until I fixed the error.
In android studio I removed some buttons that are referenced several times in the code, and I expected it to gong it and tell me all the places that I referenced the button, but it just runs like normal. Then whenever I get to the part in code where those buttons are referenced the app just crashes.
Is there a way to get Android Studio to find syntax errors?
Eclipse uses a specially instrumented compiler to find errors. The compiler that is compiling your code is the the thing that is generating error messages you see in the IDE
Studio (and Netbeans, incidentally) don't work like that. Your app is assembled by an external build system (Gradle, in the case of Studio), using whatever tools it finds. Studio, independently, generates error messages by analyzing artifacts.
Every now and then, Studio gets out of sync. A rebuild will usually fix it.

trying to build trigger.io module get an error

I wanted to try and do some work with a module in trigger.io but seem to be running into some issues and the docs are well, not very good..
Anyhow I followed the step, the ones that were there anyhow and when I tried to run the project I'm getting an error message stateing
Running tests
Test running started
Test running failed: Unable to find instrumentation info for: ComponentInfo{io.trigger.forge.android.inspector/android.test.InstrumentationTestRunner}
Empty test suite.
I did not change anything just tried to import and run but no matter what I do I cant get it to work. Have looked all around but found nothing that would work so any help would be nice

Android Robotium test - NoClassDefFoundError

I'm having problems with Robotium being unable to find my app at runtime.
Just to be clear, I've seen a few similar questions on SO however, they seem to revolve around the Robotium Solo class not being found at runtime (or some other 3rd party lib). However, this is slightly different as my Robotium tests can't find the project under test.
The tests are in a separate project which has a dependency on my app project. There are no problems at compile-time but when I try to run the tests I get...
java.lang.RuntimeException: Exception during suite construction
at android.test.suitebuilder.TestSuiteBuilder$FailedToCreateTests
....
Caused by: java.lang.NoClassDefFoundError: com.myapp.mobile.activity.RegisterUserScreen
Where RegisterUserScreen is an activity in my app. This happens on the device and the emulator.
I'm building / running in IntelliJ 12.1.4, against Android 4.1.2 and I see the same result when I attempt to run the test from the command line.
Probably worth pointing out that running adb shell pm list instrumentation from the command line returns the correct instrumentation...
instrumentation:com.myapp.mobile.test.system/android.test.InstrumentationTestRunn
er (target=com.myapp.mobile)
Thanks in advance,
Neil.
In your device go to settings->apps and check whether in installed or running application list name of your testing application name is present. If you find it there then uninstall the testing app as well as your original app (which has to be tested). Many times it happens that either because of different versions/signature mismatch test-application fails to find the target application.
Create your run configuration as an "Android Tests" not as "JUnit"

Categories

Resources