Issue
This is my first time setting up an Android test project to test a Android project.
I've created a very basic test case which I'm trying to get to run, however what I have does not run. I get a Test run failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'
.
I would troubleshot this more, however I don't get any more information, such as which class it is trying to find, etc. Any ideas on how to get more information from the error? Any common areas I should look at, or anything that might need to be configured that I'm overlooking?
Below is the information from the console:
[2013-04-16 13:21:49 - XyzProgramTest] Android Launch!
[2013-04-16 13:21:49 - XyzProgramTest] adb is running normally.
[2013-04-16 13:21:49 - XyzProgramTest] Performing android.test.InstrumentationTestRunner JUnit launch
[2013-04-16 13:21:49 - XyzProgramTest] Automatic Target Mode: launching new emulator with compatible AVD 'GalaxyNexusAPI_17'
[2013-04-16 13:21:49 - XyzProgramTest] Launching a new emulator with Virtual Device 'GalaxyNexusAPI_17'
[2013-04-16 13:21:53 - Emulator] extension WGL_ARB_make_current_read was not found
[2013-04-16 13:21:53 - Emulator] extension WGL_EXT_swap_control was not found
[2013-04-16 13:21:53 - Emulator] Failed to create pbuf surface for FB 0x3004
[2013-04-16 13:21:53 - Emulator] emulator: WARNING: Could not initialize OpenglES emulation, using software renderer.
[2013-04-16 13:21:54 - XyzProgramTest] New emulator found: emulator-5554
[2013-04-16 13:21:54 - XyzProgramTest] Waiting for HOME ('android.process.acore') to be launched...
[2013-04-16 13:22:55 - XyzProgramTest] HOME is up on device 'emulator-5554'
[2013-04-16 13:22:55 - XyzProgramTest] Uploading XyzProgramTest.apk onto device 'emulator-5554'
[2013-04-16 13:22:55 - XyzProgramTest] Installing XyzProgramTest.apk...
[2013-04-16 13:23:57 - XyzProgramTest] Success!
[2013-04-16 13:23:57 - XyzProgramTest] Project dependency found, installing: XyzProgram
[2013-04-16 13:23:57 - XyzProgram] Uploading XyzProgram.apk onto device 'emulator-5554'
[2013-04-16 13:23:58 - XyzProgram] Installing XyzProgram.apk...
[2013-04-16 13:24:05 - XyzProgram] Success!
[2013-04-16 13:24:05 - XyzProgramTest] Launching instrumentation android.test.InstrumentationTestRunner on emulator-5554
[2013-04-16 13:24:07 - XyzProgramTest] Test run failed: Instrumentation run failed due to 'java.lang.ClassNotFoundException'
Additional Notes
In my Android test project, I created a simple test with a package similar to the package that matches up with the class I'm trying to test in my Android project. So something like com.company.android.projectname
. I've specified this in the Android test project manifest
file's instrumentation
section.
<instrumentation
android:name="android.test.InstrumentationTestRunner"
android:targetPackage="com.company.android.projectname" />
When I changed this to match that, I get a new error that says Test run failed: Unable to find instrumentation target package: com.company.android.projectname
I'm not 100% sure what that targetPackage
should be and if I need multiple instrumentations for each package I want to test, etc. When I set it to com.company.android
that is when I get the java.lang.ClassNotFoundException
.
Solution
Figured out my issue and am posting the answer for documentation purposes...
The root of my problem was 2 different things:
- I did some refactoring, which change the location of my
android.app.Application
class and my activities. This made it so my main program was not working as I needed to update my manifest in myandroid project
. - After making the updates to my manifest in my android project, I had to make some updates in my
android test project
to point to the updated location of the class that extendsandroid.app.Application
.
After that, did some cleans and tested again and things were good.
Answered By - James Oravec
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.