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.
Related
Since a couple of weeks, I'm seeing more and more crashes of my app with the following exception
Fatal Exception: java.lang.NoClassDefFoundError
android.os.AsyncTask
This code has run for month without any issue, and it seems now to fail on some devices (75% android 2.3.x and 25% android 4.0.3)
It fails when I create a new instance of a class which extends AsyncTask.
I create this class from the UI thread.
How can that class be not found as it's defined within the SDK ?
Yes, looks like it is a problem with one of the versions of Google play Services. See https://code.google.com/p/android/issues/detail?id=81083
A work around is to add:
try {
Class.forName("android.os.AsyncTask");
}
catch(Throwable ignore) {
// ignored
}
into your Application#onCreate()
this appears to ensure that the root classloader loads AsyncTask so that it is then available from within Play Services.
It looks like yet another Google Play Services bug...
https://groups.google.com/forum/#!topic/google-admob-ads-sdk/_x12qmjWI7M
Edit: confirmed by Google staff => https://groups.google.com/d/msg/google-admob-ads-sdk/_x12qmjWI7M/9ZQs-v0ZZTMJ
Same issue here.
I see them for 95% of the cases on android 4.0.3 devices. remaining 5% for 2.3 devices
Errors are randomly occurring from different parts of the code.
Some examples:
java.lang.NoClassDefFoundError: android/os/AsyncTask
at android.webkit.WebView.setupPackageListener(WebView.java:1305)
at android.webkit.WebView.<init>(WebView.java:1176)
at android.webkit.WebView.<init>(WebView.java:1136)
and
java.lang.NoClassDefFoundError: android/os/AsyncTask
at android.webkit.WebView.setupPackageListener(WebView.java:1354)
at android.webkit.WebView.access$10900(WebView.java:363)
at android.webkit.WebView$PrivateHandler.handleMessage(WebView.java:10411)
and
java.lang.NoClassDefFoundError: android.os.AsyncTask
at android.webkit.WebView.setupPackageListener(WebView.java:1385)
at android.webkit.WebView.<init>(WebView.java:1192)
at android.webkit.WebView.<init>(WebView.java:1150)
at android.webkit.WebView.<init>(WebView.java:1135)
at android.webkit.WebView.<init>(WebView.java:1106)
at android.webkit.WebView.<init>(WebView.java:1093)
at com.google.android.gms.ads.internal.util.g.f(SourceFile:400)
at com.google.android.gms.ads.internal.util.g.a(SourceFile:385)
it is completely unclear why these errors are happening. usually i dont see anything in the stacktrace pointing to my code.
I have the same error:
BuscaDatosJugador().execute(participante.getIconImageUrl(),String.valueOf(altoenvio), String.valueOf(contador));
My solution:
final Runnable r = new Runnable()
{
public void run()
{
try {
--- my code ---
}
};
r.run();
}
I experienced same error on android 2.3.3, but same app was stable on 4.0+. It's a Freemium and the error occurs only when in FREE mode, which runs Google Admob adverts. So the error has to be connected with this but I do no have the detail. Here is how I solved the problem:
Execute a statement that would cause the AsyncTask class to be loaded before loading the ads.
steps 1: Create a dummy AsyncTask extension class
public class DummyAsyncTask extends AsyncTask<Void, Void, Void>{
#Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
return null;
}
}
step 2: just in your main activity:
public class MainActivity extends Activity {
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
new DummyAsyncTask();
.
.some code
.
load your ads here
}
}
After step 2 above, all other code section that instantiates AsyncTask extended class run normally.
I did everything properly, by useingdebug.keystore I generated my MD% code and I got my Valid API key from google website and I gave permission for using internet connection in MasinFest.xmland used my mapping key value in main.xml.and in MapActivity File I simply used this below code
import com.google.android.maps.MapActivity;
import com.google.android.maps.MapView;
import android.os.Bundle;
public class MapsActivity extends MapActivity
{
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
}
#Override
protected boolean isRouteDisplayed() {
return false;
}
}
I am using Android 4.0.3 version and Google API Level 15, I am Getting Error as 05-22 10:32:42.086: E/MapActivity(656): Couldn't get connection factory client in LogCat.. Help me regarding this please.. Thanks in Advance
well you are trying to import the classes of google maps. for that purpose you need to be sure that google maps app is already installed on the device you are trying to work on. unless it finds google maps application on your device your application wont work.
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=0AteWveJtbl4GdDA2WWsyRE5NbEtJM2hmbmd5NVhxM3c&ifq) it says so. Make sure you have the form key entered correctly.
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();
}
Hey,
So im newish to android and Im lost because although my code uses AsyncTask for it's heavy lifting I am still getting a ANR error when I run my one class. So here is the relevant peices of my code:
package com.cody.color;
import android.app.Activity;
import android.os.Bundle;
public class Play extends Activity{
#Override
protected void onCreate(Bundle savedInstanceState) {
// TODO Auto-generated method stub
super.onCreate(savedInstanceState);
System.out.println("about to start threader");
new GuiThreader().execute();
System.out.println("Threader finished");
setContentView(R.layout.colorboard_small);
}
}
package com.cody.color;
import android.os.AsyncTask;
public class GuiThreader extends AsyncTask<Void, Void, Void>{
#Override
protected Void doInBackground(Void... params) {
// TODO Auto-generated method stub
System.out.println("threader moving");
GUIdriver game = new GUIdriver();
game.play();
return null;
}
}
There aren't any problems with the code above that would cause an ANR, so most likely one of the following is happening:
You are trying to modify the user interface (UI) from doInBackground
An exception is occuring in your doInBackground
If you post the LogCat output or stacktrace when you get the error then it will be easier to identify.
welcome to the world of JAVA programming :) When you encounter an error your best tool to solve it is usually going to be a stacktrace. You need to learn how to analyze a stacktrace and also to include it in your questions...
What is a stacktrace you ask? The simplistic answer is that a stacktrace is an error message (although it contains a lot more info than only that). In case of an exception it tells the programmer WHAT happened, WHERE it happened and WHEN it happened. If you want to program in JAVA you need to get yourself quite familiar with them. I recommend you read some JAVA tutorials before diving into Android development.
As for your code, without the stacktrace I cannot say more... there is no obvious error except the fact that game.play(); looks like it might contain some changes to the UI, which are not allowed in another thread than the main thread (that's why AsyncTask has onPostExecute());