Take the 2-minute tour ×

My issue is that I'm trying to mock BluetoothDevice for some testing, but it's a final class. So, to mock it with PowerMock, I have to use the @PrepareForTest annotation. However, when I say @PrepareForTest({BluetoothDevice.class}), I get an exception. Here's the first few lines of the error output:

java.lang.ArrayStoreException: sun.reflect.annotation.TypeNotPresentExceptionProxy
at sun.reflect.annotation.AnnotationParser.parseClassArray(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseArray(Unknown Source)
at sun.reflect.annotation.AnnotationParser.parseMemberValue(Unknown Source)

And here's the code that I'm using (the tests still need to be filled out, I was just reducing variables):

@PrepareForTest({ BluetoothDevice.class })
public class BluetoothCommTest {
    public void testBluetoothComm() {
        fail("Not yet implemented");

Thanks for the help!

share|improve this question
add comment

1 Answer

up vote 1 down vote accepted

I figured out what was going on. I was following the instructions on this page, and the android.jar they provided was out of date, and didn't include the Bluetooth libraries.

To fix this, I used Powermock 1.2.5 and the android.jar that was included with the Android 15 SDK.

share|improve this answer
add comment

Your Answer


