question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Hello,

I recently bumped my application to API 28, when launching the application, the following below crashes within the ColorPickerView.

Using these dependencies crash the app implementation ‘com.android.support:design:28.0.0-rc01’ implementation ‘com.android.support:appcompat-v7:28.0.0-rc01’

Going down to API 27 works fine, not sure if the new dependencies once they get out of RC will still cause issues.

08-09 20:23:22.157 8630-8630/? E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.lossydragon.arduinorgb, PID: 8630
    java.lang.IllegalArgumentException: x must be < bitmap.width()
        at android.graphics.Bitmap.checkPixelAccess(Bitmap.java:1780)
        at android.graphics.Bitmap.getPixel(Bitmap.java:1728)
        at com.skydoves.colorpickerpreference.ColorPickerView.getColorFromBitmap(ColorPickerView.java:215)
        at com.skydoves.colorpickerpreference.ColorPickerView.setSelectorPoint(ColorPickerView.java:313)
        at com.skydoves.colorpickerpreference.ColorPickerView.onFirstLayout(ColorPickerView.java:111)
        at com.skydoves.colorpickerpreference.ColorPickerView.access$000(ColorPickerView.java:40)
        at com.skydoves.colorpickerpreference.ColorPickerView$1.onGlobalLayout(ColorPickerView.java:102)
        at android.view.ViewTreeObserver.dispatchOnGlobalLayout(ViewTreeObserver.java:945)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:2358)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1460)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:7184)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:949)
        at android.view.Choreographer.doCallbacks(Choreographer.java:761)
        at android.view.Choreographer.doFrame(Choreographer.java:696)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:935)
        at android.os.Handler.handleCallback(Handler.java:873)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)

Thanks,

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

3reactions
skydovescommented, Sep 24, 2018

It’s fixed at version 1.0.5. @acorbin3 Thank you for your contribution!

2reactions
effleuragercommented, Sep 16, 2018

@skydoves I found the issue:

private int getColorFromBitmap(float x, float y) {
        if (paletteDrawable == null) return 0;

        Matrix invertMatrix = new Matrix();
        palette.getImageMatrix().invert(invertMatrix);

        float[] mappedPoints = new float[]{x, y};
        invertMatrix.mapPoints(mappedPoints);

        if (palette.getDrawable() != null && palette.getDrawable() instanceof BitmapDrawable &&
                mappedPoints[0] > 0 && mappedPoints[1] > 0 &&
                mappedPoints[0] < palette.getDrawable().getIntrinsicWidth() && mappedPoints[1] < palette.getDrawable().getIntrinsicHeight()) {

            invalidate();
            return ((BitmapDrawable) palette.getDrawable()).getBitmap().getPixel((int) mappedPoints[0], (int) mappedPoints[1]);
        }
        return 0;
    }

In the non-zero return statement, palette.getDrawable() will return a drawable with the dimensions relative to whatever the display size is. In Android P, the call to .getBitmap() will return the size of the original bitmap, which is 730×730.

You’ll have to interpolate the mapped points, or multiply the points with a scaling factor in the .getPixel() call.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Behavior changes: apps targeting API level 28+
Android 9 (API level 28) introduces a number of changes to the Android system. The following behavior changes apply exclusively to apps that ......
Read more >
Fetch not working on Android 9 API 28 · Issue #24627 - GitHub
Bug Report Hello, I'm having an Issue about a HTTP service (the error only in simulator with API 28 (Pie) environment).
Read more >
What to use in Android API 28 now that fragments are ...
It's only native fragments that are being deprecated. Use the compatibility library fragments and all will be well.
Read more >
App crashes with API 28 on Android 8.0 - Fuse Community
it crashes or it simply wont start on Android 8. I read in the forum that time ago this behaviour was due to...
Read more >
Sailfish API 28 benchmarks are especially noisy ... - Issue Tracker
Sailfish API 28 benchmarks are especially noisy. 1. Hotlists Mark as Duplicate ... We may have a problem generally with Sailfish 28 being...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found