I've implemented ACRA 4.8.5 in my app and it is initialized and enabled and all but when I face a bug, it doesn't create a report... The only two related ACRA logs I have are:
I/ACRA: ACRA is enabled for com.mydomain.myapp, initializing...
and
E/ACRA: ACRA caught a RuntimeException for com.mydomain.myapp
I have this in my application class
#ReportsCrashes(reportSenderFactoryClasses = {ACRASenderFactory.class})
and
#Override
public void onCreate() {
super.onCreate();
ACRA.init(this);
}
Here is my ACRASenderFactory class
public class ACRASenderFactory implements ReportSenderFactory {
public ACRASenderFactory(){
Log.e("ACRA", "Create Sender Factory");
}
#NonNull
#Override
public ReportSender create(Context context, ACRAConfiguration acraConfiguration) {
Log.e("ACRA", "Return Report Sender");
return new ACRAReportSender();
}
}
and here is my ACRAReportSender class
public class ACRAReportSender implements ReportSender {
public ACRAReportSender(){
Log.e("ACRA", "Report Sender created");
}
#Override
public void send(Context context, CrashReportData crashReportData) throws ReportSenderException {
Log.e("ACRA", "Trying to send crash report");
String reportBody = createCrashReport(crashReportData);
// Send body using email
Intent emailIntent = new Intent(Intent.ACTION_SEND);
// Set type to "email"
emailIntent.setType("vnd.android.cursor.dir/email");
String to[] = {"me#mydomain.com"};
emailIntent.putExtra(Intent.EXTRA_EMAIL, to);
// Text
emailIntent.putExtra(Intent.EXTRA_TEXT, reportBody);
// Set the subject
emailIntent.putExtra(Intent.EXTRA_SUBJECT, "ACRA Crash Report");
context.startActivity(Intent.createChooser(emailIntent, "Send crash to developpers by email ..."));
}
private String createCrashReport(CrashReportData crashReportData){
StringBuilder body = new StringBuilder();
body.append("Device : " + crashReportData.getProperty(ReportField.BRAND) + " - " + crashReportData.getProperty(ReportField.PHONE_MODEL))
.append("\n")
.append("Android Version : " + crashReportData.getProperty(ReportField.ANDROID_VERSION))
.append("\n")
.append("App Version : " + crashReportData.getProperty(ReportField.APP_VERSION_CODE))
.append("\n")
.append("STACK TRACE : \n" + crashReportData.getProperty(ReportField.STACK_TRACE));
return body.toString();
}
}
I really don't know why it's not working.. I've also allowed Internet in my Manifest and set my app name.
Any help would be really appreciated!
Thanks!
As discussed on the ACRA GitHub issue, ACRA has shipped as an AAR for some time now. So you need to build and include the AAR, not the JAR (which you must have dug out of the AAR).
ACRA requires Android services and resources in order to run.
My problem (I think) was that I am developping for API 15 and up. Using ACRA 4.8.5 might have been the problem since using ACRA 4.7.0 works just fine!
Related
I am getting the error on the following line:
AgoraAPIOnlySignal m_agoraAPI = AgoraAPIOnlySignal.getInstance(this, appID);
in AGApplication. Can anyone let me know where I am going wrong?
In case you need the stack trace
java.lang.UnsatisfiedLinkError: No implementation found for void io.agora.NativeAgoraAPI.jniInitGet() (tried Java_io_agora_NativeAgoraAPI_jniInitGet and Java_io_agora_NativeAgoraAPI_jniInitGet__)
at io.agora.NativeAgoraAPI.jniInitGet(Native Method)
at io.agora.AgoraAPIOnlySignal.getInstance(AgoraAPIOnlySignal.java:60)
at live.smartify.community.smartliving.security.application.AGApplication.setupAgoraEngine(AGApplication.java:82)
at live.smartify.community.smartliving.security.application.AGApplication.onCreate(AGApplication.java:67)
The Agora Signaling SDK is a separate SDK that is not bundled with Agora's native SDKS, so you do have to download and link/add to your project separately from the Native SDK.
The Agora Signaling SDK has been deprecated, you should use Agora.io's RTM SDK, it has all the features of the Signaling SDK along with some new ones.
Make sure to download the SDK and link it within your project. Once you have the SDK installed in your project you can init using:
public void init() {
try {
mRtmClient = RtmClient.createInstance(mContext, APPID, new RtmClientListener() {
#Override
public void onConnectionStateChanged(int state, int reason) {
Log.d(TAG, "Connection state changes to " + state + " reason: " + reason);
}
#Override
public void onMessageReceived(RtmMessage rtmMessage, String peerId) {
String msg = rtmMessage.getText();
Log.d(TAG, "Message received " + " from " + peerId + msg);
}
});
} catch (Exception e) {
Log.d(TAG, "RTM SDK initialization fatal error!");
throw new RuntimeException("You need to check the RTM initialization process.");
}
}
See Full Android RTM SDK QuickStart Guide: https://docs.agora.io/en/Real-time-Messaging/messaging_android?platform=Android
I have a retrofit call to my server that returns JSON data. I have been working on the debug build since the first day and everything looked fine. Just yesterday I generated a release build (android) and found the call is failing with exception as "HTTP 500, internal server error".
I am unable to understand what is the difference between the two that I fall into such a state.
Code to make the retrofit is as under,
public void populateFeeds(final String market, final String category, final String msaToken, final String language, final List<CategorizedFeeds> categorizedFeedsList){
VmFeedsHub.this.feedClusterDataSetUpdate.set(false);
VmFeedsHub.this.feedCategoryDataSetUpdate.set(false);
BackendFactory.getFeedsServiceBackend().getFeedsMetadata(market, category, null, null)
.observeOn(AndroidSchedulers.mainThread())
.subscribe(new Subscriber<Feeds>() {
#Override
public void onCompleted() {
}
#Override
public void onError(Throwable e) {
ALog.i(TAG, LOG_PREFIX + " Feeds data retrieved empty/null for market: " + market + " with exception: " + e.getMessage());
}
#Override
public void onNext(Feeds feeds) {
ALog.i(TAG, LOG_PREFIX + " Feeds data retrieved successfully with feed count: " + feeds.getFeedsMetaDataArrayList().size() + " for market: " + market);
for (CategorizedFeeds categorizedFeeds : feeds.getFeedsMetaDataArrayList()) {
List<FeedMetadata> feedMetadataList = new ArrayList<>();
for(FeedsMetadata feedsMetadata : categorizedFeeds.getFeedsMetadataArrayList()){
FeedMetadata feedMetadata = new FeedMetadata(feedsMetadata.getHeadlineText(), feedsMetadata.getHeadlineImageURL(), feedsMetadata.getProviderName(), feedsMetadata.getProviderImageURL(), feedsMetadata.getPublishedDateTime(), feedsMetadata.getFeedURL(), feedsMetadata.getCmsId());
feedMetadataList.add(feedMetadata);
}
CategorizedFeeds categorizedFeed = new CategorizedFeeds(categorizedFeeds.getCategory(), feedMetadataList);
categorizedFeedsList.add(categorizedFeed);
}
if(category.equals(CATEGORY_CLUSTER))
VmFeedsHub.this.feedClusterDataSetUpdate.set(true);
else
VmFeedsHub.this.feedCategoryDataSetUpdate.set(true);
}
});
}
My solution for this issue is to keep the model classes for retrofit.
Add this code in your proguard-rules.pro file
# keep model classes for retrofit
# packagename.directory.** { *; }
-keep class com.packagename.mac.model.** { *; }
-keep class com.packagename.mac.data.response.** { *; }
I figured out the problem here was with the POST body that I was sending. In the custom Object the proguard was renaming the variables and hence server was unable to intercept them. Added #SerializedName annotation fixed the issue.
-keep class com.packagename.path_name_to_models
give the path to the model classes you are using, the issue will be solved
I am using firebase crash in my cordova application and I want to capture all logs ( Log.e ) in my application as follows.
Login => {"userName" : "jhon" , "networkConnection": "on" ,
"status":"success"}
AddContact => {"userName" : "jhon" , "networkConnection": "on" ,
"status":"success", "contactId" :"3233"}
But I have noticed one thing is that if my app gets crashed then only I am able to see logs without that I can't see the normal logs when I app do not crash.
For example ,
In following code
If I explicitly call FirebaseCrash.report(new Exception(name)); then only FirebaseCrash.logcat(Log.ERROR, name, params + " "+message); appears in firebase crash report.
If I only write FirebaseCrash.report(new Exception(name)); then only FirebaseCrash.logcat(Log.ERROR, name, params + " "+message); the these logs are not coming to the server.
private void logCrash(final CallbackContext callbackContext, final String name, final String params,final String message){
cordova.getThreadPool().execute(new Runnable() {
#Override
public void run() {
FirebaseCrash.logcat(Log.ERROR, name, params + " "+message);
FirebaseCrash.report(new Exception(name));
}
});
callbackContext.success();
}
I've got a Xamarin Android app that have Debug.WriteLine statements throughout the app. These statements appear in the Xamarin console, but I would like them to also be appended to a log file on the phone SD Card.
I think I could develop my own solution, but I'm wondering if there's a built-in way to do this?
I dont think there is a built in way to do this but a simple code can do it for you -
using System;
namespace Com.Osfg
{
public class LogUtils
{
String logFilePath = null;
public LogUtils()
{
String path = Android.OS.Environment.ExternalStorageDirectory.Path;
logFilePath = System.IO.Path.Combine(path, "log.txt");
if(!System.IO.File.Exists(logFilePath))
{
using (System.IO.StreamWriter writer = new System.IO.StreamWriter(logFilePath, true))
{
writer.WriteLine("Starting logging at " + DateTime.Now.ToString());
}
}
}
public void Log(String message)
{
using (System.IO.StreamWriter writer = new System.IO.StreamWriter(logFilePath, true))
{
writer.WriteLine(DateTime.Now.ToString() + " : " + message);
}
}
}
}
Android has a built in logging function you can use, Android.Util.Log
string tag = "myapp";
Log.Info (tag, "this is an info message");
Log.Warn (tag, "this is a warning message");
Log.Error (tag, "this is an error message");
Hi I'm using this GCM notification plugin for android and works almost perfect, the only issue I have is when the user force close my app or when the device is shutted down the notification service stops working.
I've looked the plugin code problem and realized that the following function causes the problem.
public static void sendJavascript( JSONObject _json )
{
String _d = "javascript:"+gECB+"(" + _json.toString() + ")";
Log.v(ME + ":sendJavascript", _d);
if (gECB != null ) {
gwebView.sendJavascript( _d );
}
}
When the device is shutted down and then turned on or the application is force closed, gwebView reference is lost. If I try to use the method gwebView.sendJavascript( _d ) I get a null pointer exception.
Reviewing the plugin code I noticed that gwebView is referenced when registering the device just as this code shows:
public static Plugin gwebView;
private static String gECB;
private static String gSenderID;
#SuppressWarnings("deprecation")
#Override
public PluginResult execute(String action, JSONArray data, String callbackId)
{
PluginResult result = null;
Log.v(ME + ":execute", "action=" + action);
if (REGISTER.equals(action)) {
Log.v(ME + ":execute", "data=" + data.toString());
try {
JSONObject jo= new JSONObject(data.toString().substring(1, data.toString().length()-1));
gwebView = this;
..............................More code here......................
The notifications are received on background but I can't invoke any javascript methods since gwebView points nothing.
My approach is to show a generic notification on statusbar whenever gwebView has a null pointer but I just don't know how to get the application or cordova context in order to use this function.
Any help would be appreciated, thanks
I found in google forums that this is a bug of the plugin so I decided to use Pushwhoosh notification service.