Comments (6)
怀疑是缓存引起,但是uniapp android sdk提供的api 简直少的可怜
from uni-app.
贴一个我的解决方案把
就官方这个态度,issue 提了那么久都不理,其他的不多说。主要思路就是清理 uniapp 在 Android 本地的缓存
注意:此代码为 android 原生代码,kotlin 实现,不是 js 代码
//找到 uniapp 在 Android 的目录,不同版本的系统这个目录可能不同,但是思路都是一样的
val file = File(requireContext().filesDir, "apps/你的 uniapp 的 id")
if (file.exists()){
val isDelSuccess = FileUtil.deleteDirectoryFiles(file.path)
}
/**
* 删除目录下的文件
*
* @param dir
* 要删除的目录的文件路径
*
* @return 目录删除成功返回true,否则返回false
*/
public fun deleteDirectoryFiles(dir: String): Boolean {
var path = dir
// 如果dir不以文件分隔符结尾,自动添加文件分隔符
if (!path.endsWith(File.separator))
path += File.separator
val dirFile = File(path)
// 如果dir对应的文件不存在,或者不是一个目录,则退出
if (!dirFile.exists() || !dirFile.isDirectory) {
// println("删除目录失败:" + dir + "不存在!")
return false
}
var flag = true
// 删除文件夹中的所有文件包括子目录
val files = dirFile.listFiles()
if (files != null && files.isNotEmpty()) {
for (i in files.indices) {
// 删除子文件
if (files[i].isFile) {
flag = deleteFile(files[i].absolutePath)
if (!flag)
break
} else if (files[i].isDirectory) {
flag = deleteDirectory(
files[i]
.absolutePath
)
if (!flag)
break
}// 删除子目录
}
}
return flag
}
from uni-app.
贴一个我的解决方案把 就官方这个态度,issue 提了那么久都不理,其他的不多说。主要思路就是清理 uniapp 在 Android 本地的缓存
//找到 uniapp 在 Android 的目录,不同版本的系统这个目录可能不同,但是思路都是一样的 val file = File(requireContext().filesDir, "apps/你的 uniapp 的 id") if (file.exists()){ val isDelSuccess = FileUtil.deleteDirectoryFiles(file.path) }
/** * 删除目录下的文件 * * @param dir * 要删除的目录的文件路径 * * @return 目录删除成功返回true,否则返回false */ public fun deleteDirectoryFiles(dir: String): Boolean { var path = dir // 如果dir不以文件分隔符结尾,自动添加文件分隔符 if (!path.endsWith(File.separator)) path += File.separator val dirFile = File(path) // 如果dir对应的文件不存在,或者不是一个目录,则退出 if (!dirFile.exists() || !dirFile.isDirectory) { // println("删除目录失败:" + dir + "不存在!") return false } var flag = true // 删除文件夹中的所有文件包括子目录 val files = dirFile.listFiles() if (files != null && files.isNotEmpty()) { for (i in files.indices) { // 删除子文件 if (files[i].isFile) { flag = deleteFile(files[i].absolutePath) if (!flag) break } else if (files[i].isDirectory) { flag = deleteDirectory( files[i] .absolutePath ) if (!flag) break }// 删除子目录 } } return flag }
应该没有不理,你发的帖子中就引用了我跟进的一个帖子中给的临时方案。目前已经确定是缓存问题,给出临时方案后已经转给了其他相关人员处理。
你的这个方案是否经过验证,如果验证过的话,我一并转给相关人员参考。
from uni-app.
@zhetengbiji 目前已经验证过了,我们现在就常用这个方法
from uni-app.
@zhetengbiji 目前已经验证过了,我们现在就常用这个方法
这部分逻辑你们是怎么什么时机使用?安装wgt之前吗?
from uni-app.
@zhetengbiji 我们的场景是打包 wgt 解压放assets 里,算是离线了,这部分逻辑放在app 启动的时候,比如启动页或者主页相关的生命周期中判断,比如 onCreate中,我们的项目结构是这样,见下图
from uni-app.
Related Issues (20)
- 微信小程序uni-easyinput设置bindnicknamereview回调方法无效 HOT 1
- [TypeError] {message: "(0 , _tslib.__spreadArray) is not a function"} HOT 1
- uni.getRecorderManager() 在鸿蒙 next 上调不起录音或者无效果 HOT 5
- Uniapp 如何请求鸿蒙 next 相关的权限 HOT 1
- targetSdkVersion升级到34后,fcm消息推送点击后,plus.push.addEventListener("receive",function) 和plus.push.addEventListener("click",function)无法触发
- vue3 setup scirpt语法使用onShareAppMessage不生效 #3084
- 除H5端以外,sass的api配置无效 HOT 3
- webpack5使用内置缓存,页面和组件的json文件的usingComponents为空
- 头条小程序在 v-for 循环遍历时 事件绑定错误 ! HOT 5
- uniapp/小程序怎么判断出蓝牙设备的类型,例如 耳机、打印机这种的类型 HOT 1
- Vue3版本,针对H5是否有嵌套路由、动态添加路由页面功能 HOT 1
- 微信小程序,showModal在安卓手机上,返回上一层会直接消失
- 微信小程序,showModal在安卓手机上,返回上一层会直接消失 HOT 1
- ios web-view内嵌h5,通过uni.getSystemInfoSync()获取的windowHeight与app的不一致 HOT 3
- vue3 微信小程序,v-if 元素上的点击事件触发错误 HOT 1
- 关于在分包内引入插件代码包,目前支付宝已支持分包中引入插件包。
- app.vue 页面跳转不触发 HOT 1
- vue3 vite配置了 vue: "vue/dist/vue.esm-bundler.js", does not provide an export named 'injectHook' HOT 1
- vue3-cli项目依赖更新后无法正常构建
- 定位失败: {"status":348,"message":"参数错误,以下参数不合法:location","request_id":"b04f11079fa84f32b57a0d780387922e"} HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from uni-app.