Reputation: 902
I am currently developing an Ionic app with Capacitor. Strangely, the apk produces unexpected results.
This happened fairly often. Let me describe what I do.
When building the apk, I first make sure to delete the server
key in capacitor.config.json. It is written there when I use Ionic Live Reload.
Then I use following commands to build the apk:
ionic build
ionic cap copy
ionic cap sync
ionic cap open android
Before I click the Play Button to install the app on my device, I go to my settings and clear the cache and data of the app, followed by a uninstallation of the app.
Then I install the new app on my phone. But strangely there are old values and also some old values from the internal database.
How could this happen? What am I doing wrong?
Here is my 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": []
}
}
Upvotes: 3
Views: 1920
Reputation: 63
I had the same problem. I solved it by deleting the android
and dist
folder inside the ionic app. Then I ran:
npm run build
ionic capacitor add android
ionic capacitor open android’
Update: You can also without deleting the folders do the following steps:
npm run build
npx cap sync
ionic capacitor open android
(In android studio) sync project with gradle files
Upvotes: 5
Reputation: 902
I found the problem.
In the Android Manifest, setandroid:allowBackup="false"
. Its true by default and will load some old data when its not set to false.
Upvotes: 0