mindscapehq / raygun4android Goto Github PK
View Code? Open in Web Editor NEWAndroid crash reporting provider for Raygun
Home Page: https://raygun.com
License: MIT License
Android crash reporting provider for Raygun
Home Page: https://raygun.com
License: MIT License
Hi,
Following up from a support ticket, I cannot get Raygun to build in any gradle and Android Studio based project. Perhaps someone out there can help.
/Users/paul/sc/android-raygun-integration-test/app/src/main/java/rgtest1/android/showcase/myapplication/FullscreenActivity.java:13: error: package main.java.com.mindscapehq.android.raygun4android does not exist
import main.java.com.mindscapehq.android.raygun4android.RaygunClient;
^
/Users/paul/sc/android-raygun-integration-test/app/src/main/java/rgtest1/android/showcase/myapplication/FullscreenActivity.java:14: error: package main.java.com.mindscapehq.android.raygun4android.messages does not exist
import main.java.com.mindscapehq.android.raygun4android.messages.RaygunUserInfo;
^
/Users/paul/sc/android-raygun-integration-test/app/src/main/java/rgtest1/android/showcase/myapplication/FullscreenActivity.java:60: error: cannot find symbol
RaygunClient.Init(getApplicationContext());
^
symbol: variable RaygunClient
location: class FullscreenActivity
/Users/paul/sc/android-raygun-integration-test/app/src/main/java/rgtest1/android/showcase/myapplication/FullscreenActivity.java:61: error: cannot find symbol
RaygunClient.AttachExceptionHandler();
^
symbol: variable RaygunClient
location: class FullscreenActivity
4 errors
:app:compileDebugJava FAILED
FAILURE: Build failed with an exception.
I've made a repo with full source to demonstrate that the setup is as per documentation:
https://github.com/ShowcaseSoftwareLtd/android-raygun-integration-test
If I do not set the version on the Raygun client and upload a mapping file matching the version eg '1.5.2.txt' the stack trace is de-obfuscated as expected.
However if I set the version manually to provide more information, name & version code eg:
RaygunClient.setVersion("${BuildConfig.VERSION_NAME} (${BuildConfig.VERSION_CODE})")
The crash report will show the version as I set manually eg: 1.5.2 (452)
But uploading a file '1.5.2 (452).txt' does not de-obfuscate any future crash reports.
This did work as expected in a previous version.
I have changed how I name the version to the following:
RaygunClient.setVersion("${BuildConfig.VERSION_NAME}_${BuildConfig.VERSION_CODE}")
eg 1.5.2_452 and this does work uploading a file '1.5.2_452.txt'.
This solves it for me, but adding this incase anyone else has the same issue, I'm not sure if this file name should not contain spaces?
Hi,
I'm doing maintenance on an app (which has been using Raygun successfully for a year now), and every time I do a Raygun.send I get a dialog pop up with "Unfortunately, {app-name] has stopped". Its a modal dialog which clears when I click OK, but the app is never stopped i.e. it hasn't crashed, and continues to work fine.
It happens with both debug and release builds, and nothing reaches my Raygun console. I've also tried 2 different api keys, both show the issue. I've also tried an api key from another app (which works within the other app). The Android logcat screen doesn't show any errors, just the I/System.out: message detailing the attempt to send the message.
Raygun version is 3.0.2 (also tried 3.0.0) and compileSDKVersion is 27 (both of these are used in another app which works ok).
I've also reviewed all method calls on RaygunClient - I make one call to init and attachExceptionHandler in my Application class, and the rest are all send calls.
Is there a quick easy explanation for this?
I attempted to update my app from 3.0.6 to 4.0.1 today and I got the following build error:
Caused by: com.android.tools.r8.utils.AbortException: Error: Static interface methods are only supported starting with Android N (--min-api 24): void com.raygun.raygun4android.logging.TimberRaygunLogger.init()
The documentation says raygun is compatible with 16+ but this error indicates it requires 24+. Am I doing something wrong or was the compatibility changed?
Add unit tests for :provider
Message: NullPointerException: Attempt to invoke virtual method 'boolean android.net.NetworkInfo.isConnectedOrConnecting()' on a null object reference
main.java.com.mindscapehq.android.raygun4android.RaygunPostService.hasInternetConnection in RaygunPostService.java::92
main.java.com.mindscapehq.android.raygun4android.RaygunPostService.access$000 in RaygunPostService.java::18
main.java.com.mindscapehq.android.raygun4android.RaygunPostService$1.run in RaygunPostService.java::37
java.lang.Thread.run in Thread.java::764
This still happens occasionally in 3.0.4.
It comes from a very edge-case timing issue in the ConnectivityManager when the network is in the process of coming down.
I'll have a proper fix for it now - ran into a similar issue in a client project, will ping through a PR in the next couple of days.
Hi,
We have noticed that Raygun doesn't seem to pick up any crashes caused by StackOverflow errors. For example, we have the following stack trace in our Play Console:
java.lang.StackOverflowError:
at androidx.core.view.ViewCompat.getLayoutDirection (ViewCompat.java:1558)
at androidx.drawerlayout.widget.DrawerLayout.findDrawerWithGravity (DrawerLayout.java:986)
at androidx.drawerlayout.widget.DrawerLayout.isDrawerOpen (DrawerLayout.java:1836)
at com.mikepenz.materialdrawer.Drawer.isDrawerOpen (Drawer.java:153)
at xxx.yyy.zzz.MainActivity.onBackPressed (MainActivity.kt:292)
at xxx.yyy.zzz.FragmentNavigatorImpl.navigateBack (FragmentNavigatorImpl.kt:72)
at xxx.yyy.zzz.MainActivity.navigateBack (MainActivity.kt:344)
at xxx.yyy.zzz.MainActivity.onBackPressed (MainActivity.kt:310)
at xxx.yyy.zzz.FragmentNavigatorImpl.navigateBack (FragmentNavigatorImpl.kt:72)
at xxx.yyy.zzz.MainActivity.navigateBack (MainActivity.kt:344)
at xxx.yyy.zzz.MainActivity.onBackPressed (MainActivity.kt:310)
However, these stack traces are not reported in Raygun. I can confirm we have set up/initialised the RaygunClient
correctly using the following code in our Activity's onCreate()
method:
RaygunClient.init(application)
RaygunClient.setVersion(BuildConfig.VERSION_NAME)
RaygunClient.enableCrashReporting()
RaygunPageTags.init(deviceType)
RaygunClient.enableRUM(this)
Is there anything that could be preventing Raygun from reporting these StackOverflow crashes?
Version ussed: 4.0.1
Thank you for your support.
Calling RaygunClient.send causes NullPointerException
The following appears in the logcat
2018-10-08 11:18:52.845 10560-10560/? W/Raygun4Android: Couldn't get all env data: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
2018-10-08 11:18:52.847 10560-10560/? E/Raygun4Android: Failed to build RaygunMessage - java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
2018-10-08 11:18:52.847 10560-10560/? E/TLog: Raygun failed to send error, trying again with limited data. Error: java.lang.NullPointerException: Attempt to invoke virtual method 'main.java.com.mindscapehq.android.raygun4android.messages.RaygunMessageDetails main.java.com.mindscapehq.android.raygun4android.messages.RaygunMessage.getDetails()' on a null object reference
Looks like there are three problems here!
2018-10-08 11:18:52.845 10560-10560/? W/Raygun4Android: Couldn't get all env data: java.lang.NullPointerException: Attempt to invoke virtual method 'android.content.res.Resources android.content.Context.getResources()' on a null object reference
public RaygunEnvironmentMessage(Context context) {
try {
architecture = Build.CPU_ABI;
oSVersion = Build.VERSION.RELEASE;
osSDKVersion = Build.VERSION.SDK;
deviceName = Build.MODEL;
deviceCode = Build.DEVICE;
brand = Build.BRAND;
board = Build.BOARD;
processorCount = Runtime.getRuntime().availableProcessors();
int orientation = context.getResources().getConfiguration().orientation; // ----> context is null here!
.setEnvironmentDetails(RaygunClient.context)
I don't know how the context could possibly be null, although I am investigating this issue now. This could be a problem with my code base. Will provide updates later when i find more information
2018-10-08 11:18:52.847 10560-10560/? E/Raygun4Android: Failed to build RaygunMessage - java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.Object android.content.Context.getSystemService(java.lang.String)' on a null object reference
Another null context problem, could be related to the above problem, am investigating this issue now
2018-10-08 11:18:52.847 10560-10560/? E/TLog: Raygun failed to send error, trying again with limited data. Error: java.lang.NullPointerException: Attempt to invoke virtual method 'main.java.com.mindscapehq.android.raygun4android.messages.RaygunMessageDetails main.java.com.mindscapehq.android.raygun4android.messages.RaygunMessage.getDetails()' on a null object reference
public static void send(Throwable throwable, List tags, Map userCustomData) {
RaygunMessage msg = buildMessage(throwable);
msg.getDetails().setTags(mergeTags(tags)); // -----> See below comment. Of course we are getting a null pointer exception here!
msg.getDetails().setUserCustomData(mergeUserCustomData(userCustomData));
if (RaygunClient.onBeforeSend != null) {
msg = RaygunClient.onBeforeSend.onBeforeSend(msg);
if (msg == null) {
return;
}
}
postCachedMessages();
spinUpService(RaygunClient.apiKey, new Gson().toJson(msg), false);
}
private static RaygunMessage buildMessage(Throwable throwable) {
try {
RaygunMessage msg = RaygunMessageBuilder.instance()
.setEnvironmentDetails(RaygunClient.context)
.setMachineName(Build.MODEL)
.setExceptionDetails(throwable)
.setClientDetails()
.setAppContext(RaygunClient.appContextIdentifier)
.setVersion(RaygunClient.version)
.setNetworkInfo(RaygunClient.context)
.build();
if (RaygunClient.version != null) {
msg.getDetails().setVersion(RaygunClient.version);
}
if (RaygunClient.userInfo != null) {
msg.getDetails().setUserContext(RaygunClient.userInfo, RaygunClient.context);
}
else if (RaygunClient.user != null) {
msg.getDetails().setUserContext(RaygunClient.user);
}
else {
msg.getDetails().setUserContext(RaygunClient.context);
}
return msg;
}
catch (Exception e) {
RaygunLogger.e("Failed to build RaygunMessage - " + e);
}
return null; // -------------------------> Somebody wasn't thinking straight :P. The catch above shouldn't even be there!
}
This issue Could be related to #44
The builds are now using Gradle 7.x, which is current as of AS Giraffe 2022.3.1+.
There is Gradle 8 already on the horizon and it's known to cause a variety of issues when upgrading regarding required changes to build flows.
This should be upgraded as soon as possible.
RaygunClient.attachPulse(this); // taking an activity reference
Could'nt it use an applicationContext?
Since we attach it on SplashActivity meant it kept splashActivity alive throughout application lifecycle
using implementation 'com.mindscapehq.android:raygun4android:3.0.3' on build.gradle
Raygun uses OkHttpClient to make it's posts.
Use Case:
Problem:
The default SSLContext will fail to handshake and the requests will fail.
Solution:
Allow a SSLContext to be supplied to RaygunSettings that will be set on the OKHttpClient:
new OkHttpClient.Builder()
.sslSocketFactory(sslContext.getSocketFactory())
This would be needed in both post services
https://github.com/MindscapeHQ/raygun4android/blob/master/provider/src/main/java/com/raygun/raygun4android/services/CrashReportingPostService.java#L114
https://github.com/MindscapeHQ/raygun4android/blob/master/provider/src/main/java/com/raygun/raygun4android/services/RUMPostService.java#L69
Hello,
after following your instructions for Gradle dependencies, I get this compilation error:
Dependency com.mindscapehq.android:raygun4android:1.2.0 on project Application resolves to an APK archive which is not supported as a compilation dependency. File: C:\Users\Igor.gradle\caches\modules-2\files-2.1\com.mindscapehq.android\raygun4android\1.2.0\762ffb14c64e8dffedf6ac6f0431d83755caefc3\raygun4android-1.2.0.apk
Please advise,
Igor
That's an interesting question because the file gets created by default when you setup a project and has
app_name
in there, in case you want to use it - I guess. We didn't use the resource in the provider, so I emptied it. I'd be cautious with removing it - but I'll give that a try in the next piece of work. Right now it doesn't really bother me being there.
Originally posted by @TheRealAgentK in #88 (comment)
Code:
try {
return new Gson().fromJson(jsonStr, X.class);
}
catch (Exception ex) {
return new X();
}
new Gson().fromJson()
throws JsonSyntaxException
which is still caught by app-wide 'UncaughtExceptionHandler' instantiated via RaygunClient.AttachExceptionHandler()
- even though exception is being caught.
Could this be due to being called from within an IntentService
(so background)..?
The Raygun dashboard for my app does not have an option to upload an R8 mapping file. Will Raygun support this in the near future like it currently does for Proguard?
https://github.com/MindscapeHQ/raygun4android/blob/master/src/main/java/com/mindscapehq/android/raygun4android/messages/RaygunEnvironmentMessage.java#L95
The Disk space calculations use an integer when it should be using a long.
Integer.MaxValue() is approx 23^1 - 1
A GigaByte is 2^30
So anything over 2 Gigs overflows
See:
https://developer.android.com/reference/android/os/StatFs.html#getAvailableBlocksLong()
https://developer.android.com/reference/android/os/StatFs.html#getBlockSizeLong()
The package naming in the :app
module has sample
somewhat doubled-up.
package com.raygun.raygun4androidsample.sample
Refactor into a simpler path.
this repo has not been updated for a bout an year. I was trying to disable Jetifier on my project and this is the only project left.
so how are you guys doing? actually I could update this project myself and send pr, will you guys accept it?
....now that we're on modern Java
Is there proper support for fragments in RUM?
What is the solution for apps that use a single activity?
I'm currently using public static void sendRUMTimingEvent(RaygunRUMEventType eventType, String name, long milliseconds)
but there doesn't seem to be a way to track viewing time.
In the RUM web console, I am able to see the different fragments loaded (by sending a RUMTimingEvent with ACTIVITY_LOADED event type), but viewing time is not correct. As far as I can tell the 'Viewing Time' is calculated as the duration between the current RUM Timing Event and the next Timing Event. Since network requests are also tracked as RUM Timing Events, Fragments that make a network requests report false viewing times (i.e. time from Fragment load to next network event, not the time until next Fragment event).
Hi team,
<service android:name="com.raygun.raygun4android.services.CrashReportingPostService"
android:exported="false"
android:permission="android.permission.BIND_JOB_SERVICE"
android:process=":crashreportingpostservice"/>
Is it safe if I remove android:process=":crashreportingpostservice
so CrashReportingPostService
will run only in main process? My intention is, I want to make sure my Application only run in one process, Pls advise.
Thanks.
RaygunClient class method spinUpService(String apiKey, String jsonPayload, boolean isPulse) can print user's sensitive data using System.out.println, this line should be removed from the method.
2019-06-28 14:41:08.927 11019-11019/? W/System.err: java.lang.NullPointerException: Attempt to invoke interface method 'boolean java.util.List.add(java.lang.Object)' on a null object reference
2019-06-28 14:41:08.927 11019-11019/? W/System.err: at com.raygun.raygun4android.CrashReporting.recordBreadcrumb(CrashReporting.java:65)
2019-06-28 14:41:08.927 11019-11019/? W/System.err: at com.raygun.raygun4android.CrashReporting.recordBreadcrumb(CrashReporting.java:61)
2019-06-28 14:41:08.927 11019-11019/? W/System.err: at com.raygun.raygun4android.RaygunClient.recordBreadcrumb(RaygunClient.java:216)
https://docs.oracle.com/javase/7/docs/api/java/io/File.html#listFiles()
listFiles() can return null in some cases and raygun errors on it rather than handling gracefully.
Timber appears to have several embedded lint rules, of which one is particularly annoying. The LogNotTimber lint rule which gets inherited by anybody including Raygun, causes all uses of Log to have a lint warning that it should be using Timber.
This cannot be easily worked around, as Android Studio Code inspection profiles are per computer and not something that can be commited into a shared code repository.
I don't think we should have to use Timber in order to use raygun.
I added Raygun for my app, following the instructions provided by the official documentation.
After roll out to production, I'm receiving numerous crashes in Firebase Crashlytics, caused by the RUM process of Raygun added in the AndroidManifest.
The Stacktrace of the exception is:
Fatal Exception: java.lang.RuntimeException
Using WebView from more than one process at once with the same data directory is not supported. https://crbug.com/558377 :
Current process com.example.package:rumpostservice (pid 1479), lock owner com.example.package (pid 30096)
Obviously, "com.example.package" is not the real package name of the app.
Can anyone help me with this issue?
iOS equivalent:
message - reason
classname - exception name
Will be useful for consistency in Flutter plugin.
I've recently seen this popping up a bit in the ANR & crashes section in Play Console:
java.lang.NullPointerException
main.java.com.mindscapehq.android.raygun4android.RaygunPostService.hasInternetConnection
Samsung Galaxy S7 Edge (hero2lte), 4096MB RAM, Android 7.0
Report 5
java.lang.NullPointerException:
at main.java.com.mindscapehq.android.raygun4android.RaygunPostService.hasInternetConnection (RaygunPostService.java:93)
at main.java.com.mindscapehq.android.raygun4android.RaygunPostService.access$000 (RaygunPostService.java:18)
at main.java.com.mindscapehq.android.raygun4android.RaygunPostService$1.run (RaygunPostService.java:41)
at java.lang.Thread.run (Thread.java:762)
Looking at the code, it seems that cm might be null.
I feel that we should start removing "User" when referencing custom data. Every discussion we have at Raygun we never say UserCustomData, it's always CustomData. I think we should remove it for the 4.0.0 release. I am planning on redoing the API spec for providers this year and thats one thing I want to change. The json payload will still need send it as "userCustomData" but the API can have it removed.
Originally posted by @mduncan26 in #56
RaygunClientMessage line 10:
setVersion("3.0.0");
Expected: Always gets set to the current version of the provider. Ideally should be pulled from pom/manifest at runtime.
Some instrumentation tests for :app would be useful to ensure it launches and behaves correctly.
Consequently RaygunClient.setOnBeforeSend() method can't be used.
Keep our lawyers happy by adding a license file. ๐
The parts of the build that publish to library repos are currently not working again yet and this process needs to be upgraded/revamped as well.
It seems that quite often with devices in Wifi, the provider only logs an internal/NAT IP address.
That's not ideal for cross referencing data with other services and monitoring.
Tested with RG4A 3.0.x
a) Check if that's still the case with 4.x
b) If yes, look into a better solution and viability of other means to collect an external IP
Add Customer-functions in 4.1, deprecate User-functions.
In 5.0 (breaking release) remove User-functions and only provide Customer-API.
Bump OKHttp should be bumped to 4.x if we can. Needs a closer look because v4 has a bunch of API changes that could hit the :provider
module.
Using an Android device connected via ethernet to a ECU/Gateway.
If the Android device has a connection to a host, it can still fail to send, and the message will not be cached.
RaygunPostService.java, Line 43
if (isPulse && hasInternet) {
RaygunClient.postPulseMessage(apiKey, message);
} else if (!isPulse && hasInternet) {
RaygunClient.post(apiKey, message); // This can fail and does not end up cached
} else if (!isPulse && !hasInternet) {
// Caches to filesystem
currently using a work around, but may be other effects from this use case
boolean store = !hasInternet && !isPulse;
if (isPulse && hasInternet) {
RaygunClient.postPulseMessage(apiKey, message);
} else if (!isPulse && hasInternet) {
if (RaygunClient.post(apiKey, message) == -1) store = true;
}
if (store) {
// Caches to filesystem
I am using android studio 1.4.1
build.xml:
buildscript {
repositories {
jcenter()
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
}
}
Thanks and looking forward to your reply!
Android 6.0 ( M ) does not support Apache Http Library anymore.
The documentation suggests to use HttpUrlConnection implementation instead.
You can still use Apache library by changing build file to use legacy Apache library, but it's just a temporary resolution.
Since Raygun is not supporting Android 2.2 or under, remove dependency on Apache Http library can be done without any dependency problems.
Check out the following link.
http://developer.android.com/preview/behavior-changes.html#behavior-apache-http-client
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.