I have created a React Application via Expo CLI, while I run something via:
yarn web
I am able to open a QR code, and Switch to Tunnel and open that application via my Personal Android Device, it renders fine. But I have to make any changes, and I spin the server again using the same command, it does not seem to refresh content. It does refresh on Web, but does not on Android.
I have gone through few SO's posts and seen that we need a Hot Reload to serve contents dynamically. But when I shake the phone rigorously, I do not find any thing such as Hot Reload to enable it.
This is what I am getting:
I need two things now so to unblock me:
How to enable Hot Reload?
How can I rebuild the package so that I can access the latest from Android mobile
I used expo start instead of yarn web,
And it has helped me in auto reloading
Related
In the capacitor app we are developing for Android we load the entire app from a url using server.url in capacitor.config.json.
Our app is a single-spa application which loads angular apps as multiple microfrontends. We build our app using the commands:
npm run build (this builds the root config for single-spa)
npx cap sync android
npx cap open android
then build APK using Android Studio
Then we try doing the following code in one of our angular components. It is done to conditionally implement some platform specific logic in component.
import { Capacitor } from '#capacitor/core';
console.log(Capacitor.isNative);
//this logs "true" when loading the app after clearing app data or loading app for first time
//but logs "false" when reloading the webview using chrome debugger or when closing app and opening again(without clearing data)
In our case the Capacitor.isNative field changes from being true to false after reloading using chrome debugger or closing and opening app again. Is there something extra we have to do to make sure that Capacitor recognizes the App as a native app? Anybody has any idea as to why the Capacitor object changes after we reload the page?
We have tried using other Capacitor APIs for detecting platform like Capacitor.getPlatform() and Capacitor.platform. Both of these change from "android" to "web" after reopening app or reloading the page using chrome debugger.
We have also seen similar behavior when trying to load other Capacitor Plugins wherein the plugin object changes its structure(i.e. presumably the web implementation gets loaded instead of Android specific implementation) after the page is reloaded or app is restarted. Has anybody faced issues similar to this?
I'm using Phonegap Build for my application. I wonder is there any way to clear ALL app data (not just localStorage or cache) in my app? I have some problems with relogin in my app for Android. When I do localStorage.clear(), it seems like Android doesn't clean data. I also tried to clean cache at that moment (using cordova-plugin-cache-clear plugin). But if I clean app data manually (in phone`s settings) it works perfectly. Otherwise I have conflicts when I try to login again, as if Android use some old previous data. Other platforms work ok.
localStorage.clear should do it (I've used it successfully).
Normally I don't use it though, as (obviously) it cleans out everything.
So, for individual credentials, options and such I use localStorage.removeItem.
There's no need to clear the cache. localStorage calls have immediate effect, at least from the app's point of view.
Without seeing the login code it's hard to be more specific.
You can use this plugin to clear App data for Android and iOS apps:
https://github.com/dpa99c/cordova-plugin-clear-data
Another way, is using ionic framework. There is $ionicHistory.clearCache() which will clear app data.
When change the code and run in borwser by
cordova run browser
and haven't any change, then use:
cordova build
and run again:
cordova run browser
I know theres a few posts on this site regarding this error message but my issue doesn't seem to be answered by any of the solutions.
I am debugging my React Native app using my Android testing phone. Everything works correctly until I start using "Debug JS Remotely" with Chrome's React Native Debugger. That is when Chrome gives me this error. I do not have any other packages running and my AppRegistry has the correct name.
Edit: I restarted my computer and I managed to get Chrome React Native Debugger working without this error. However, upon reloading the app this error starts to pop up again.
Edit: Another thing to note, my application is working correctly when I'm not using Chrome's debugger. I have live reloading on and my app updates upon making changes to my files. This issue only appears when I turn on Remote JS Debugger.
in two situations this will happen:
1: when your development server is not up so try this:
react-native start
2: otherwise try this in terminal react-native run-android
Make sure that the packager is running from same directory as the app.
Make sure that the string in MainActivity.java matches the string in index.android.js.
I am currently usings chromes fantastic Inspect Devices to debug my phonegap app.
However every single time I build the app and deploy to my phone I will get the following message:
Detached from the target etc
Is it possible to get Chrome to auto reload so I don't have to keep opening
Settings -> More Tools -> Inspect Devices
As far I know, at this moment it is possible to do it only by reload page. It will reload the code (HTML, js, CSS), but the history of WebView will not be cleared. By that I mean that if your app start on "http://start", and you are currently on url "http://a/b" and do reload, you will be now on "http://start", but click on back will not terminate app, you will be redirected on "http://a/b". If that is not problem, then relaod is your solution. Regards.
I want to clear localStorage for my app each time I install it from Eclipse to simulate installing the app for the first time.
How can I do this?
Thanks!
I answered this, specifically for Android, here - Programmatically clear PhoneGap/Cordova app's cache on Android to simulate a fresh install?
There are no hooks in Eclipse, but you could probably do this with Ant. You can add a task that executes the clear command (pm clear my.package) before uploading the app. If pm clear does not work, you can write a small script and start it on the device before uploading the app
There is also the Android run configuration's 'Wipe user data' checkbox, but it only works on emulator startup.
I'm using Chrome inspector (chrome://inspect) which very nicely shows the connected Android device. From there you can just hit Resources to access and modify the localStorage
I am not sure if you want it programmatically or via ADB - in any case this should solve it
How to programmatically clear application data
For testing purposes, you can drop a quick local storage clear statement:
localStorage = ""
Make sure to remove this before release.