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

Posible memory leak in version 2.3.10-api-22 #253

Closed
hugomenesesp opened this issue Nov 16, 2017 · 6 comments
Closed

Posible memory leak in version 2.3.10-api-22 #253

hugomenesesp opened this issue Nov 16, 2017 · 6 comments

Comments

@hugomenesesp
Copy link

When signing APK with the new version of Cordova (6.4.0), there's a error because a posible memory leak:

:lintVitalRelease<ROUTE_TO_PROJECT>/platforms/android/src/cordova/plugins/Diagnostic.java:167: Error: The WIFI_SERVICE must be looked up on the Application context or memory will leak on devices < Android N. Try changing this.cordova.getActivity() to this.cordova.getActivity().getApplicationContext() [WifiManagerLeak]
                modeName = "unknown";
^
/Users/hugo/Documents/GIT/appmimovistar/platforms/android/src/cordova/plugins/Diagnostic.java:218: Error: The WIFI_SERVICE must be looked up on the Application context or memory will leak on devices < Android N. Try changing this.cordova.getActivity() to this.cordova.getActivity().getApplicationContext() [WifiManagerLeak]
        Intent settingsIntent = new Intent(Settings.ACTION_WIFI_SETTINGS);
                     ^

   Explanation for issues of type "WifiManagerLeak":
   On versions prior to Android N (24), initializing the WifiManager via
   Context#getSystemService can cause a memory leak if the context is not the
   application context. Change context.getSystemService(...) to
   context.getApplicationContext().getSystemService(...).

2 errors, 0 warnings

That new version of Cordova uses Gradle 4.1, older versions use 2.14.1

@hugomenesesp
Copy link
Author

Related Stackoverflow thread: https://stackoverflow.com/a/47319534/1583507

@dpa99c
Copy link
Owner

dpa99c commented Nov 16, 2017

Your are explicitly using the v2.3.10-api-22 tag of the api-22 branch which is deprecated and (as documented) is no longer maintained.

The api-22 branch was created at the time that API 23 (Android 6.0 Marshmallow) had just been released and many developers had not yet updated their code to use Android run-time permissions. Android apps should by now be updated to handle run-time permissions on Android and therefore this branch is no longer necessary.

Instead use the npm releases from the master branch which has been updated to fix the stricter checks under Gradle 4 and so will build fine with [email protected], which targets API 26.

@dpa99c dpa99c closed this as completed Nov 16, 2017
@hugomenesesp
Copy link
Author

The problem is that my app needs to be compatible from API 19, will it work?

@dpa99c
Copy link
Owner

dpa99c commented Nov 16, 2017

cordova-android@6:

Minimum Supported Android Version is Jellybean (API 16/ Android 4.1)

@dpa99c
Copy link
Owner

dpa99c commented Nov 16, 2017

i.e. both this plugin and [email protected] are backwardly-compatible to API 16

@hugomenesesp
Copy link
Author

hugomenesesp commented Nov 17, 2017

The fix should be the same as #251
Solution seems to be ok

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

No branches or pull requests

2 participants