gpt4 book ai didi

android - Cordova:错误:必须在Application上下文中查找WIFI_SERVICE,否则在
转载 作者:行者123 更新时间:2023-12-03 05:00:05 24 4
gpt4 key购买 nike

尝试构建我的应用时出现以下错误:

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
我正在使用节点v6.11.2,cordova 6.5.0和cordova-android 6.4.0和gradle 4.1

最佳答案

Github issue中所述,使用已弃用的api-22分支将导致此错误,因为不再维护该错误。从master分支切换到使用发行版,它将通过cordova-android@6.4.0和Gradle 4很好地构建。
cordova-diagnostic-plugincordova-android@6.4.0的master分支都向后兼容API 16。

关于android - Cordova:错误:必须在Application上下文中查找WIFI_SERVICE,否则在<Android N,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/47315928/

24 4 0

Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com