I was wondering if it would be possible to override a method (or something like that), that will be called when the application will crash due to some exception.
I'd like to do this, so the next time the user loggs in, it gives him/her a message that the app has crashed and that the bug will be fixed as soon as possible.
Use Thread and setDefaultUncaughtExceptionHandler().
I found a simple little solution that works perfectly:
When my app is created I do something like this:
// Ceck if the app crashed last time
if(this.getIO().readPrimitiveInternalMemoryBoolean(FileNames.SpaceDroid.CrashReport) == true) {
this.getGameLog().d(classTAG, "App crashed last time");
}
else {
this.getGameLog().d(classTAG, "App didn't crash last time");
}
// Flag the app as chrashed and when the app is exited, then mark it as false.
this.getIO().writePrimitiveInternalMemory(FileNames.SpaceDroid.CrashReport, true);
When my app is being closed, then I do something like this:
#Override
public void onDispose() {
super.onDispose();
this.getIO().writePrimitiveInternalMemory(FileNames.SpaceDroid.CrashReport, false);
}
You could use a try catch statement and log info in your logs. Also google play provides a mechanism to notify you about crashes in your apps in production.
Related
Already tried to look into all different problems here on StackOverflow with related titles, like this one. But no success.
Here is the piece of code where the problem happens:
const fetchApi = useCallback(async () => {
setIsLoading(true);
if (activePortfolioId) {
try {
const response = await getApis().portfoliosApi.getPortfolioOverviewById(
activePortfolioId
);
if (response.data && response.data?.tickers?.length) {
setItems(handleListItems(response.data.tickers));
}
} catch (error) {
Sentry.Native.captureException(error);
Sentry.Native.captureMessage('HELLO?');
Alert.alert(
'Sorry!',
'We were unable to retrieve the performance list. Please try again later.'
);
} finally {
setIsLoading(false);
}
}
}, [activePortfolioId]);
So what happens is, on iOS I have no problem at all here, either on DEV or PROD, using real device or simulator, everything works fine, never went to the catch statement. On Android, using simulator or real device with Expo, it's all fine too, even using expo start --no-dev --minify to try to reproduce the app as PROD, occurs no errors at all. I have tried everything that came on my mind, like removing pieces of the code to see if the problem stops. Like instead of calling the API, just setting the items, like this:
setItems(handleListItems(response.data.tickers)); because I also thought that the problem might be with my handler function, I also tried to just do setItems([{ OBJECT HERE }]);. The problem has just stopped once I stopped setting the items. So I also tried to check my renderItem function, tried to stop using any styled component, just what React Native provides, nothing works. Then I decided to bring Sentry to my code but even with Sentry, no issues is shown there. I open the screen, it is loading, fetches the API, then it falls in the catch block, because I see the Alert on Android and then the app crashes and go back to the splash screen frozen. The only issue that appeared on Sentry was:
Could not open URL 'https://XXXXXXX': No Activity found to handle Intent { act=android.intent.action.VIEW dat=https://XXXXXXX... flg=0x10000000 }
But strangely I have never clicked on this during the "tests" and this link just appears on the login screen, shouldn't have anything to do with the problem itself, right?
I really don't know what else I could try to do and figure out what is causing this problem, so decided to ask for help and maybe find someone who already went through something similar.
Thanks!
PS: I'm using TS too, so apparently no problems with some possible undefined or whatever.
Found the issue, it was with the Intl. Solution here.
Lately, I have been trying to add static interstitial ads into my Unity game. For some reason, I could not get the system to show anything, or even react to me. After trying to work with the base Chartboost plugin, I tried to match a tutorial that I was following and purchased Prime31's Chartboost plugin and have been using that. However, neither the base plugin, nor Prime31's plugin, seem to be allowing me to show any ads. The code is pretty much done inside a single object, and it seems simple enough.
public class Advertisement : MonoBehaviour {
public string chartboostAppID = "5461129ec909a61e38b1505b";
public string chartboostAppSignature = "672b3b34e3e358e7a003789ddc36bd2bc49ea3b5";
// Use this for initialization
void Start () {
DontDestroyOnLoad(this.gameObject);
ChartboostAndroid.init (chartboostAppID, chartboostAppSignature, true);
ChartboostAndroid.cacheInterstitial(null);
}
void OnLevelWasLoaded(int level) {
ChartboostAndroid.cacheInterstitial(null);
if(Application.loadedLevelName == "Network Lobby") {
showAds();
}
}
public static void showAds() {
Debug.Log("Showing ad");
ChartboostAndroid.showInterstitial(null);
}
}
As you can see, it's pretty straightforward. This object is created at the game's splash screen, which appears only once, and it's never destroyed until the program ends. The goal is, whenever I enter the lobby scene, I want to see an ad before going to the lobby's menus. As it is, I do see the log printing "Showing ad", so I know the function is being called. However, nothing appears. Do I need to disable the GUI system first? Is there a step I'm missing?
I have already performed the following steps:
I have created and registered the app with chartboost, as well as double and triple checked the AppID and App Signature.
I have created a publishing campaign and registered it to the app.
I double-checked the orientation and confirmed that it's correct.
I registered this specific device as a test device.
The tutorial showed a call to ChartBoostAndroid.OnStart(), but there was no function like that for me to call. Perhaps that is from an older version?
I emailed Chartboost support and have not heard from them yet. I do not have that much time on this project, so if anyone can offer help, I'd appreciate it.
I have being upgrading an application to use the new Mobile Android GNSK but I have noticed that using the new MusicID-Stream is a little bit tricky. If the "identifyAlbumAsync" method get executed before the "audioProcessStart" method(since this need to be executed in a different thread), the application just crashes. In the Gracenote Demo application, the "audioProcessStart" method is continuously running so there is no need to synchronize its execution with the "identifyAlbumAsync" method call. Is it the way it is supposed to be used? It will be convenient if the application didn't crashed at least when the methods are not executed in order. Also in our application, we don't want to have the "audioProcessStart" method continuously like it is done in the demo application. We only want to run the "audioProcessStart" method when the user request identification and when the song playing gets identified , we want to stop the audio processing by calling "audioProcessStop". Is there an easy way to do this? Right now, we are getting the Thread where "identifyAlbumAsync" is running to sleep for 2 seconds in order to make sure that the Thread where the "audioProcessStart" method is supposed to run has time to get executed. Thank you in advance for your prompt response
In the upcoming 1.2 release, IGnMusicIdStreamEvents includes a callback that signals audio-processing has started, and an ID can be synced with this, e.g.:
#Override
public void musicIdStreamProcessingStatusEvent( GnMusicIdStreamProcessingStatus status, IGnCancellable canceller ) {
if (GnMusicIdStreamProcessingStatus.kStatusProcessingAudioStarted.compareTo(status) == 0) {
try {
gnMusicIdStream.identifyAlbumAsync();
} catch (GnException e) { }
}
}
Thanks for the feedback, you're right about this issue. Unfortunately right now sleeping is the best solution. But we are adding support for an explicit sync event in an upcoming release, please stay tuned.
I made a unity project and included facebook in it. Everything worked fine until I used OBB spliter.
Actually, I just wanted to share a screenshot of the game so I did this:
private void CallFBLogin()
{
print ("test");
FB.Login("email,publish_actions", LoginCallback);
StartCoroutine (TakeScreenshot ());
print ("test2");
}
When I push a button, this function is called but the problem is that the process finishes before I'm logged with Facebook. When I'm logged in, I'm already out of this function. What's the best way to log, wait to be logged and then launch the coroutine?
I haven't used the Facebook api yet so I can't give you exact code but based on what I see here you need to launch your coroutine from inside the LoginCallback function.
This way it will automatically execute after the user is logged in.
As TheValar stated, you need to do the following..
private void CallFBLogin()
{
print ("test");
FB.Login("email,publish_actions", MyLoginCallback);
print ("test2");
}
void MyLoginCallback(FBResult result)
{
// Do whatever you need, or nothing. You can check if you are logged in correctly
StartCoroutine (TakeScreenshot ());
}
This will guarantee that the take screenshot gets called after you are logged in Facebook
I've been playing around with Parse on Android for a few days, I have a problem with ParseUser.logOut() => it actually doesn't log the current user out.
Here's what I do :
private void onClickOnDisconnect() {
ParseUser.logOut();
currentUser = ParseUser.getCurrentUser(); // should be null but isn't...
invalidateOptionsMenu();
Toast.makeText(getApplicationContext(), "Disconnected...", Toast.LENGTH_LONG).show();
}
After the call to ParseUser.logOut(), ParseUser.getCurrentUser() should return null (says the documentation). Still it returns the previously logged in user.
Even though I restart the app the user is still considered as connected.
I use parse framework v1.3.8 (downloaded a 3 days ago). I don't use Facebook SDK, as I've seen a few questions for that specific case.
Thanks in advance
Somewhere in your app, probably the appDelegate you most likely send this message to the PFUserClass
[PFUser enableAutomaticUser];
in this case the
[PFUser currentUser];
will never return nil;
I had the same issue while incorporating logout functionality with facebook login. The error turned out to quite simple and a basic mistake on my part. I had written the following piece of code in my Application class
ParseUser.enableAutomaticUser();
This creates the user every time you run your application even if you have logged out the last time around. Removing this solved my problem.
As I said in the comments above, I got it to work by :
uninstalling the app
deleting the user on the Parse dashboard
reinstalling the app and signing up again
Then the signout/signin mechanism worked miraculously :|
The only reason I can imagine is that I had previously signed up with this user having Automatic user creation enabled, and it somehow stuck to the user entity in Parse.
Experiencing same bug. Now instead of only checking ParseUser as null, I check username too:
ParseUser currentUser=ParseUser.getCurrentUser()
if(currentUser==null)
{
//user doesn't exist
}
else
{
if(currentUser.getUserName()==null)
{
//user oesn't exist
}
}
Try
ParseUser.getCurrentUser().logOut();
I had the same problem. Actually it was a bug in parse sdk and the problem was solved without changing any of my code, just by installing the latest parse android sdk(1.8.1 at the time of writing).
I had the same issue it was because i has automatic user enabled which causes a new anonymous user to be created, it is also explained here
https://www.parse.com/questions/issues-with-parseuserlogout-on-android
Try to logout the current user object, not the class.
ParseUser.getCurrentUser().logout();
and make sure to delete
ParseUser.enableAutomaticUser();
Edit:
When you logout, the User instance will still available, but with null fields. Parse changes all the user's fields into nulls.
So, if you want to check whether the user is logged in or out, just do the following
if(ParseUser.getCurrentUser().getUsername() == null)
{ // user is out
} else {
// user is in }