Test run failed: java.lang.IllegalAccessError


This happens when you have 3 projects in your eclipse dev environment.
1) Library project : here you have common stuff between other projects
2) Android project : here you have your android app, which has the Library project as a project in your build path
3) Android Test Instrumentation project : here you have your test cases which run on your android device.

Naturally you will include 1 and 2 as dependent projects to 3, in 3’s properties->java build path -> projects.

Instead you need to edit the project properties on 2. On 2, Properties->JavaBuildPath->OrderandExport, check the Library project for exporting.
AND
Dont include the library project into 3, instead just include 2 in 3. Since 1 is exported in 2, you will be ok. And this error will go away.

I referred to this blog for this issue.

Advertisements

7 thoughts on “Test run failed: java.lang.IllegalAccessError

  1. Here is the problem i am facing

    1] I have an Android Application Project which uses a signed library jar say utility.jar
    2] I have an Android Test Project which tests the Android application project
    3] There is a library used by Test project say[test.jar]
    4] This test.jar uses utility.jar api’s
    5] The test.jar is required as a library to the test project

    This situation gives a runtime java.lang.illegalAccessException exception cz i am making use off the same signed jar which the application project uses in my test project

    In Short I am trying to use a library [signed jar] present in the Application Project in my test project.

    Please let me know if it could work by any way

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s