Invalid Layer Save Flag - only ALL_SAVE_FLAGS is allowed android API 28+

Asked

Viewed 110 times

-2

I’m having this problem after changing the targetSdkVersion of 25 for 28, I am having to make this change because it is necessary this sdk to publish in the google store.

To exception generated:

java.lang.IllegalArgumentException: Invalid Layer Save Flag - only ALL_SAVE_FLAGS is allowed
        at android.graphics.Canvas.checkValidSaveFlags(Canvas.java:442)
        at android.graphics.Canvas.saveLayer(Canvas.java:519)
        at com.mikepenz.materialdrawer.view.BezelImageView.onDraw(BezelImageView.java:209)
        at android.view.View.draw(View.java:22213)
        at android.view.View.updateDisplayListIfDirty(View.java:21089)
        at android.view.View.draw(View.java:21944)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4419)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4180)
        at android.view.View.updateDisplayListIfDirty(View.java:21080)
        at android.view.View.draw(View.java:21944)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4419)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4180)
        at android.view.View.updateDisplayListIfDirty(View.java:21080)
        at android.view.View.draw(View.java:21944)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4419)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4180)
        at android.view.View.updateDisplayListIfDirty(View.java:21080)
        at android.view.View.draw(View.java:21944)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4419)
        at android.widget.ListView.drawChild(ListView.java:3613)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4180)
        at android.widget.AbsListView.dispatchDraw(AbsListView.java:2668)
        at android.widget.ListView.dispatchDraw(ListView.java:3608)
        at android.view.View.draw(View.java:22216)
        at android.widget.AbsListView.draw(AbsListView.java:4369)
        at android.view.View.updateDisplayListIfDirty(View.java:21089)
        at android.view.View.draw(View.java:21944)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4419)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4180)
        at android.view.View.draw(View.java:22216)
        at android.view.View.updateDisplayListIfDirty(View.java:21089)
        at android.view.View.draw(View.java:21944)
        at android.view.ViewGroup.drawChild(ViewGroup.java:4419)
        at android.support.v4.widget.DrawerLayout.drawChild(DrawerLayout.java:1379)
        at android.view.ViewGroup.dispatchDraw(ViewGroup.java:4180)
        at android.view.View.updateDisplayListIfDirty(View.java:21080)
        at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4403)
        at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4376)
        at android.view.View.updateDisplayListIfDirty(View.java:21049)
        at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4403)
        at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4376)
        at android.view.View.updateDisplayListIfDirty(View.java:21049)
        at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4403)
        at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4376)
        at android.view.View.updateDisplayListIfDirty(View.java:21049)
        at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4403)
        at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4376)
        at android.view.View.updateDisplayListIfDirty(View.java:21049)
        at android.view.ViewGroup.recreateChildDisplayList(ViewGroup.java:4403)
        at android.view.ViewGroup.dispatchGetDisplayList(ViewGroup.java:4376)
        at android.view.View.updateDisplayListIfDirty(View.java:21049)
        at android.view.ThreadedRenderer.updateViewTreeDisplayList(ThreadedRenderer.java:559)
        at android.view.ThreadedRenderer.updateRootDisplayList(ThreadedRenderer.java:565)
        at android.view.ThreadedRenderer.draw(ThreadedRenderer.java:642)
        at android.view.ViewRootImpl.draw(ViewRootImpl.java:4058)
        at android.view.ViewRootImpl.performDraw(ViewRootImpl.java:3785)
        at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:3060)
        at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1888)
        at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:8122)
        at android.view.Choreographer$CallbackRecord.run(Choreographer.java:972)
        at android.view.Choreographer.doCallbacks(Choreographer.java:796)
2020-04-13 13:16:46.209 31317-31317/br.com.desen.amauditores E/AndroidRuntime:     at android.view.Choreographer.doFrame(Choreographer.java:731)
        at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:957)
        at android.os.Handler.handleCallback(Handler.java:907)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:216)
        at android.app.ActivityThread.main(ActivityThread.java:7464)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:549)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:955)

I noticed that in class BezelImageView.java there is a call to saveLayer:

cacheCanvas.saveLayer(mBoundsF, mMaskedPaint,
                        Canvas.HAS_ALPHA_LAYER_SAVE_FLAG | Canvas.FULL_COLOR_LAYER_SAVE_FLAG);

But this class cannot be changed to default ALL_SAVE_FLAGS

Someone’s been through it and could help me?

1 answer

0

You are using an outdated version of com.mikepenz.materialdrawer. Doing a little digging on their Github, I found this Issue where the repository maintainer says

Those flags are no longer applied in recent versions.

Please update the Materialdrawer.

See the available versions and update your gradle accordingly.

Follow the migration guide step by step. See your current version and compare it to a newer version to know what has changed. The migration guide has several examples like "rename X to Y".

With this, you can get to a version that doesn’t have this problem (apparently, the older version without this problem is the v6.0.9). I strongly recommend doing the step-by-step version most recent (v8.0.0 in the migration guide) to fix possible bugs that you haven’t noticed yet and avoid new migration problems by having such an old version.

  • I’m using a very old version: Compile('com.mikepenz.materialdrawer:library:2.9.8@Aar') { transitive = true } When I try to migrate to a newer version: Compile group: 'com.mikepenz', name: 'materialdrawer', version: '8.0.1' provides me another error: C: Users hcs01.android build-cache bb3a14d3dfbcfbe9711ebec71497bfb1b45d6b70 output res font materialdrawerfont_font_v5_0_0.ttf: Error: The file name must end with . xml

  • Take a look at the migration guide, which I put in the answer. Migrate from one version to another, not from 2.9.8 to the 8.0.1. When migrating, make a clear build of your project, read in the guide what you need to change in code and see if there is an error. Do this progressively until you reach the desired version.

  • Okay, I’ll read the migration guide, thank you.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.