Android acra exception - android

I just set up ACRA for exception reporting on Android, and on my local simulator, I get this exception:
and here is my class:
package com.problemio;
import android.app.Application;
import org.acra.*;
import org.acra.annotation.*;
#ReportsCrashes(formKey = "...")
public class MyApplication extends Application
{
#Override
public void onCreate()
{
// The following line triggers the initialization of ACRA
ACRA.init(this);
super.onCreate();
}
}
How should I change the code to make it right? Thanks!!!

Making my comment an answer, because it solved the issue:
Such spread sheet does not exist, or at least when I point my browser to this address (https://spreadsheets.google.com/formResponse?formkey=0AteWveJtbl4GdDA2WWsyRE5Nb‌​EtJM2hmbmd5NVhxM3c&ifq) it says so. Make sure you have the form key entered correctly.

Related

Unable to log output in new android studio

I am new to Android Studio. I successfully created a Hello World app from the example in Android website. Now, I want to play around by using some statement to print in the logcat but it doesn't works. Below is my ApplicationTest.java code:
package com.example.abc.myloggingapplication;
import android.app.Application;
import android.test.ApplicationTestCase;
import android.util.Log;
/**
* Testing Fundamentals
*/
public class ApplicationTest extends ApplicationTestCase<Application> {
public ApplicationTest() {
super(Application.class);
Log.d("MyTest", "Here goes the output!"); // THIS IS THE NEW STATEMENT INSERTED BUT PRINTS NOTHING IN CONSOLE LOG IN ANDROID STUDIO SDK.
}
}
Other files are same as provided by the Hello World example in Android website. In Android Studio sdk, I entered the logcat to debug but still no luck. Can anybody point me out where I am going wrong.
Check your logcat:
Check View -> Tool windows -> Android Monitor.
Or Alt + 6
If that doesnt help, make sure you have an instance of your class. Otherwise the constructor is never called and therefor the log.d is never called.
Edit:
As other's have stated: Check if you are running the Test Application, if you want to do so. Otherwise make sure you code in your actual application and not your test application.

why am i getting an Error Unable to open debugger port (127.0.0.1:58061): java.net.SocketException "socket closed"

I am just trying to run a simple test on my "hello world" programme in android studio , the programme is below:
package com.example.gautam.droidone.tests;
import android.test.ActivityInstrumentationTestCase2;
import android.widget.TextView;
import com.example.gautam.droidone.MainActivity;
import com.example.gautam.droidone.R;
import android.util.Log;
/**
* Testing Fundamentals
*/
public class MainActivityTest extends ActivityInstrumentationTestCase2<MainActivity> {
MainActivity activity;
public MainActivityTest() {
super(MainActivity.class);
}
#Override
protected void setUp() throws Exception {
super.setUp();
activity = getActivity();
}
public void testMainActivity() {
TextView textView = (TextView) activity.findViewById(R.id.hello_world);
Log.d("MainActivityTest", textView.getText().toString());
assertNotNull(textView);
}
}
When i click on the debug button, i get the following error in the console:
Error running MainActivityTest: Unable to open debugger port (127.0.0.1:58061): java.net.SocketException "socket closed".
Similar so threads:
Thread 1
Thread 2
Thread 3
I googled the error and found a few solutions to the problem, most of them did't work, then i saw THIS article and in the comments section a few people have suggested that you need to turn off build-process. how do you do that , on reading more on google , i found that since android 1+ this option is no longer available , so how do i turn off build process ? and once again why am i getting this error:
Error running MainActivityTest: Unable to open debugger port
(127.0.0.1:58061): java.net.SocketException "socket closed"
I had the same problem. My fault that in the tool bar the wrong target was selected.
It has to be "App". It can easily been selected wrong with a single unintended mouseclick.
So check if there is "App" or something like "assemble".

Collecting stacktrace of crashing widget with ACRA Android

I am trying to debug the widget of the app I'm developing with ACRA but I have a problem. I use the following code to collect the StackTrace:
import org.acra.ACRA;
import org.acra.ReportingInteractionMode;
import org.acra.annotation.ReportsCrashes;
import android.app.Application;
#ReportsCrashes(formKey = "",
resToastText = R.string.crash_toast_text, mailTo = "mailAddress", mode = ReportingInteractionMode.TOAST, logcatArguments = {
"-t", "100", "-v", "long", "ActivityManager:I", "MyApp:D", "*:S" })
public class MyApplication extends Application
{
#Override
public void onCreate()
{
super.onCreate();
// The following line triggers the initialization of ACRA
ACRA.init(this);
}
}
The problem is that it happens on Samsung devices that the widget become unresponsive after a random amount of time and I have no idea what is causing it (I never call onUpdate so nothing should happen but this is another story). I'd like to use ACRA to collect the StackTrace when it becomes unresponsive but when, for example, I turn on the screen after 10 minutes and see the widget not working I have no message from ACRA that has collected a crash report to send me an email and see the problem.
Is maybe ACRA not working?
If the widget is not responsive (the buttons for example) it means it crashed right?
Do you have any better strategy to debug this situation?
Thank you very much
If the widget is not responsive, then it hasn't crashed, it is in some kind of deadlock or waiting state. That is why you haven't received any message from ACRA.
Either looks at what the threads are doing, or injecting a healthy amount of debug to try to determine what has locked up the app.

How can I get ACRA working with Phonegap on Android?

I have a PhoneGap application that works fine but occasionally is known to have bugs. I would like to catch them and send them to a Google Doc with ACRA
I have been following the ACRA wiki steps here http://code.google.com/p/acra/wiki/BasicSetup?tm=6
The ACRA documentation says I should create an Application class and then point my AndroidManifest at it by naming the Application the same as that class.
That didn't work, or at least it didn't catch any errors I tested it with.
I thought this would be the best bet, but it isn't logging anything and still Force Closes the app when I force a NullPointer exception error.
#ReportsCrashes(formKey = "dFhqOGY3cVVGc0w4UUxGa2E2Y3RL...",
mode = ReportingInteractionMode.NOTIFICATION)
public class myPhoneGap extends DroidGap
{
#Override
public void onCreate(Bundle savedInstanceState)
{
ACRA.init(this.getApplication());
super.onCreate(savedInstanceState);
super.init();
super.loadUrl("file:///android_asset/www/index.html");
}
}
I'm pretty sure you have to set up another activity that extends Application like this:
package jq.test;
import android.app.Application;
import org.acra.*;
import org.acra.annotation.*;
#ReportsCrashes(formKey = "xxxxxxxxxxxxxxxxxxxxxxxxx")
public class MyApplication extends Application {
#Override
public void onCreate() {
// The following line triggers the initialization of ACRA
ACRA.init(this);
super.onCreate();
}
}
and then in your manifest change the name of the application to the name of the class. I'm pretty sure that that's it but I have a question for you.....how do you get the formkey from Google Docs? I can't remember how to do that lol and its not posted anywhere. It really should be in the acra wiki but its not.

android - how to implement the logging [duplicate]

This question already has answers here:
capturing and sending logcat output by email or to server
(2 answers)
Closed 9 years ago.
I installed the .apk file in the device then run that application at this time suppose i am getting any exception then application will be crash. At this time i want to see that exception in the device without using Eclipse Logcat. It means i want send that exception to file(means some path in the device like sdcard/downloads/a.txt)in the device using Log.
Generally some applications are working properly in the emulator but in case of device we got some exceptions. so thats why i want see that particular exception in the device using Log.
Is it possible? How can i implement this? can anybody help me.
Myapplication classs:
package com.ibkr.roadbrake;
import org.acra.*;
import org.acra.annotation.*;
import android.app.Application;
import android.os.Bundle;
#ReportsCrashes(formKey = "dDJ5VFhURVNHakhSa3hfTndteFd6Smc6MQ")
public class MyApplication extends Application
{
#Override
public void onCreate()
{
// The following line triggers the initialization of ACRA
ACRA.init(this);
super.onCreate();
}
public Bundle getCrashResources()
{
Bundle result = new Bundle();
String RES_TOAST_TEXT = null;
result.putInt(RES_TOAST_TEXT, R.string.crash_toast_text);
return result;
}
}
thanks
Log4j or slf4j can also be used as logging frameworks in Android together with logcat. See the project android-logging-log4j and log4j support in Android. Configuring logging to a (rotating) file(s) is very easy.
static {
final LogConfigurator logConfigurator = new LogConfigurator();
logConfigurator.setFileName(Environment.getExternalStorageDirectory() + "myapp.log");
logConfigurator.setRootLevel(Level.DEBUG);
// Set log level of a specific logger
logConfigurator.setLevel("org.apache", Level.ERROR);
logConfigurator.configure();
}

Categories

Resources