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

Obfuscated apk does not work in Flutter 2.2.0+, worked in Flutter 1.22.6 #10

Open
gazialankus opened this issue Aug 22, 2021 · 1 comment · May be fixed by #11
Open

Obfuscated apk does not work in Flutter 2.2.0+, worked in Flutter 1.22.6 #10

gazialankus opened this issue Aug 22, 2021 · 1 comment · May be fixed by #11

Comments

@gazialankus
Copy link

I build my apk with obfuscation
flutter build apk --obfuscate --split-debug-info=debuginfo_to_deobfuscate

With this, the background service's persistent notification appears when using Flutter 1.22.6. After upgrading to Flutter 2.2.0, the persistent notification stopped appearing and the app does not work in the background anymore. I set minifyEnabled false in app/build.gradle in case it's R8 that's the problem.

Doing either one of the things below make the persistent notification appear again:

  • build using flutter build apk, without obfuscation
  • downgrade Flutter to 1.22.6
@gazialankus
Copy link
Author

This is a very curious case. When obfuscation is enabled the parameter comes in as an Int. So, as Long fails.
image
Changing it toval callbackRawHandle = (method.arguments as Int).toLong() works in this case.

However, you cannot bulid without obfuscation anymore as it comes in as a Long. So, as Int fails now. You have to change it back to as Long again...
image

So I did this and it works both in obfuscated and non-obfuscated builds:

                    val callbackRawHandle = if (method.arguments is Long)
                        method.arguments as Long
                    else
                        (method.arguments as Int).toLong() // flutter build apk --obfuscate

Will send a PR now.

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 a pull request may close this issue.

1 participant