Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MissingPluginException on release build #452 #546

Conversation

Boehrsi
Copy link

@Boehrsi Boehrsi commented Nov 14, 2020

Initially I tried to -keep just the whole package and played around with the rules. After some tries I got it working and tried to move the rules from my actual app project to the library directly. During this process I realized not the -keep rule for the package alone was the fix, but also the usage of getDefaultProguardFile('proguard-android-optimize.txt') which I applied during testing.
I also tested getDefaultProguardFile('proguard-android.txt') and it wasn't working, so I just diffed both and got the needed rule by trial and error. Lastly I also removed the -keep rule itself and funny enough it was still working.

How to easily test in an app

Update pubspec.yaml

# sqflite: ^1.3.2+1 replace the actual production import with the following direct Git branch import
  sqflite:
    git:
      url: git://github.com/Boehrsi/sqflite.git
      path: sqflite
      ref: 452_MissingPluginExceptionOnReleaseBuilds

Create a minified build, e.g. by just enabling it in debug builds:

buildTypes {
        debug {
            minifyEnabled true
            shrinkResources true
        }
    }

To ensure the new stuff is really used some rounds of flutter clean or gradlew clean could be helpful.

Additional information

…or method getDatabasesPath on channel com.tekartik.sqflite) tekartik#452
@alextekartik
Copy link
Contributor

Sorry I somehow did not notice this pull request. Would it possible to apply the minify configuration on the example apps in release mode in the same project (either the one in sqflite/example or the one in sqlite_test_app or both!) so that I have a way to validate easily that it works (even if this might sound obvious for you)? Thanks!

@Boehrsi
Copy link
Author

Boehrsi commented Nov 26, 2020

No problem and yep should be possible, I will have a look later today. I will update the PR 👍 .

@alextekartik
Copy link
Contributor

thanks @Boehrsi !

@Boehrsi
Copy link
Author

Boehrsi commented Nov 26, 2020

It seems to be more complicated to reproduce this issue than I initially thought. I tried for the last hours to provoke the error in the example app of the project and within a newly created Flutter example app. And I wasn't able to do so, so my assumption that this is a general problem is refuted. I would say this is good in general, but quite strange in regards to the issue itself, as I wasn't able to pin point the actual configuration which leads to the error.

As my own project is affected I tried to copy Gradle configurations, dependencies, plugin embedding setups and multiple other parts to find the problem, but nothing helped. If time allows I will continue testing during the weekend.

@Boehrsi
Copy link
Author

Boehrsi commented Nov 26, 2020

@alextekartik I think I made some progress. It's lets say "complicated".

Some findings:

This explains why only some people encounter the problem. To minimize external sources I created a fresh new test app, where I just added sqflite: ^1.3.2+1 and image_picker: ^0.6.7+14 and I called openDatabase which then lead to the error. I will add this flow tomorrow to the PR, so you can have a look via the sqflite example app.

@@ -35,6 +35,7 @@ android {
defaultConfig {
minSdkVersion 16
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
consumerProguardFiles 'proguard-rules.txt'
Copy link
Author

@Boehrsi Boehrsi Nov 27, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you comment out this line you will see the problematic MissingPluginException(No implementation found for method getDatabasesPath on channel com.tekartik.sqflite) exception. With the Proguard rules everything should work.

@Boehrsi
Copy link
Author

Boehrsi commented Nov 27, 2020

Even though this seems to fix the symptoms, somebody with more insights should probably verify why there is a problem at all and what is the cause. I can't really tell to be honest why this rules fixes the problem.

@alextekartik
Copy link
Contributor

I'm still puzzled by what to do here yet. Maybe adding documentation regarding minification (although I don't have much clue) could help. I'm going to close this pull request for now, sorry.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants