Skip to content Skip to sidebar Skip to footer

How To Correct A 'instrumentation Run Failed Due To 'java.lang.illegalargumentexception''

I am working on a course project that deals with notifications,Asynctasks, and broadcast Recievers. i have three tests to run, the first test fails with the stack trace error of: T

Solution 1:

You have to check if mRefreshReciver is null in onPause method

if(mRefreshReceiver != null)
{
unregisterReceiver(mRefreshReceiver);
}

This will solve your problem and test will pass ;)

Solution 2:

You have not initialized mRefreshReciver in onPause().

Try to initialize mRefreshReceiver regardless to mIsFresh on ensureData().

Solution 3:

On top of the mRefreshReceiver check that Ivan has mentioned, you need to add a null check for mCallback as well in onPostExecute():

if (mCallback != null) {
    mCallback.notifyDataRefreshed(strings);
}

Post a Comment for "How To Correct A 'instrumentation Run Failed Due To 'java.lang.illegalargumentexception''"