Ionic-APK构建总是产生具有旧值的旧APK



我目前正在开发一款带有电容器的Ionic应用程序。奇怪的是,apk产生了意想不到的结果。

这种情况经常发生。让我描述一下我的工作。

在构建apk时,我首先确保删除capacitor.config.json中的server密钥。它是在我使用Ionic Live Reload时写的。

然后我使用以下命令来构建apk:

  1. ionic build

  2. ionic cap copy

  3. ionic cap sync

  4. ionic cap open android

在单击"播放"按钮在设备上安装应用程序之前,我会转到我的设置并清除应用程序的缓存和数据,然后卸载应用程序。

然后我在手机上安装了新的应用程序。但奇怪的是,内部数据库中既有旧值,也有一些旧值。

这怎么会发生?我做错了什么?

这是我的package.json:

{
"name": "OrgAtwork_mobile",
"version": "0.08.06",
"author": "Ionic Framework",
"homepage": "https://ionicframework.com/",
"scripts": {
"ng": "ng",
"start": "ng serve --proxy-config proxy.conf.json",
"build": "ng build",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/cdk": "^10.2.0",
"@angular/common": "^10.0.14",
"@angular/core": "^10.0.14",
"@angular/flex-layout": "^10.0.0-beta.32",
"@angular/forms": "^10.0.14",
"@angular/platform-browser": "^10.0.14",
"@angular/platform-browser-dynamic": "^10.0.14",
"@angular/router": "^10.0.14",
"@capacitor/android": "^2.4.1",
"@capacitor/core": "^2.4.0",
"@capacitor/ios": "^2.4.0",
"@ionic-native/core": "^5.28.0",
"@ionic-native/http": "^5.29.0",
"@ionic-native/launch-navigator": "^5.28.0",
"@ionic-native/native-storage": "^5.28.0",
"@ionic-native/screen-orientation": "^5.28.0",
"@ionic-native/splash-screen": "^5.28.0",
"@ionic-native/sqlite": "^5.28.0",
"@ionic-native/status-bar": "^5.28.0",
"@ionic/angular": "^5.3.2",
"@types/hammerjs": "^2.0.36",
"@types/underscore": "^1.10.24",
"add": "^2.0.6",
"cordova-plugin-actionsheet": "^2.3.3",
"cordova-plugin-advanced-http": "^3.1.0",
"cordova-plugin-app-preferences": "^0.99.3",
"cordova-plugin-dialogs": "^2.0.2",
"cordova-plugin-file": "^6.0.2",
"cordova-plugin-geolocation": "^4.0.2",
"cordova-plugin-nativestorage": "^2.3.2",
"cordova-plugin-screen-orientation": "^3.0.2",
"cordova-sqlite-storage": "^5.0.1",
"es6-promise-plugin": "^4.2.2",
"hammerjs": "^2.0.8",
"ionic-long-press": "^2.0.3",
"js-sha256": "^0.9.0",
"moment": "^2.27.0",
"moment-range": "^4.0.2",
"rxjs": "^6.6.3",
"rxjs-compat": "^6.6.3",
"sha.js": "^2.4.11",
"tslib": "^2.0.1",
"uk.co.workingedge.phonegap.plugin.launchnavigator": "^5.0.4",
"underscore": "^1.11.0",
"zone.js": "~0.10.3"
},
"devDependencies": {
"@angular-devkit/build-angular": "^0.1100.2",
"@angular/cli": "^10.0.8",
"@angular/compiler": "^10.0.14",
"@angular/compiler-cli": "^10.0.14",
"@angular/language-service": "^10.0.14",
"@capacitor/cli": "2.3.0",
"@ionic/angular-toolkit": "^2.3.3",
"@types/jasmine": "^3.5.14",
"@types/jasminewd2": "~2.0.8",
"@types/node": "^14.6.4",
"@types/uuid": "^8.3.0",
"codelyzer": "^6.0.0",
"cordova-plugin-ionic-keyboard": "^2.2.0",
"cordova-plugin-ionic-webview": "^4.2.1",
"cordova-plugin-splashscreen": "^5.0.2",
"cordova-plugin-statusbar": "^2.4.2",
"cordova-plugin-whitelist": "^1.3.3",
"jasmine-core": "~3.5.0",
"jasmine-spec-reporter": "~5.0.2",
"karma": "^5.1.1",
"karma-chrome-launcher": "~3.1.0",
"karma-coverage-istanbul-reporter": "~3.0.3",
"karma-jasmine": "~3.3.1",
"karma-jasmine-html-reporter": "^1.5.4",
"protractor": "~7.0.0",
"ts-node": "~8.10.2",
"tslint": "^6.1.3",
"typescript": "~3.9.7"
},
"description": "An Ionic project",
"cordova": {
"plugins": {
"cordova-plugin-whitelist": {},
"cordova-plugin-statusbar": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-ionic-keyboard": {}
},
"platforms": []
}
}

我也遇到了同样的问题。我通过删除ionic应用程序中的androiddist文件夹解决了这个问题。然后我跑了:

npm run build
ionic capacitor add android
ionic capacitor open android’

更新:您也可以在不删除文件夹的情况下执行以下步骤:

npm run build
npx cap sync
ionic capacitor open android
(In android studio) sync project with gradle files

我发现了问题。

在Android清单中,设置android:allowBackup="false"。默认情况下为true,并且在未设置为false时将加载一些旧数据。

最新更新