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

Support for Configuring Model Path on Android 14+ #15

Closed Vinayak0-0 closed 1 month ago

Vinayak0-0 commented 2 months ago

Description: I am using the flutter_gemma package in my Flutter application, and I've encountered a challenge when trying to use the library on devices running Android 14. The library currently requires the model to be located in /data/local/tmp/, but due to enhanced security restrictions in Android 14, writing to this path is no longer permitted for non-system apps, resulting in a Permission denied error.

Steps to Reproduce:

  1. Use the flutter_gemma package in a Flutter application targeting Android 14.
  2. Attempt to copy a model file to /data/local/tmp/ as required by the package.
  3. Observe the error: PathAccessException: Cannot copy file to '/data/local/tmp/', (OS Error: Permission denied, errno = 13).

Expected Behavior: The application should be able to load the model from a path that is accessible without elevated permissions on Android 14, such as app-specific storage (/data/user/0/<package_name>/files/).

Proposed Solution:

Vinayak006 commented 2 months ago

I’ve submitted a PR to initialize the model with a custom path for Android.

You can check it out here: PR #18.

DenisovAV commented 1 month ago

Thank you, PR is merged, check the 0.2.2 version