davidmartos96 / sqflite_sqlcipher

SQLite flutter plugin
BSD 2-Clause "Simplified" License
102 stars 46 forks source link

Release APK shows missing method implementation error #32

Closed joshmark-novade closed 3 years ago

joshmark-novade commented 3 years ago

Hello!

First off, big ups on this package, its great!

However, I've been experiencing an issue while attempting to run a release apk of my app. Specifically release, both profile and debug seem to be OK.

I'm getting the foll. error:

No implementation found for method getDatabasesPath on channel com.davidmartos96.sqflite_sqlcipher

Any fixes for this would be much appreciated. Also, if I can provide additional details on my end, please let me know.

flutter doctor -v output

[✓] Flutter (Channel beta, 1.25.0-8.1.pre, on macOS 11.1 20C69 darwin-x64, locale en-GB) • Flutter version 1.25.0-8.1.pre at /Users/joshuamarkfurtado/Public/development/flutter • Framework revision 8f89f6505b (3 weeks ago), 2020-12-15 15:07:52 -0800 • Engine revision 92ae191c17 • Dart version 2.12.0 (build 2.12.0-133.2.beta)

[✓] Android toolchain - develop for Android devices (Android SDK version 30.0.2) • Android SDK at /Users/joshuamarkfurtado/Library/Android/sdk • Platform android-30, build-tools 30.0.2 • Java binary at: /Applications/Android Studio.app/Contents/jre/jdk/Contents/Home/bin/java • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495) • All Android licenses accepted.

[✓] Xcode - develop for iOS and macOS (Xcode 12.3) • Xcode at /Applications/Xcode.app/Contents/Developer • Xcode 12.3, Build version 12C33 • CocoaPods version 1.10.0

[✓] Chrome - develop for the web • Chrome at /Applications/Google Chrome.app/Contents/MacOS/Google Chrome

[✓] Android Studio (version 4.1) • Android Studio at /Applications/Android Studio.app/Contents • Flutter plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/9212-flutter • Dart plugin can be installed from: 🔨 https://plugins.jetbrains.com/plugin/6351-dart • Java version OpenJDK Runtime Environment (build 1.8.0_242-release-1644-b3-6915495)

[✓] VS Code (version 1.52.1) • VS Code at /Applications/Visual Studio Code.app/Contents • Flutter extension version 3.18.0

[✓] Connected device (1 available) • Chrome (web) • chrome • web-javascript • Google Chrome 87.0.4280.88

• No issues found!

davidmartos96 commented 3 years ago

@joshmark-novade Glad to hear the package is being useful to you!

Have you configured your project with the following instructions?

https://github.com/davidmartos96/sqflite_sqlcipher/blob/master/sqflite/README.md#android

Also, it would be great to know in what platform are you getting the error. Android or iOS? Edit: I've noticed that you mentioned APK in the title.

joshmark-novade commented 3 years ago

Hey @davidmartos96 yeah, we did the setup just like your readme says. Also, it works on debug and profile modes.

davidmartos96 commented 3 years ago

@joshmark-novade Is by any chance your project somewhat "old"? It may have something to do with the new Android plugin embedding API. Could you try the example project in the repository? It's under "sqflite/example" I have just tried it and it works fine in release mode with Flutter 1.22

https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects

davidmartos96 commented 3 years ago

@joshmark-novade Here is a relevant thread on the topic, but with normal sqflite https://stackoverflow.com/questions/62890116/missingpluginexceptionno-implementation-found-for-method-getdatabasespath-on-c

davidmartos96 commented 3 years ago

@joshmark-novade Were you able to get it working?

joshmark-novade commented 3 years ago

Hey @davidmartos96 still working on it. The SqflitePlugin is registered as part of the GeneratedPluginRegistrant, so I don't think the solution from that link is valid here.

I'll try downgrading to Flutter v1.22, lets see if that helps.

joshmark-novade commented 3 years ago

Hey @davidmartos96 unfortunately, this looks like a problem on every version from 1.22 to 1.26. I've confirmed that the setup is as instructed, and the plugin is registered. Not sure what the next step should be, as it persists as an issue specifically on release versions of our Android app.

davidmartos96 commented 3 years ago

@joshmark-novade That's odd. The release version on Android ka working fine for me on the example project inside the repo and on my app using Flutter 1.22 Could you try the example project? You could also try recloning your project on a different folder and see if it has something to do with some temporary build file.

davidmartos96 commented 3 years ago

Hey @davidmartos96 still working on it. The SqflitePlugin is registered as part of the GeneratedPluginRegistrant, so I don't think the solution from that link is valid here.

I'll try downgrading to Flutter v1.22, lets see if that helps.

Here you mention that SqflitePlugin is registered but this plugin is called SqfliteSqlcipherPlugin. Was this a typo? Sqflite plugin may be registered still if you use other dependencies that use it under the hood, like cache_network_image.

https://github.com/davidmartos96/sqflite_sqlcipher/blob/09c3a65a14869c7d036b6c9acc46ab4806c9a32c/sqflite/android/src/main/java/com/davidmartos96/sqflite_sqlcipher/SqfliteSqlCipherPlugin.java#L108

In any case you should look into the new way in which the plugins get registered with the app. Take a look at this migration guide: https://github.com/flutter/flutter/wiki/Upgrading-pre-1.12-Android-projects

joshmark-novade commented 3 years ago

Apologies for that @davidmartos96, that was indeed a typo. However, I can confirm that both SqflitePlugin and SqfliteSqlCipherPlugin are registered as part of the GeneratedPluginRegistrant as shown below.

public final class GeneratedPluginRegistrant {
  public static void registerWith(@NonNull FlutterEngine flutterEngine) {
    ShimPluginRegistry shimPluginRegistry = new ShimPluginRegistry(flutterEngine);
    flutterEngine.getPlugins().add(new io.flutter.plugins.camera.CameraPlugin());
    flutterEngine.getPlugins().add(new io.flutter.plugins.connectivity.ConnectivityPlugin());
    flutterEngine.getPlugins().add(new io.flutter.plugins.deviceinfo.DeviceInfoPlugin());
    flutterEngine.getPlugins().add(new com.jrai.flutter_keyboard_visibility.FlutterKeyboardVisibilityPlugin());
    flutterEngine.getPlugins().add(new io.flutter.plugins.flutter_plugin_android_lifecycle.FlutterAndroidLifecyclePlugin());
    flutterEngine.getPlugins().add(new com.it_nomads.fluttersecurestorage.FlutterSecureStoragePlugin());
    flutterEngine.getPlugins().add(new vn.hunghd.flutter.plugins.imagecropper.ImageCropperPlugin());
    flutterEngine.getPlugins().add(new io.flutter.plugins.imagepicker.ImagePickerPlugin());
    flutterEngine.getPlugins().add(new com.vitanov.multiimagepicker.MultiImagePickerPlugin());
      io.scer.pdf.renderer.NativePdfRendererPlugin.registerWith(shimPluginRegistry.registrarFor("io.scer.pdf.renderer.NativePdfRendererPlugin"));
    flutterEngine.getPlugins().add(new com.crazecoder.openfile.OpenFilePlugin());
    flutterEngine.getPlugins().add(new io.flutter.plugins.pathprovider.PathProviderPlugin());
    flutterEngine.getPlugins().add(new com.tekartik.sqflite.SqflitePlugin());
    flutterEngine.getPlugins().add(new com.davidmartos96.sqflite_sqlcipher.SqfliteSqlCipherPlugin());
    flutterEngine.getPlugins().add(new eu.simonbinder.sqlite3_flutter_libs.Sqlite3FlutterLibsPlugin());
    flutterEngine.getPlugins().add(new name.avioli.unilinks.UniLinksPlugin());
  }
}
joshmark-novade commented 3 years ago

Hey @davidmartos96, looks like I found a fix that worked for me.

Following the steps described in this article did the trick! (https://stackoverflow.com/questions/63766058/flutter-issues-with-release-mode-only-apk-builds)

But seriously man, thanks so much for being so helpful with this! You freaking rule!

davidmartos96 commented 3 years ago

@joshmark-novade Awesome! Happy to hear that you got it working.