Android Vitals “Bad Behaviour” Flags - crash

Google Play recently released the “Android Vitals” feature in the Google Play Console whereby they present analytic information about the released app.
The Android Vitals tab contains analytic information like crashes, ANR, multi-crashes, Slow Rendering, Frozen Frames, etc. They also show “bad behaviour” metrics whereby they compare the analytics of your app with benchmarks. If your app gets flagged with bad beahviours flags, then supposedly it can impact your rankings/downloads etc.
Is anyone else experiencing bad behaviour flags in their app on google play?
Has anyone else seen a dramatic decrease in organic traffic since the Android Vitals tab was introduced?
Does anyone have any advice on how to best solve these “bad behaviour” flags considering our Apps are developed with AS
Thanks in advance
bad behav image
installs
java.lang.NullPointerException:
at com.mydemoapp.player.activity.Dashboard$37.subscribeActual (Dashboard.java:2033)
at io.reactivex.Observable.subscribe (Observable.java:10179)
at io.reactivex.internal.operators.observable.ObservableSubscribeOn$1.run (ObservableSubscribeOn.java:39)
at io.reactivex.Scheduler$1.run (Scheduler.java:134)
at io.reactivex.internal.schedulers.ScheduledRunnable.run (ScheduledRunnable.java:59)
at io.reactivex.internal.schedulers.ScheduledRunnable.call (ScheduledRunnable.java:51)
at java.util.concurrent.FutureTask.run (FutureTask.java:237)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run (ScheduledThreadPoolExecutor.java:272)
at java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1133)
at java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:607)
at java.lang.Thread.run (Thread.java:761)
--
private Observable<ArrayList<HashMap<String, String>>> provideSongListOberservable() {
return new Observable<ArrayList<HashMap<String, String>>>() {
#Override
protected void subscribeActual(Observer<? super ArrayList<HashMap<String, String>>> observer) {
File home = new File(MEDIA_PATH);
String[] values = getResources().getStringArray(R.array.array_songs);
ArrayList<HashMap<String, String>> songsList = new ArrayList<>();
if (home.listFiles(new FileExtensionFilter()).length > 0) {
for (File file : home.listFiles(new FileExtensionFilter())) {
try {
HashMap<String, String> song = new HashMap<>();
song.put(KEY_SONG_TITLE,
values[Integer.parseInt(file.getName().split("_")[1].substring(0,
(file.getName().split("_")[1].length() - 4))) - 1]);
song.put(KEY_SONG_PATH, file.getPath());
// Adding each song to SongList
songsList.add(song);
} catch (Exception e) {
e.printStackTrace();
}
}
}
observer.onNext(songsList);
}
};
}

An "App crashing" bad behavior means your app is crashing a lot.
Google Play has publicly said (eg this talk) that it will use bad behavior as a signal when deciding which how to order apps in search results, and choose which apps to promote.
In order to fix this - get your development team to make crash fixing a priority, not just adding new features. Use the crash reports in the Play console to find out the bugs in your app, and fix them.

Related

Asynchronous programming for IotHub Device Registration in Java?

I am currently trying to implement the Java web service(Rest API) where the endpoint creates the device in the IoTHub and updates the device twin.
There are two methods available in the azure-iot sdk. One is
addDevice(deviceId, authenticationtype)
and another is to
addDeviceAsync(deviceId, authenticationtype)
I just wanted to figure out which one should I use in the web service(as a best practice). I am not very strong in MultiThreading/Concurrency so was wondering to receive people's expertise on this. Any suggestion/Link related to this is much appreciated
Thanks.
The Async version of AddDevice is basically the same. If you use AddDeviceAsync then a thread is created to run the AddDevice call so you are not blocked on it.
Check the code#L269 of RegistryManager doing exactly that: https://github.com/Azure/azure-iot-sdk-java/blob/master/service/iot-service-client/src/main/java/com/microsoft/azure/sdk/iot/service/RegistryManager.java#L269
public CompletableFuture<Device> addDeviceAsync(Device device) throws IOException, IotHubException
{
if (device == null)
{
throw new IllegalArgumentException("device cannot be null");
}
final CompletableFuture<Device> future = new CompletableFuture<>();
executor.submit(() ->
{
try
{
Device responseDevice = addDevice(device);
future.complete(responseDevice);
}
catch (IOException | IotHubException e)
{
future.completeExceptionally(e);
}
});
return future;
}
You can as well build your own async wrapper and call AddDevice() from there.

Getting error Attempted to start a foreground service (xxx) with a broken notification (no icon: Notification(pri=0 contentView=null ---

I do not understand this error message in Android Studio. Looking at the source code this error is caused by the small icon being null. But I set the icon (both large and small) and the notification is present WITH my icon. I even used the Asset Studio to create this icon specifically for notifications.
There are a lot of other posts on this topic but they all seem related to those trying to HIDE the notification in some way. I want it so that my service is not killed by Android!
Here is the full error
Attempted to start a foreground service (ComponentInfo{com.lni.pchademophg/com.lni.pchademophg.BaseManager}) with a broken notification (no icon: Notification(pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x40 color=0x00000000 vis=PRIVATE secFlags=0x0 secPriority=0))
Why the error? ( I guess I shouldn't complain, everything works as I need it to work ... at least it appears so, but the error is unsettling and I would like to understand it.)
This error is occurring on a 6.0.1 device (have not tried a 10 yet)
Here is my code which is in the 'onsStartCommand()' method of the service:
#Override
public int onStartCommand(Intent intent, int flags, int startId)
{
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.O)
{
createNotificationChannel();
Notification.Builder builder = new Notification.Builder(context, mChannel.getId())
.setContentTitle(getString(R.string.app_name))
.setSmallIcon(R.drawable.ic_stat_name)
.setContentText("Pcha Personal Health Gateway")
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(),
R.drawable.ic_stat_name))
.setAutoCancel(true);
Notification notification = builder.build();
startForeground(NOTIFICATION_ID, notification);
}
else
{
NotificationCompat.Builder notificationBuilder =
new NotificationCompat.Builder(context, "BtleScanChannel");
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.N)
{
notificationBuilder.setPriority(NotificationManager.IMPORTANCE_LOW);
}
notificationBuilder.setContentTitle(getString(R.string.app_name))
.setContentTitle(getString(R.string.app_name))
.setContentText("Pcha Personal Health Gateway")
.setSmallIcon(R.drawable.ic_stat_name)
.setLargeIcon(BitmapFactory.decodeResource(context.getResources(),
R.drawable.ic_stat_name));
startForeground(NOTIFICATION_ID, notificationBuilder.build());
}
return START_STICKY;
}
Any ideas? What are the consequences?

Play Frame work 2.2 How Concurrent execution works

Recently, we started to work with play 2.2. Previously we were working with play 2.1.3.
In play 2.2 it says Akka.future and async methods are seen as deprecated. Also when we tried to run below piece of code fetchSample() through a loop, it took more time to complete in play 2.2.
So how can we replace the below deprecated code with the latest one?
private static Promise<SampleDBResponseBean> fetchSample(
final Document sampleDoc) throws Exception {
Promise<SampleBean> promiseOfSampleJson = Akka.future(
new Callable<SampleBean>() {
public SampleBean call() throws Exception
{
return doSomeCalc(sampleDoc);
}
});
}
private Result getAsyncResult(final SampleResponseBean sampleDbResponseBean) {
List<F.Promise<? extends SampleDBResponseBean>> promiseList = sampleDbResponseBean
.getSampleHelperList();
Promise<List<SampleDBResponseBean>> promiseJsonObjLists = Promise
.sequence(promiseList);
return async(
promiseJsonObjLists.map(
new Function<List<SampleDBResponseBean>, Result>() {
public Result apply(List<SampleDBResponseBean> sampleList) {
SampleResponseBean sampleResponseBean = new SampleResponseBean();
sampleResponseBean.setStatus("success");
sampleResponseBean.setSampleList(sampleList);
JsonNode jsNodeResponse = Json.toJson(sampleResponseBean);
return ok(jsNodeResponse);
}
}));
}
I had searched a lot of places not seeing any solution. The problem effects our code performance when comparing to 2.1.3.
Any ideas how can we implement the deprecated methods for the above 2 methods in play 2.2?
As pointed out in the migration docs:
http://www.playframework.com/documentation/2.2.x/Migration22
You want to use Promise.promise. This is also described in the documentation:
http://www.playframework.com/documentation/2.2.x/JavaAsync
And of course in the API docs:
http://www.playframework.com/documentation/2.2.x/api/java/play/libs/F.Promise.html#promise(play.libs.F.Function0)
One of the really nice things about Play 2.2 Java promises is now you can control exactly which execution context the code runs in, so you can create your own execution context, or get one from Akka, and so control exactly how many, in your case, concurrent DB operations are run across the whole app at the same time.

Unity game online beta testing platform

I've googled this but, nothing useful came up. It's really simple, i'm looking for a service that supports Unity games distribution and usage tracking, with crash reports and whatnot, something like TestFlight or HockeyApp but for Unity games!
Thanks in advance !
If you search for "analytics" in the Unity Asset Store there are some systems that support Unity PC. These can be used to track usage, and some track errors too. Usually analytics systems support attaching extra data to an event, and you could use this to send uncaught exceptions to the service.
Application.RegisterLogCallback can be used for this.
void OnEnable() {
Application.RegisterLogCallback(ErrorReporter);
}
void OnDisable() {
Application.RegisterLogCallback(null);
}
void ErrorReporter (string logString, string stackTrace, LogType type) {
if (type == LogType.Assert || type == LogType.Error || type == LogType.Exception) {
// send analytics message with logString and/or stackTrace attached.
}
}

Camera application for all Android devices

I'm currently developing a camera application for Android on which some problems have occurred. I need it to work on all Android devices and since all of these works in different ways specially with the camera hardware, I'm having a hard time finding a solution that works for every device.
My application main goal is to launch the camera on a button click, take a photo and upload it to a server. So I don't really need the functionality of saving the image on the device, but if that's needed for further image use I might as well allow it.
For example I'm testing my application on a Samsung Galaxy SII and a Motorola Pad. I got working code that launches the camera, which is by the way C# code since I'm using Monodroid:
Intent cameraIntent = new Intent(Android.Provider.MediaStore.ActionImageCapture);
StartActivityForResult(cameraIntent, PHOTO_CAPTURE);
And I fetch the result, similar to this guide I followed:
http://kevinpotgieter.wordpress.com/2011/03/30/null-intent-passed-back-on-samsung-galaxy-tab/
Why I followed this guide is because the activity returns null on my galaxy device (Another device oriented problem).
This code works fine on the Galaxy device. It takes a photo and saves the photo in the gallery from which i can upload to a server. By further research this is apparently galaxy standard behaviour, so this doesn't work on my Motorola pad. The camera works fine, but no image is saved to gallery.
So with this background my question is, am I on the right path here? Do I need to save the image to gallery in order for further use in my application? Is there any solution that works for every Android device, cause that's the solution i need.
Thanks for any feedback!
After reading the linked article, the approach taken in that article is geared toward the Galaxy line, since they appear to write to the gallery automatically.
This article discusses some other scenarios in detail:
Android ACTION_IMAGE_CAPTURE Intent
So, I don't necessarily think that following the linked article that you provided is the right path. Not all devices automatically write to the gallery as described in that article, afaik. The article I linked to points to the issues being related to security and suggests writing the image to a /sdcard/tmp folder for storing the original image. Going down a similar path would more than likely lead to code that is going to work reliably across many devices.
Here are some other links for reference:
Google discussion regarding this subject: http://code.google.com/p/android/issues/detail?id=1480
Project with potential a solution to the problem: https://github.com/johnyma22/classdroid
While that discussion/project are in Java/Android SDK, the same concepts should apply to Monodroid. I'd be happy to help you adapt the code to a working Mono for Android solution if you need help.
To long2know:
Yes the same concepts applies to Monodroid. I've already read the stack article you linked among with some other similar. However i don't like the approach in that particular post since it checks for bugs for some devices that are hardcoded into a collection. Meaning it might fail to detect bugs in future devices. Since i won't be doing maintenance on this application, i can't allow this. I found a solution elsewhere and adapted it to my case and i'll post it below if someone would need it. It works on both my devices, guessing it would work for the majority of other devices. Thanks for your post!
Solution that allows you to snap a picture and use, also with the option of using a image from gallery. Solution uses option menu for these purposes, just for testing. (Monodroid code).
Camera code is inspired by:
access to full resolution pictures from camera with MonoDroid
namespace StackOverFlow.UsingCameraWithMonodroid
{
[Activity(Label = "ImageActivity")]
public class ImageActivity
private readonly static int TakePicture = 1;
private readonly static int SelectPicture = 2;
private string imageUriString;
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
this.SetContentView(Resource.Layout.ImageActivity);
}
public override bool OnCreateOptionsMenu(IMenu menu)
{
MenuInflater flate = this.MenuInflater;
flate.Inflate(Resource.Menu.ImageMenues, menu);
return base.OnCreateOptionsMenu(menu);
}
public override bool OnOptionsItemSelected(IMenuItem item)
{
switch (item.ItemId)
{
case Resource.Id.UseExisting:
this.SelectImageFromStorage();
return true;
case Resource.Id.AddNew:
this.StartCamera();
return true;
default:
return base.OnOptionsItemSelected(item);
}
}
private Boolean isMounted
{
get
{
return Android.OS.Environment.ExternalStorageState.Equals(Android.OS.Environment.MediaMounted);
}
}
private void StartCamera()
{
var imageUri = ContentResolver.Insert(isMounted ? MediaStore.Images.Media.ExternalContentUri
: MediaStore.Images.Media.InternalContentUri, new ContentValues());
this.imageUriString = imageUri.ToString();
var cameraIntent = new Intent(MediaStore.ActionImageCapture);
cameraIntent.PutExtra(MediaStore.ExtraOutput, imageUri);
this.StartActivityForResult(cameraIntent, TakePicture);
}
private void SelectImageFromStorage()
{
Intent intent = new Intent();
intent.SetType("image/*");
intent.SetAction(Intent.ActionGetContent);
this.StartActivityForResult(Intent.CreateChooser(intent,
"Select Picture"), SelectPicture);
}
// Example code of using the result, in my case i want to upload in another activity
protected override void OnActivityResult(int requestCode, Result resultCode, Intent data)
{
// If a picture was taken
if (resultCode == Result.Ok && requestCode == TakePicture)
{
// For some devices data can become null when using the camera activity.
// For this reason we save pass the already saved imageUriString to the upload activity
// in order to adapt to every device. Instead we would want to use the data intent
// like in the SelectPicture option.
var uploadIntent = new Intent(this.BaseContext, typeof(UploadActivity));
uploadIntent.PutExtra("ImageUri", this.imageUriString);
this.StartActivity(uploadIntent);
}
// User has selected a image from storage
else if (requestCode == SelectPicture)
{
var uploadIntent = new Intent(this.BaseContext, typeof(UploadActivity));
uploadIntent.PutExtra("ImageUri", data.DataString);
this.StartActivity(uploadIntent);
}
}
}
}