'Flutter 1.9: D/skia ( 5106): Shader compilation error

I've created a simple Flutter 1.9.1+hotfix.4 application using Android Studio 3.5.1. After adding successfully a new virtual device (Nexus 6) and tried to run my app, I got this error:

Launching lib\main.dart on Android SDK built for x86 in debug mode...
Initializing gradle...
Resolving dependencies...
Running Gradle task 'assembleDebug'...
Built build\app\outputs\apk\debug\app-debug.apk.
Syncing files to device Android SDK built for x86...
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/EGL_emulation( 5106): eglMakeCurrent: 0xec5ed840: ver 3 1 (tinfo 0xec593810)
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 
D/skia    ( 5106): Shader compilation error
D/skia    ( 5106): ------------------------
D/skia    ( 5106): Errors:
D/skia    ( 5106): 

The application runs correctly but the console shows the errors above.

My Configuration:

Android Studio 3.5.1

Build #AI-191.8026.42.35.5900203, built on September 25, 2019

JRE: 1.8.0_202-release-1483-b03 amd64

JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o

Windows 10 Pro 64bits



Solution 1:[1]

I solved my Shader compilation error by changing emulator's settings.

Press that ... button which is located on the side panel of emulator, and go to Settings section. There, go to Advanced tab and change OpenGL ES API level to Compatibility (OpenGL ES 1.1/2.0).

Do not forget to close and rerun the emulator after this change. On the first run, emulator could pop a warning on its screen and it would take a while to get ready, but do not worry.

Solution 2:[2]

The error message comes from: Add ShaderErrorHandler to GrContextOptions

In the previous Flutter versions, the persistent cache had been disabled to remedy the problem. However, it is currently enabled in the Fllutter engine: Revert "Disable the persistent cache

Possible solutions:

  • Downgrade your Flutter version to the linked commit
  • Enable rendering flutter run --enable-software-rendering
  • Disable hardware acceleration in the emulator

Issue:

8578 Shader compilation error

Solution 3:[3]

Open the terminal, Navigate to your folder and

Type flutter run --enable-software-rendering after that debug and run again.

This worked for me and it might help you too!

Solution 4:[4]

I was facing the same issue.Use flutter clean and then run the app. This fixed mine.

Solution 5:[5]

I had the same problem, once I wrapped the widget in Scaffold , the problem is solved.

Solution 6:[6]

It happened to me when I tested in Emulator. My Emulated Performance used to set to Automatic, which in my case it runs using Hardware - GLES 2.0. Changing it to Software - GLES 2.0 solves this issue.

Where to find the setting: Open Android Studio, open AVD manager, click the edit icon that looks like a pencil on your virtual device. There you'll find this setting.

Solution 7:[7]

Please add --enable-software-rendering to

[Edit Configurations...] > [Additional arguments] 

and it should be fixed

Solution 8:[8]

it happened because of your emulator, run the app on a real device, then run it again on your emulator. I did that, and fix my problem.

Solution 9:[9]

Maybe following technique works: If you are using android studio there are one test folder. In that folder if you click on auto solve option it create one class what is causing error. In my case it was myapp() and it is solved. maybe it works. Let me know if it works.

Solution 10:[10]

My code was 4170 shader compilation error,

I solved that by just moving the fonts folder of ( the custom fonts specifically icons as they also are the same ) at the root directory. The path should look like this-

fonts:
     - family: MyIconClass
       fonts:
           - asset: fonts/myIcons.ttf

Solution 11:[11]

Open Emulator(SDKPHONE) , Going to ... button at bottom (image reference) => Settings section => go to Advanced tab and change both to Auto (image reference). Choosing Direct X 11 and other settings would take more memory space. Changing Open GL ES renderer to Angle DX 11, Open GS EL API level to Render maximum 3.1 will also work but it will take up more memory space. Hence it's better to select auto.

Note: first of all you must confirm that flutter is fully updated with plugins(dart and flutter).

After that disconnect your emulator from studio, close the emulator, restart your emulator and build your apk. Hope this will work fine.