Runtime Exception Stub! using BitmapFactory and BitmapOptions testcase


Wasted a lot of time on this. Basically I was running the below as a junit test instead of a android junit test. I modified the test case to “extend AndroidTestCase”, added stuff into the manifest
in

in

And it worked. For reference I have added the exceptions and code.

Code Example 1

try {
inputStream = (InputStream)new URL(url).openStream() ;
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
inputStream = null ;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
inputStream = null ;
}

if (inputStream == null) throw new NullPointerException() ;
mapPiece = BitmapFactory.decodeStream(new FlushedInputStream(inputStream)) ;//, null, factoryOptions);

Throws

java.lang.RuntimeException: Stub!
at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:33)

Code Example 2

try {
inputStream = (InputStream)new URL(url).openStream() ;
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
e.printStackTrace();
inputStream = null ;
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
inputStream = null ;
}

if (inputStream == null) throw new NullPointerException() ;
BitmapFactory.Options factoryOptions = new BitmapFactory.Options();
factoryOptions.inPurgeable = true;
factoryOptions.inSampleSize = 2;
mapPiece = BitmapFactory.decodeStream(new FlushedInputStream(inputStream), null, factoryOptions);

Throws

java.lang.RuntimeException: Stub!
at android.graphics.BitmapFactory$Options.(BitmapFactory.java:6)

Advertisements

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