DenisovAV / flutter_gemma

The Flutter plugin allows running the Gemma AI model locally on a device from a Flutter application.
MIT License
55 stars 17 forks source link

PlatformException in Release Mode: Failed to initialize Gemma with FlutterGemmaPlugin #13

Closed Vinayak0-0 closed 2 months ago

Vinayak0-0 commented 2 months ago

Description: I'm encountering a PlatformException when trying to initialize FlutterGemmaPlugin in release mode. The same code works fine in debug mode, but fails in release mode with the following error:

PlatformException(ERROR, Failed to initialize gemma, Field modelPath_ for t0.b not found. Known fields are [private int t0.b.h, private java.lang.String t0.b.i, private java.lang.String t0.b.j, private int t0.b.k, private int t0.b.l, private int t0.b.m, private float t0.b.n, private int t0.b.o, private static final t0.b.q], null)
DenisovAV commented 2 months ago

Thank you, I'll take a look, could you give a bit more details, which platform, which model and etc

Vinayak0-0 commented 2 months ago

@DenisovAV, we encountered that issue while trying to use the gemma-2b-it-gpu-int4 model on Android 11. The problem was later resolved by adding the following to the build.gradle file:

buildTypes {
    release {
        ...
        minifyEnabled false
        shrinkResources false
    }
}

However, we're not certain if this is a good approach.