-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Issues in release build when minifyEnabled is set to true #739
Comments
"And we noticed that for some reason Plugins.App.openUrl stops to work in release version. It just doing nothing." Interesting since I have an issue opened regarding openUrl. |
@solojuve1897 did you try it with |
In release also |
Turned out that issues disappear if set in I can only wonder why minification of the APK results in such issues. |
Are you talking about |
Yes, I meant We've set it to
yeap, we do not use any Cordova plugins. Only pure Capacitor, without any additions |
It's probably related to minifyEnabled enabling proguard, which obfuscates the code and that can make the plugin execution code not work. |
First, thank you Capacitor team for the amazing work you guys do!! |
Here my
It could be put here and, as an embedded library proguard file, should be handled by any android/capacitor project. Maybe it could be optimized but it does the job for me 😄! |
@Rajarml How would you allow for a Cordova plugin in proguard-rules.pro? Would adding this work?
|
I would also like to know this. I moved my project from Cordova to Capacitor and it is something like 2.5MB bigger than the Cordova version. I would really like to be able to enable minifying. |
I had a similar issue. I mixed the above solutions to make my application work with the minifyEnabled. I will test this solution heavily. Probably
|
I have build problems too, with 'minifyEnabled=true'. I working on Capacitor version 3 with Ionic (V5) and Angular (V11).
and than: java.lang.RuntimeException: Unable to start activity ComponentInfo{xxx/xxx.MainActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void g.a.a.g.q(java.lang.String, g.a.a.e, g.a.a.j, g.a.a.h)' on a null object reference |
Hi @hschindler Native api in capacitor has changed.
EDIT: Added directives for permissions and activities result:
If older (v2) plugins are present, this also should be added:
And, if Cordova plugins are still present:
Tested on fresh project created with ionic cli with Capacitor v3, angular v12 and ionic v5 |
@Zapominacz yep this works. Just upgraded our app from capacitor 2 to 3. Ran into the white screen of death when doing a release build on android with minifyEnabled. After updating the proguard-rules.pro with the v3 version, it now works fine. |
Hmm, the app builds, and the plugins work, but on fresh install, the app no longer prompts for permissions. The error I am seeing in logcat is If I set minifyEnabled false, it prompts for permissions as expected |
Ok, it looks I need to add proguard directive for one more annotation - will look at it shortly |
So, it looks like if you manually request permissions for geolocation it works fine. However, if you do NOT manually request, and try to use geolocation, it will just fail. Looks like that is the same with file permissions. I have not tried manually requesting that yet, but guessing it will be the same. So if minifyEnable is true, you want to make sure to manually request permissions. If this can be resolved due to a proguard change, that would be preferable, just so you would not have to change any code, but it looks like there is a way around it. |
Looks like I found another one, looks like it may be multiple call back methods, not just related to permissions. Just dropping this here as it may be relevant. This was triggered using capacitor camera plugin on capacitor 3, trying to select image from gallery.
This was after manually requesting, and granting permissions. |
@Jesspu This should do the job for v3 - I will test it soon. I forgot about two added annotations. Replace the "v3 part" of the solution above for this:
|
Ok, i removed |
Thanks so much, will test in the morning. Really appreciate you looking at
this.
Question, should this be merged into the base capacitor proguard file? That
would probably save others from having to chase down this issue in the
future.
Or maybe just put in the docs on the Android configuration page.
…On Thu, Jun 24, 2021, 5:21 PM Mikołaj Styś ***@***.***> wrote:
Ok, i removed public constraint as these methods can be private. Tested
on fresh project located here:
https://github.com/Zapominacz/issue_capacitor_739 Hope it will work now :)
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#739 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAUN6P3ECNKV3HBRGXXHO2TTUOVVXANCNFSM4FP3FUFQ>
.
|
@Zapominacz works great. Thanks so much! |
We still had issues with some plugins (e.g. Geolocation) after applying the fix suggested by @Zapominacz. Adding this line to our
So the full file looks like this:
|
The proguard-rules should be added by default maybe? Or atleast added to the docs? Seems like a common issue on Android |
The proguard rules that were added to Capacitor should cover proguard issues with Capacitor core and the plugin interfaces. If we missed one of those plugin interfaces in the Core project then we could get that fixed. If there is a specific Capacitor core plugin that needs a rule added, we are interested in resolving that issue with a particular plugin in the https://github.com/ionic-team/capacitor-plugins repo, but this issue was focusing on addressing proguard rules for Capacitor core only.
|
Thanks for the issue! This issue is being locked to prevent comments that are not relevant to the original issue. If this is still an issue with the latest version of Capacitor, please create a new issue and ensure the template is fully filled out. |
Capacitor version
1.0.0-beta.4
Platform
Android
Issue
Strangely, many Capacitor elements behave differently in
release
build.For instance, with
debug
we don't have any issues, whilerelease
builds getting few crashes during testing all the time:For instance, my friend's Galaxy S6 Android 6.0 (debloated, not stock) always crashing on launch with
release
version, but not withdebug
.Another issue with
navigator.geolocation
described in #738And we noticed that for some reason
Plugins.App.openUrl
stops to work inrelease
version. It just doing nothing.I'm sure there also other issues specific to the
release
build. It makes me feel there some kind of global issue withrelease
build in Capacitor.What can I do to help debug those issues?
The text was updated successfully, but these errors were encountered: