Push notification Error with Parse - android

Situation
I've implemented push notification with Parse in ANDROID. Everything works great (I can receive push/send etc.), the only thing is that when I install my application it happens this:
if it is the first install ever on the device: no problem
if it is not the first install (this means that the device has already made a PARSE/GCM registration) it generates this error:
Error generated
02-12 11:12:28.054 15564-15579/com.hoxell.hoxellbrowser E/ParseCommandCache﹕ Failed to run command.
com.parse.ParseException: at least one ID field (installationId,deviceToken) must be specified in this operation
at com.parse.ParseCommand.onPostExecute(ParseCommand.java:404)
at com.parse.ParseRequest$5.then(ParseRequest.java:342)
at com.parse.ParseRequest$5.then(ParseRequest.java:339)
at bolts.Task$10.run(Task.java:486)
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:97)
at bolts.Task.completeAfterTask(Task.java:482)
at bolts.Task.continueWithTask(Task.java:358)
at bolts.Task.continueWithTask(Task.java:369)
at bolts.Task$8.then(Task.java:415)
at bolts.Task$8.then(Task.java:407)
at bolts.Task$10.run(Task.java:486)
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:97)
at bolts.Task.completeAfterTask(Task.java:482)
at bolts.Task.access$200(Task.java:27)
at bolts.Task$6.then(Task.java:351)
at bolts.Task$6.then(Task.java:348)
at bolts.Task.runContinuations(Task.java:515)
at bolts.Task.access$600(Task.java:27)
at bolts.Task$TaskCompletionSource.trySetResult(Task.java:570)
at bolts.Task$TaskCompletionSource.setResult(Task.java:604)
at bolts.Task$10$1.then(Task.java:498)
at bolts.Task$10$1.then(Task.java:490)
at bolts.Task$9.run(Task.java:453)
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:97)
at bolts.Task.completeImmediately(Task.java:449)
at bolts.Task.access$100(Task.java:27)
at bolts.Task$5.then(Task.java:316)
at bolts.Task$5.then(Task.java:313)
at bolts.Task.runContinuations(Task.java:515)
at bolts.Task.access$600(Task.java:27)
at bolts.Task$TaskCompletionSource.trySetResult(Task.java:570)
at bolts.Task$TaskCompletionSource.setResult(Task.java:604)
at bolts.Task$10$1.then(Task.java:498)
at bolts.Task$10$1.then(Task.java:490)
at bolts.Task$9.run(Task.java:453)
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:97)
at bolts.Task.completeImmediately(Task.java:449)
at bolts.Task.access$100(Task.java:27)
at bolts.Task$5.then(Task.java:316)
at bolts.Task$5.then(Task.java:313)
at bolts.Task.runContinuations(Task.java:515)
at bolts.Task.access$600(Task.java:27)
at bolts.Task$TaskCompletionSource.trySetResult(Task.java:570)
at bolts.Task$TaskCompletionSource.setResult(Task.java:604)
at bolts.Task$10$1.then(Task.java:498)
at bolts.Task$10$1.then(Task.java:490)
at bolts.Task$9.run(Task.java:453)
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:97)
at bolts.Task.completeImmediately(Task.java:449)
at bolts.Task.continueWith(Task.java:323)
at bolts.Task.continueWith(Task.java:334)
at bolts.Task$10.run(Task.java:490)
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:97)
at bolts.Task.completeAfterTask(Task.java:482)
at bolts.Task.access$200(Task.java:27)
at bolts.Task$6.then(Task.java:351)
at bolts.Task$6.then(Task.java:348)
at bolts.Task.runContinuations(Task.java:515)
at bolts.Task.access$600(Task.java:27)
at bolts.Task$TaskCompletionSource.trySetResult(Task.java:570)
at bolts.Task$TaskCompletionSource.setResult(Task.java:604)
at bolts.Task$10$1.then(Task.java:498)
at bolts.Task$10$1.then(Task.java:490)
at bolts.Task$9.run(Task.java:453)
at bolts.BoltsExecutors$ImmediateExecutor.execute(BoltsExecutors.java:97)
at bolts.Task.completeImmediately(Task.java:449)
at bolts.Task.continueWith(Task.java:323)
at bolts.Task.continueWith(Task.java:334)
at bolts.Task$10.run(Task.java:490)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
at java.lang.Thread.run(Thread.java:864)
Yeah, it generates it but the app do not crash! and the app still works: push notifications too, but you can understand that this is not 100% reliable.
E/ParseCommandCache﹕ Failed to run command.
com.parse.ParseException: at least one ID field (installationId,deviceToken) must be specified in this operation
What does he want..? What should I do? What is the cause of the problem? Here is my code:
Application.java
#Override
public void onCreate() {
super.onCreate();
// Initialize the Parse SDK.
Parse.initialize(this, "x", "x");
// Specify an Activity to handle all pushes by default.
PushService.setDefaultPushCallback(this, MainActivity.class);
ParseInstallation.getCurrentInstallation().saveInBackground();
}
In my mainActivity I just concatenate the deviceToken (in my case it is the installationId) into my userAgent: and this work fine too! Even if the error is generated, the installationID is inserted into the userAgent.
MainActivity.java
deviceToken = ParseInstallation.getCurrentInstallation().getInstallationId();
webSettings.setUserAgentString(userAgent + " ||" + deviceToken);
Am I making any mistakes into my code?
Thank you

Try the following below:
ParseInstallation.getCurrentInstallation().saveInBackground(new SaveCallback()
{
#Override
public void done(ParseException e)
{
PushService.setDefaultPushCallback(Application.this, MainActivit.class);
}
});

As I recall, you do not need to save the installation when using setDefaultPushCallback. Try removing the saving of installation and see if it still happens.
setDefaultPushCallback will automatically save the installation for you. Cannot remember where I found it, but at some forum it was told to be the behavior. I guess a second save right after (without the first yet completed) brings the installation in a bad state, causing the non-fatal error msg.

Related

Using ACRA with tracepot as backend

I have just finished my first android app as part of a school project ..one of my friends encountered a problem while trying to explore one of the activities in the app ..so i searched for solutions to get the crashes reports whenever they happen to fix the bugs ..i came across ACRA ..and I followed one of SO threads to setup ACRA to my app ..
RESULT: when the crashs happens the gmail app get launch in the device and the user (if he want to) he'll send the crash report by email ..Consedering not all users will want to ..i found in a comment in one of the SO threads that some developers use tracepot.
so i have used their link for integration in formUri but exploring my account on tracepot i get nothing ..is there something i am doing wrong (or if there is a better solution than using tracepot a backend , please suggest/explain or link a good tutorial, thanks!)
MyApplication.Java ( AFTER EDITING
#ReportsCrashes(
formUri = "https://collector.tracepot.com/79b1***",
reportType = org.acra.sender.HttpSender.Type.JSON,
httpMethod = org.acra.sender.HttpSender.Method.PUT,
mode = ReportingInteractionMode.TOAST,
resToastText = R.string.crash_toast_text
)
public class MyApplication extends Application {
#Override
public void onCreate() {
super.onCreate();
CaocConfig.Builder.create()
//.errorActivity(CustomErrorActivity.class) //default: null (default error activity)
.apply();
// The following line triggers the initialization of ACRA
ACRA.init(this);
}
}
EDIT :
msg in logcat if i use the http and email:
09-17 18:37:33.700 14329-14812/ma.ac.iav.menunaviagtion:acra W/ACRA: ma.ac.iav.menunaviagtion reports will be sent by email (if accepted by user).
09-17 18:37:33.703 14329-14812/ma.ac.iav.menunaviagtion:acra I/ACRA: Sending report /data/user/0/ma.ac.iav.menunaviagtion/app_ACRA-approved/2018-09-17T18:37:33.441+01:00-IS_SILENT.stacktrace
if i use only the http :
09-17 22:47:00.648 20116-20137/ma.ac.iav.myapplication:acra E/ACRA: Failed to send crash report for /data/user/0/ma.ac.iav.myapplication/app_ACRA-approved/2018-09-17T22:44:52.199+00:00-IS_SILENT.stacktrace
IMPLEMENTATION:
compile 'ch.acra:acra:4.9.2'
LOGCAT FOR F43nd1r
09-18 01:39:49.631 18508-18803/? E/AndroidRuntime: FATAL EXCEPTION: Thread-5
Process: ma.ac.iav.myapplication, PID: 18508
java.lang.InternalError: Thread starting during runtime shutdown
at java.lang.Thread.nativeCreate(Native Method)
at java.lang.Thread.start(Thread.java:733)
at android.app.SharedPreferencesImpl.startLoadFromDisk(SharedPreferencesImpl.java:119)
at android.app.SharedPreferencesImpl.<init>(SharedPreferencesImpl.java:112)
at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:392)
at android.app.ContextImpl.getSharedPreferences(ContextImpl.java:373)
at android.content.ContextWrapper.getSharedPreferences(ContextWrapper.java:167)
at cat.ereza.customactivityoncrash.CustomActivityOnCrash.getLastCrashTimestamp(CustomActivityOnCrash.java:673)
at cat.ereza.customactivityoncrash.CustomActivityOnCrash.hasCrashedInTheLastSeconds(CustomActivityOnCrash.java:683)
at cat.ereza.customactivityoncrash.CustomActivityOnCrash.access$200(CustomActivityOnCrash.java:52)
at cat.ereza.customactivityoncrash.CustomActivityOnCrash$1.uncaughtException(CustomActivityOnCrash.java:112)
at org.acra.builder.ReportExecutor.endApplication(ReportExecutor.java:269)
at org.acra.builder.ReportExecutor.dialogAndEnd(ReportExecutor.java:254)
at org.acra.builder.ReportExecutor.access$400(ReportExecutor.java:42)
at org.acra.builder.ReportExecutor$2.run(ReportExecutor.java:217)
By default, if the mail config is present, Acra 4 will send via mail and nothing else.
To use both you'd have to configure the reportSenderFactories.
400: Client error
Indicates that tracepot rejected your report. This could have multiple reasons. To find out what the problem is, call ACRA.DEV_LOGGING = true; right before ACRA.init and post all logcat with the ACRA tag.
Also note that ACRA 4.9.2 does not support android Oreo and above, it is recommended to upgrade to at least ACRA 4.11, or just the newest version 5.2.0.
You are not sending all required fields to Tracepot.
https://tracepot.uservoice.com/knowledgebase/articles/355272-what-are-the-required-fields-acra-needs-to-send
ANDROID_VERSION
APP_VERSION_CODE
APP_VERSION_NAME
PACKAGE_NAME
REPORT_ID
STACK_TRACE
USER_APP_START_DATE
USER_CRASH_DATE

Firestore operations (add(), set()) not working

I am trying to add user details to Firestore db, but can't write data in it.
Actually none of the listeners are triggered neither onSuccess() nor onFailure().
here is my code.
Map<String,Object> userlol = new HashMap<>();
userlol.put("name",name);
userlol.put("email",email);
userlol.put("uid",currentUser.getUid());
Log.d(TAG, "we are here");
CollectionReference dc = db.collection("users");
DocumentReference dd = dc.document(currentUser.getUid());
dd.set(userlol)
.addOnSuccessListener(new OnSuccessListener<Void>() {
#Override
public void onSuccess(Void aVoid) {
Toast.makeText(SignupActivity.this, "User Added" ,
Toast.LENGTH_SHORT).show();
Log.d(TAG,"User added to database");
}
})
.addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(SignupActivity.this, "ERROR" +e.toString(),
Toast.LENGTH_SHORT).show();
Log.d(TAG, e.toString());
}
});
There is no toast nor the Log in my logcat.I can see
D/logging: we are here
This log and logs after this method.
There is no issue with rules as onFailure() is also not working.
I have searched every possible thing but nothing worked.
The only way I can get neither of the callbacks to trigger is when there is no network connection on my device. In that case the behavior makes sense, since the task is only considered completed when the data has been committed (or rejected) on the server.
To easily see if the Firestore client indeed can't connect to the server, enable debug logging:
FirebaseFirestore.setLoggingEnabled(true);
I see log entries like this after doing so:
11-12 07:56:21.366 10034-10066/com.firebase.firestorestackoverflow I/Firestore: (0.6.6-dev) [zzetk]: (b6322ac) Stream closed with status: zzcd{code=UNAVAILABLE, description=null, cause=java.net.UnknownHostException: Unable to resolve host "firestore.googleapis.com": No address associated with hostname
at java.net.InetAddress.lookupHostByName(InetAddress.java:470)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252)
at java.net.InetAddress.getAllByName(InetAddress.java:215)
at io.grpc.internal.zzbj$zzb.zztu(Unknown Source)
at io.grpc.internal.zzbk.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588)
at java.lang.Thread.run(Thread.java:818)
Caused by: android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
at libcore.io.Posix.android_getaddrinfo(Native Method)
at libcore.io.ForwardingOs.android_getaddrinfo(ForwardingOs.java:55)
at java.net.InetAddress.lookupHostByName(InetAddress.java:451)
at java.net.InetAddress.getAllByNameImpl(InetAddress.java:252) 
at java.net.InetAddress.getAllByName(InetAddress.java:215) 
at io.grpc.internal.zzbj$zzb.zztu(Unknown Source) 
at io.grpc.internal.zzbk.run(Unknown Source) 
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1113) 
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:588) 
at java.lang.Thread.run(Thread.java:818) 
}.
well for anyone having that problem in the future just Uninstall your application and reinstall it, as savage as it seams it works(y)
I had the same problem.
First of all turning on the logs helped a lot as #Frank van Puffelen suggested.
In my case I got "The Cloud Firestore API is not available for Datastore Mode projects".
So I went to GCP and created manually a collection by changing the db to a native one. And then I had an option on the gui.
Now the error changed to "FirebaseFirestoreException: permission_denied: missing or insufficient permissions"
So I changed the permissions under the "rules" tab in firestore.
And that fixed it for me :)
I guess the problem was the permissions from the beginning, but I can't tell for sure now.
I had the same error. In my case, I was creating a user and automatically logging him/her out, for them to log manually.
I removed the sign out, as data appears not to be written if there is no user logged in.
Do you have a user signed in when the data is written? Creating a user signs him/her in automatically.
Hope it helps!
It appears that just like after adding new permissions in the manifest file, the app has to be reinstalled to register the changes. I tried reinstalling the app after adding the firestore connection and everything worked fine. voila!

Android RemoteServiceException: Bad notification posted from package Couldn't cache contentViews

I have an Android app that is crashing due to an unhandled exeption, but only on one particular device (running Nougat). I believe they are the only one of my testers that is running Nougat. This is the exception:
Java.Lang.RuntimeException: Bad notification posted from package [my
package name]: Couldn't cache contentViews: package=[my package name]
Here is the stack trace:
android.app.RemoteServiceException: Bad notification posted from package com.elephanigma.starmygrooves: Couldn't cache contentViews: package=com.elephanigma.starmygrooves
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1675)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6247)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
Xamarin caused by: Java.Lang.RuntimeException: Bad notification posted from package com.elephanigma.starmygrooves: Couldn't cache contentViews: package=com.elephanigma.starmygrooves
--- End of managed Java.Lang.RuntimeException stack trace ---
android.app.RemoteServiceException: Bad notification posted from package com.elephanigma.starmygrooves: Couldn't cache contentViews: package=com.elephanigma.starmygrooves
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1675)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:154)
at android.app.ActivityThread.main(ActivityThread.java:6247)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:872)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:762)
The stack trace does not show any of my own code. My app does not create any notifications itself, but it does use an open source package (Xamarin Media Manager) that does. The stack trace does not show any of that package's code either.
So, I'm not sure where to look. I have tried searching for this exception, and although I get a couple of hits for "Bad notification posted", none of them seem to address my issue. I do not get ANY hits for "Couldn't cache contentViews".
If it helps, here is the code (as best I can tell) from the package that creates the notification: (note this is c# code, because it's using Xamarin/Mono)
/// <summary>
/// When we start on the foreground we will present a notification to the user
/// When they press the notification it will take them to the main page so they can control the music
/// </summary>
public void StartNotification(IMediaFile mediaFile, bool mediaIsPlaying, bool canBeRemoved)
{
var icon = (_appliactionContext.Resources?.GetIdentifier("xam_mediamanager_notify_ic", "drawable", _appliactionContext?.PackageName)).GetValueOrDefault(0);
_notificationStyle.SetMediaSession(_sessionToken);
_notificationStyle.SetCancelButtonIntent(_pendingCancelIntent);
_builder = new NotificationCompat.Builder(_appliactionContext)
{
MStyle = _notificationStyle
};
_builder.SetSmallIcon(icon != 0 ? icon : _appliactionContext.ApplicationInfo.Icon);
_builder.SetContentIntent(_pendingIntent);
_builder.SetOngoing(mediaIsPlaying);
_builder.SetVisibility(1);
SetMetadata(mediaFile);
AddActionButtons(mediaIsPlaying);
if (_builder.MActions.Count >= 3)
((NotificationCompat.MediaStyle)(_builder.MStyle)).SetShowActionsInCompactView(0, 1, 2);
NotificationManagerCompat.From(_appliactionContext)
.Notify(MediaServiceBase.NotificationId, _builder.Build());
}

bonjour for embedded system

I have followed the steps provided in the install file to initialize the bonjour for embedded system . first I generated the shared ib for bonjour source code for my embedded system and then I initialized it by calling mDNS_Init api.
Since I just need to browse at my client , I called the browsing function as per dns_sd.h , but I got the below error .
mDNS_StartBrowse: mDNSPlatformRawTime went backwards by 1669225997 ticks; setting correction factor to 1669225997
11-17 00:28:08.481: D/bonjour(1280): mDNS_StartBrowse: mDNS_Unlock: ERROR! m->timenow aready zero
11-17 00:28:08.481: D/bonjour(1280): DNSServiceBrowse("_appl._tcp.", "local.") failed: mDNS_StartBrowse (-65546)
11-17 00:28:08.490: I/System.out(1280): DNSService call failed -65546
11-17 00:32:24.720: E/ThrottleService(161): problem during onPollAlarm: java.lang.IllegalStateException: problem parsing stats:
I posted in the apple forum but I have nit received any help for this problem ..

Embedded Felix, running inside android-app cant resolve org.osgi.framework

i cant figure out why the following happens:
I am running an embedded apache felix from a small android application. I programmatically install 2 bundles after starting the framework, but both never enter the "resolved" state. Thereby the Bundle "MyBundle1" imports "MyBundle2".
This is what Logcat tells me:
05-17 20:21:56.514: ERROR/MainActivity(384): org.osgi.framework.BundleException:
Unresolved constraint in bundle de.xy.MyBundle1 [1]: Unable to resolve 1.11: missing
requirement [1.11] package; (package=de.xy.MyBundle2) [caused by: Unable to resolve 2.0:
missing requirement [2.0] package; (&(package=org.osgi.framework)(version>=1.5.0))]
I totally understand what the error-message says (well...org.osgi.framework in version 1.5+ cant be resolved) but i cant figure out why this happens. Why cant the framework resolve "himself"?! I tried to run the same felix.jar as standalone with the adb shell , and both bundles work. Ofcourse, the felix.jar is up to date (3.2)
Thanks for your advice!
Daniel
FelixSetup
m_configMap = new StringMap(false);
try {
m_cache = File.createTempFile("felix-cache", null);
} catch (IOException ex) {
throw new IllegalStateException(ex);
}
m_cache.delete();
boolean mkdirs = m_cache.mkdirs(); // works (=true)
m_activator = new HostActivator(); // implements BundleActivator
List list = new ArrayList();
list.add(m_activator);
m_configMap.put(FelixConstants.LOG_LEVEL_PROP, "1");
m_configMap.put(BundleCache.CACHE_ROOTDIR_PROP, ".");
m_configMap.put(FelixConstants.SYSTEMBUNDLE_ACTIVATORS_PROP, list);
m_configMap.put(FelixConstants.FRAMEWORK_STORAGE, m_cache.getAbsolutePath());
m_felix = new Felix(m_configMap);
try {
m_felix.start();
} catch (BundleException ex) {
Logger.getLogger(MainActivity.class.getName()).log(Level.SEVERE, null, ex);
}
I dont know if it has something to do with the previous problems:
05-18 08:52:59.149: VERBOSE/out(363): Problem creating boot delegation class loader: java.lang.reflect.InvocationTargetException
05-18 08:52:59.209: VERBOSE/out(363): ERROR: Error parsing system bundle export statement: (java.lang.IllegalArgumentException:A header cannot be an empty string.)
05-18 08:52:59.209: VERBOSE/out(363): java.lang.IllegalArgumentException: A header cannot be an empty string.
I install and start the bundles with
myBundle1= bundleContext.installBundle("file:/data/felix/MyBundle1.jar");
myBundle2= bundleContext.installBundle("file:/data/felix/MyBundle2.jar");
myBundle1.start();
they were previously dx'ed and moved to /data/felix with adb push.
The same code I used in the android-application also works inside a regular java console-app.
The way you build up the framework looks okay to me. You could consider
replacing the FRAMEWORK_SYSTEMPACKAGES by a list that is specific for Android, if your bundles will e.g. be using Activities), or
not using a temp file, but point to some directory you know exists.
We have used 3.0.1 in the past successfully, and I do have the idea that the error message you posted has something to do with it. You could try that version of Felix, and if that works, you may have found a regression in Felix, which you can then report to users#felix.apache.org .

Categories

Resources