Cordova 10 不支持目标 SDK 版本

Posted

技术标签:

【中文标题】Cordova 10 不支持目标 SDK 版本【英文标题】:Target SDK Version is not supported in Cordova 10 【发布时间】:2021-12-21 21:12:51 【问题描述】:

当我们尝试将目标 sdk 版本 29 更改为 30 时。出现以下错误。

This should work as is when targeting API 28 (now forbidden by Google Play)
This should work when targeting API 29 with the dev version of the plugin (which has the android:requestLegacyExternalStorage="true"), alternatively you can use the edit-config to add this flag.
This won't work when targeting API 30, as API 30 ignores the android:requestLegacyExternalStorage attribute.
It's important to read the Android Notes before you target API 30. You may need to migrate your files to another folder to maintain access to them when targeting API 30 using the new APIs.

有没有办法解决这个问题。提前致谢!

【问题讨论】:

【参考方案1】:

花了两天时间后,我们得到了一个解决科尔多瓦 API 级别 30 外部存储问题的解决方案。

我在 CordovaActivity.java 的 init() 函数中做了一点修改。

protected void init() 
appView = makeWebView();
createViews();
if (!appView.isInitialized()) 
appView.init(cordovaInterface, pluginEntries, preferences);

/********** MODIFICATION SDK 30 **********/
WebView webView = (SystemWebView)(appView.getEngine().getView());
WebSettings webSettings = webView.getSettings();
webSettings.setAllowFileAccess(true);
/**********************************/
cordovaInterface.onCordovaInit(appView.getPluginManager());
// Wire the hardware volume controls to control media if desired.
String volumePref = preferences.getString("DefaultVolumeStream", "");
if ("media".equals(volumePref.toLowerCase(Locale.ENGLISH))) 
setVolumeControlStream(AudioManager.STREAM_MUSIC);


【讨论】:

它的工作。谢谢!

以上是关于Cordova 10 不支持目标 SDK 版本的主要内容,如果未能解决你的问题,请参考以下文章