jblejder opened a new issue #1164: URL: https://github.com/apache/cordova-android/issues/1164
# Bug Report ## Problem After upgrade AGP to 4.1.0 our cordova based solution started to crash on Debug builds. ### What is expected to happen? Not crash ;) ### What does actually happen? We use Cordova in a way where we provide [PluginEntry](https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/PluginEntry.java#L51) with existing instance of CordovaServices. This started to crash after we upgraded to AGP 4.1.0 from assertions [HERE](https://github.com/apache/cordova-android/blob/master/framework/src/org/apache/cordova/CordovaPlugin.java#L52) Turns out AGP 4.1.0 changed config so all assertions will always throw on debug builds >**Assertions in debug builds** >When you build the debug version of your app using Android Gradle plugin 4.1.0 and higher, the built-in compiler (D8) will >rewrite your app's code to enable assertions at compile time, so you always have assertion checks active. source: [AGP release notes](https://developer.android.com/studio/releases/gradle-plugin#4.1-debug-assertions) ## Information So far I found out that plugins provided from outside are initialized twice here [CordovaWebViewImpl:init](https://github.com/apache/cordova-android/blob/3081e5e6e91c32e507423411196b184325baa935/framework/src/org/apache/cordova/CordovaWebViewImpl.java#L97) First is when PluginManager is created on [L:103](https://github.com/apache/cordova-android/blob/3081e5e6e91c32e507423411196b184325baa935/framework/src/org/apache/cordova/CordovaWebViewImpl.java#L103) As `plugin.entry` is not null it is initialised here first time <img width="647" alt="Screen Shot 2021-02-17 at 11 31 02 am" src="https://user-images.githubusercontent.com/17861372/108191625-75642680-7167-11eb-9538-5e2412960e8c.png"> Right arter this in `CordovaWebViewImpl:init` calls [pluginManager.init()](https://github.com/apache/cordova-android/blob/3081e5e6e91c32e507423411196b184325baa935/framework/src/org/apache/cordova/CordovaWebViewImpl.java#L117) which basically initialize plugins again and causes assertion to fail. What more I found is that if only `PluginEntry.load` could be set to false if plugin instance is provided it would not initialize them twice. Not sure if it breaks something else though. It seems like a bug to me but if it's not please tell me what is the proper way to provide instances of plugin from outside. ### Environment, Platform, Device Android, Any ### Version information 8.1.0 - because it's last version that supports android 21 ## Checklist - [x] I searched for existing GitHub issues - [x] I updated all Cordova tooling to most recent version - [x] I included all the necessary information above ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: [email protected] --------------------------------------------------------------------- To unsubscribe, e-mail: [email protected] For additional commands, e-mail: [email protected]
