Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

java.lang.RuntimeException: Failed to extractAlpha on Bitmap #2795

Closed
zhengxiaopeng opened this issue Jan 3, 2017 · 2 comments
Closed

java.lang.RuntimeException: Failed to extractAlpha on Bitmap #2795

zhengxiaopeng opened this issue Jan 3, 2017 · 2 comments
Assignees
Milestone

Comments

@zhengxiaopeng
Copy link

extractAlpha on bitmap

stacktrace:

java.lang.RuntimeException: Failed to extractAlpha on Bitmap

	at android.graphics.Bitmap.extractAlpha(Bitmap.java:1512)
	at android.graphics.Bitmap.extractAlpha(Bitmap.java:1479)
	//...
	at android.app.Activity.performCreate(Activity.java:5243)
	at org.robolectric.util.ReflectionHelpers.callInstanceMethod(ReflectionHelpers.java:195)
	at org.robolectric.util.ActivityController$1.run(ActivityController.java:126)
	at org.robolectric.shadows.ShadowLooper.runPaused(ShadowLooper.java:356)
	at org.robolectric.shadows.CoreShadowsAdapter$2.runPaused(CoreShadowsAdapter.java:40)
	at org.robolectric.util.ActivityController.create(ActivityController.java:123)
	at org.robolectric.util.ActivityController.create(ActivityController.java:133)
	at org.robolectric.util.ActivityController.setup(ActivityController.java:227)
	at org.robolectric.Robolectric.setupActivity(Robolectric.java:102)
	at com.xxx.xxx.xxx.testXXX(XXX.java:39)
	at org.junit.runners.model.FrameworkMethod$1.runReflectiveCall(FrameworkMethod.java:50)
	at org.junit.internal.runners.model.ReflectiveCallable.run(ReflectiveCallable.java:12)
	at org.junit.runners.model.FrameworkMethod.invokeExplosively(FrameworkMethod.java:47)
	at org.junit.internal.runners.statements.InvokeMethod.evaluate(InvokeMethod.java:17)
	at org.robolectric.RobolectricTestRunner$HelperTestRunner$1.evaluate(RobolectricTestRunner.java:498)
	at org.junit.internal.runners.statements.RunBefores.evaluate(RunBefores.java:26)
	at org.junit.internal.runners.statements.RunAfters.evaluate(RunAfters.java:27)
	at org.robolectric.RobolectricTestRunner$2.evaluate(RobolectricTestRunner.java:245)
	at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:171)
	at org.robolectric.RobolectricTestRunner.runChild(RobolectricTestRunner.java:47)
	at org.junit.runners.ParentRunner$3.run(ParentRunner.java:290)
	at org.junit.runners.ParentRunner$1.schedule(ParentRunner.java:71)
	at org.junit.runners.ParentRunner.runChildren(ParentRunner.java:288)
	at org.junit.runners.ParentRunner.access$000(ParentRunner.java:58)
	at org.junit.runners.ParentRunner$2.evaluate(ParentRunner.java:268)
	at org.robolectric.RobolectricTestRunner$1.evaluate(RobolectricTestRunner.java:137)
	at org.junit.runners.ParentRunner.run(ParentRunner.java:363)
	at org.junit.runner.JUnitCore.run(JUnitCore.java:137)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:119)
	at com.intellij.junit4.JUnit4IdeaTestRunner.startRunnerWithArgs(JUnit4IdeaTestRunner.java:42)
	at com.intellij.rt.execution.junit.JUnitStarter.prepareStreamsAndStart(JUnitStarter.java:234)
	at com.intellij.rt.execution.junit.JUnitStarter.main(JUnitStarter.java:74)
	at com.intellij.rt.execution.application.AppMain.main(AppMain.java:144)

Steps to Reproduce

        //1. setup activity
        Robolectric.setupActivity(MyActivity.class);
        //2. extractAlpha in MyActivity's onCreate method
        Bitmap bmp = BitmapFactory.decodeResource(context.getResources(),id);
        Bitmap mAlphaBitmap = Bitmap.createBitmap(bmp.getWidth(), bmp.getHeight(), Config.ARGB_8888);
        Canvas mCanvas = new Canvas(mAlphaBitmap);
        Paint mPaint = new Paint();
        mPaint.setColor(mColor);
        Bitmap alphaBitmap = bmp.extractAlpha();
        mCanvas.drawBitmap(alphaBitmap, 0, 0, mPaint);

Robolectric & Android Version

testCompile 'org.robolectric:robolectric:3.1.2'
testCompile 'org.robolectric:shadows-support-v4:3.1.2'
Build.VERSION_CODES.KITKAT(19)
@jongerrish jongerrish self-assigned this Nov 14, 2018
@jongerrish jongerrish added this to the 4.1 milestone Nov 14, 2018
@jongerrish
Copy link
Contributor

Have an fix for this as part of forthcoming fix for #4028

@jongerrish
Copy link
Contributor

1c1fe55

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants