My app works perfectly:
On browser, both locally and deployed
On emulator, using either the local or deployed server
On my device when using run android-device, using either the local or deployed server
But somehow, when I build it following these instructions, at the first server call, for example:
console.log("test1");
Meteor.call("someMethod", function (error, result) {
console.log("test2");
});
// yes I know how asynchronous calls work
console.log("test3");
Or:
console.log("test1");
Meteor.loginWithPassword("validUsername", "validPassword", function (error, result) {
// should print no matter if the credentials are good or bad anyway
console.log("test2");
});
console.log("test3");
"test2" does not get printed in the adb logcat, even though "test1" and "test3" do. There is a mapbox map that loads fine, so it's not an internet access issue. Also, startup works:
Meteor.startup(function () {
console.log("this gets printed in the adb console");
});
So it's not ALL Meteor methods. I used both my deployed and local server: there were no errors reported on the server log. I also tested hot-code push on my local server, it does reload the app on my phone! But only the first time I launch the app only after it's freshly installed. Still, there is at least some kind of connection between them.
I should also mention that I already built this app and it worked fine before, but I did not build it in a while and now it doesn't work anymore. I installed the package on two different devices and get the exact same issue.
Here is my package list if it can help, all on the latest version available:
meteor-platform
iron:router
sacha:spin
accounts-password
accounts-base
mdg:geolocation
mrt:flash-messages
mdg:camera
useraccounts:ratchet
fastclick
alanning:roles
tap:i18n
simple:imgur
Here are the client's logs when I launch it on my local server:
I/CordovaLog(18991): Changing log level to DEBUG(3)
I/CordovaLog(18991): Found start page location: index.html
D/CordovaLog(18991): file:///android_asset/www/meteor_cordova_loader.js: Line 12 : METEOR CORDOVA DEBUG (meteor_cordova_loader.js) Error reading version file Error: Failed to resolve entry: file:///data/data/com.idz9099616fhad1150nrz/files/meteor/version
D/CordovaLog(18991): file:///android_asset/www/meteor_cordova_loader.js: Line 12 : METEOR CORDOVA DEBUG (meteor_cordova_loader.js) Couldn't load from the manifest, falling back to the bundled assets.
D/CordovaLog(18991): file:///android_asset/www/meteor_cordova_loader.js: Line 12 : METEOR CORDOVA DEBUG (meteor_cordova_loader.js) Loading from url: http://meteor.local
D/CordovaLog(18991): http://meteor.local/d7372e9a56ce9d5ddfb0fea0d5e071cfd699fac8.js: Line 111 : show showSignInLink signIn
These are all before I hit "Sign In" on my app. That last statement is just a log print from the useraccounts:ratchet package that occurs everywhere. As soon as I hit "Sign in": blank page, and zero output on the logs. (that's due to the fact that I can never actually stop logging in, as we saw earlier) The above log remains as it is forever.
When using the app installed with run android-device, it's the same exact output, except that after I click, the next page shows up and everything works fine. (logging works, as everything else) As with the non-functionning app, no more log lines show up. (except when I start using the app as usual)
What really bugs me is that it works perfectly fine on my phone when I install the app using run android-device. Even when I stop the debug and use this build as a standalone app, it works flawlessly! But I cannot decently ask users to install my app using meteor run, can I?
From the information you've provided it looks like you have a race condition issue in your code. I'm not assured this is what it is, but the characteristic of the problem you're describing makes it quite likely.
On your local server it doesn't pop up because the connection is fairly instantaneous, but on a remote server it's more of an issue since the data may not yet be ready due to the higher latency.
Basically you have something like this in your code, or a variation in some way:
var doc = MyCollection.findOne();
return doc.name
The thing is MyCollection.findOne() is null (since the data has not yet loaded). This calls up a cannot read 'name' of undefined error (client side not server side) and this halts the execution of further code, which is why your screen is white and the subscriptions aren't run.
How to find where this is exactly. Try and get access to adb to view the client side logs on the device or view and login with xxx.meteor.com/your deployed server on your web browser and keep an eye on the JS console to find where it pops up. The key thing to reproduce the issue is a slower connection to the server than that available on your localhost
The fix is simply accounting for a lack of data, i.e return doc && doc.name instead of return doc.name or if(doc != null) return doc.name;
Related
I have been using the cordova-plugin-media-capture plugin for some time now without any problems on Android and iOS.
Except under Android 9 or after closing the camera (with or without video to return) the webview restarts.
I searched everywhere in the github issues of the plugin and on this forum but without success...
I also have trouble understanding what's happening with the logs because as soon as the application restarts I have the process that switch to "DEAD" status and so I no longer have the logs in Android Studio.
I may have help with
https://developer.android.com/about/versions/oreo/android-8.0-changes#back-all
or https://developer.android.com/about/versions/pie/android-9.0-changes-28
I would like to point out that this does not work even if I disable battery optimization from the parameters.
Here was the code I use :
var captureSuccess = function(mediaFiles) {
// didn't reach this code
}.bind(this);
var captureError = function(error) { };
navigator.device.capture.captureVideo(captureSuccess, captureError, {limit:1, duration:60});
Did you have any ideas?
EDIT 1 :
At the end of the README of cordova-plugin-media-capture we can read this :
When capturing audio, video, or images on the Android platform, there
is a chance that the application will get destroyed after the Cordova
Webview is pushed to the background by the native capture application.
I'm affraid about it cause i use ExtJS framework which are unable (or i don't know how) to save and restore state at the resume event...
Do you know how to avoid the apps to be destroyed ?
Sir, same problem with me
tried everything other than searching in forums :)
but i think it is a issue with cordova only,
tried this
navigator.device.capture.captureVideo(captureSuccess, captureError, {limit:1, duration:60});
but there is now acceptance (right tick/ accept this) to invoke call the onSuccess function from the UI after capture options work perfectly
Successfully worked on Android 6,7,8 on emulator
but getting error on android 9 on personal mobile device (nokia 6.1)
Hoping you have this issue if possible....
getting this error after catching error on console after pressing back after recording video
{code: 3, message: "Canceled."}
code: 3
message: "Canceled."
proto: Object
hope somethings gets resolved...
I have a node/express/socket.io app. When i run the app on android 4 and previous, it works just fine. However, with android 5.0+ and greater, every time my app loads and does its initial route (/), it sends the route function twice. The second time it executes, there is nothing in the request body, which is causing the app to error out.
app.post('/', someFunction);
Ive logged this function req.url and notice it is hitting someFunction twice for android 5.0+, but anything previous only hits it once and executes normally.
Does anyone have thoughts on to why this would be caused on new versions of android? and not others? Also to mention, this works just fine with iOS.
The problem was not related to sockets.io. It had to do with how the newer android OS web view handles some JS. In my EJS templates associated with that route, I have a
window.location.reload();
This works great with iOS and older android OS's, but the new versions didn't like it. I was able to switch to:
window.location.href = window.location.href;
And this seems to work just dandy.
I have an android application that I have recently finished. So I have successfully finished each function and ensured that no errors are encountered.
When I have exported it to an apk file. It runs smoothly. It uses httpRequests to communicate with a remote mySQL server. But there are times that it spontaneously crashes?
For example, I have an activity that would receive input from the user then communicate with the server. It runs smoothly and quickly. But on next run it would crash. And when I restart the application it would run smoothly again even on the second run. I'm just going crazy from this. Are there any explanations for these?
Use ACRA to collect crash reports from your app. You don't need your own server, just a Google Docs form. The integration is described here:
https://github.com/ACRA/acra/wiki/BasicSetup#wiki-Setting-up_your_project
The advantage of using a crash report tool vs. logcat is that you don't need physical access to the device. There are also chances that you see crashes that you or your testers didn't even notice.
The first step to debugging your problem is to get a stack trace. If you can reproduce this on your own device, then right after you see a crash, connect it to your dev pc and run this command:
adb logcat > crash.log
Open the log file, copy and paste its contents on http://pastebin.com/ or similar and add the link to your question. Once we have that, we can try to figure out what's going on.
On Android I am using the android.util.Log to log within my application and during development I am using the adb logcat or Eclipse to see the logs - I use it even more then debugging...
On device I can save the logfile from my code or use some application form Android Market to save the logs - e.g. aLogCat.
Now can I do the same on the iPhone? I can use the NSLog(#"message");, but can I easily save the log file from my application and access it? Are there any ways for that?
Regards,
STeN
This is from NSFoundation reference
NSLog:
Simply calls NSLogv, passing it a variable number of arguments.
NSLogv:
Logs an error message to the Apple System Log facility (see man 3 asl). If the STDERR_FILENO file descriptor has been redirected away from the default or is going to a tty, it will also be written there. If you want to direct output elsewhere, you need to use a custom logging facility.
Thus, it is only a matter of redirecting the file-descriptor "stderr" (2) to a custom file, and you will get everything that you print using NSLog in that file.
This seems to be exactly what you want.
Note that if you want to get logs on console when you are connected to the debugger, you can wrap your code around this to avoid redirection in this case:
if (!isatty(STDERR_FILENO)) { // Not connected to any terminal
// your redirection code
}
You can access the console log from Organizer->Device->Your device->console.
If that is not powerful enough, consider using utilities like NSLogger.
The previous answers are good; also see this if you're inclined to making system calls.
I have an application built using PhoneGap (Android) that is essentially a shell for a web app, that would (in the future) allow for push notifications and offline reading of downloaded pages from the web app.
My problem is this - if the connection to the network is lost or turned off in the middle of use, and a link is clicked on a page, there is an error: Application Error: Could not find url: '...', and the app closes. I want to be able to prevent the app from closing, and if possible, change this error message.
I know that the standard would be to use the PhoneGap API to check the network connection, then handle it myself, but because this is a shell for a web App, the only place I can do this is on app startup. What are my options?
I would start by checking out the source code for the childbrowserplugin.
The code there for onlocationchange is allowing for intercepting all webrequests in and out of a webview. It sounds like your app has needs similar to this.
For that you have to add the permissions for wifi,Gps,Internet into the Android Manifest file. While you have to add the code for checking the Internet Connection available condition into you code as well..
If both the connection doesnot fullfills then try to add the toast message that Internet connection is not available..
I think your problem will definitely be solved...