Android Application Crashes in Emulator - android

My Android application crashes in the emulator with, with the following being output to the logs:
09-26 14:04:02.123: D/dalvikvm(716): GC_FOR_ALLOC freed 66K, 6% free 2675K/2844K, paused 29ms, total 30ms
09-26 14:04:02.123: I/dalvikvm-heap(716): Grow heap (frag case) to 3.455MB for 782224-byte allocation
09-26 14:04:02.173: D/dalvikvm(716): GC_FOR_ALLOC freed 2K, 5% free 3437K/3608K, paused 42ms, total 42ms
09-26 14:04:02.303: D/dalvikvm(716): GC_FOR_ALLOC freed <1K, 5% free 3436K/3608K, paused 38ms, total 39ms
09-26 14:04:02.314: I/dalvikvm-heap(716): Grow heap (frag case) to 4.778MB for 1389712-byte allocation
09-26 14:04:02.363: D/dalvikvm(716): GC_FOR_ALLOC freed <1K, 4% free 4793K/4968K, paused 52ms, total 52ms
09-26 14:04:02.423: D/AndroidRuntime(716): Shutting down VM
09-26 14:04:02.423: W/dalvikvm(716): threadid=1: thread exiting with uncaught exception (group=0x414c4700)
09-26 14:04:02.433: E/AndroidRuntime(716): FATAL EXCEPTION: main
09-26 14:04:02.433: E/AndroidRuntime(716): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.sample_proj/com.example.sample_proj.MainActivity}: java.lang.NullPointerException
09-26 14:04:02.433: E/AndroidRuntime(716): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2211)
09-26 14:04:02.433: E/AndroidRuntime(716): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2261)
09-26 14:04:02.433: E/AndroidRuntime(716): at android.app.ActivityThread.access$600(ActivityThread.java:141)
09-26 14:04:02.433: E/AndroidRuntime(716): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1256)
09-26 14:04:02.433: E/AndroidRuntime(716): at android.os.Handler.dispatchMessage(Handler.java:99)
09-26 14:04:02.433: E/AndroidRuntime(716): at android.os.Looper.loop(Looper.java:137)
09-26 14:04:02.433: E/AndroidRuntime(716): at android.app.ActivityThread.main(ActivityThread.java:5103)
09-26 14:04:02.433: E/AndroidRuntime(716): at java.lang.reflect.Method.invokeNative(Native Method)
09-26 14:04:02.433: E/AndroidRuntime(716): at java.lang.reflect.Method.invoke(Method.java:525)
09-26 14:04:02.433: E/AndroidRuntime(716): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:737)
09-26 14:04:02.433: E/AndroidRuntime(716): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
09-26 14:04:02.433: E/AndroidRuntime(716): at dalvik.system.NativeStart.main(Native Method)
09-26 14:04:02.433: E/AndroidRuntime(716): Caused by: java.lang.NullPointerException
09-26 14:04:02.433: E/AndroidRuntime(716): at com.example.sample_proj.MainActivity.onCreate(MainActivity.java:21)
09-26 14:04:02.433: E/AndroidRuntime(716): at android.app.Activity.performCreate(Activity.java:5133)
09-26 14:04:02.433: E/AndroidRuntime(716): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
09-26 14:04:02.433: E/AndroidRuntime(716): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2175)
09-26 14:04:02.433: E/AndroidRuntime(716): ... 11 more
Would someone please help me in understanding why NullPointerException is being thrown and how I can resolve it?

Check this line in your MainActivity
MainActivity.java:21

You have probably used findviewbyid and the following happened
you forgot to put the line "setContentView" or put it after findviewbyid
or you put the contentView to the wrong layout
1 and 2 are not it, and you did findviewbyid to non existing id in the given layout- and tried to use that object aterwards, because the id is incorrect, the object returns null, and you are trying to use it

Related

Error while running application

08-07 11:18:38.353: D/dalvikvm(15215): GC_FOR_ALLOC freed 83K, 6% free 12813K/13599K, paused 21ms
08-07 11:18:38.363: I/dalvikvm-heap(15215): Grow heap (frag case) to 15.352MB for 2908176-byte allocation
08-07 11:18:38.393: D/dalvikvm(15215): GC_FOR_ALLOC freed 1K, 6% free 15652K/16483K, paused 12ms
08-07 11:18:38.413: D/dalvikvm(15215): GC_CONCURRENT freed <1K, 6% free 15652K/16483K, paused 2ms+2ms
08-07 11:18:38.443: D/dalvikvm(15215): GC_FOR_ALLOC freed <1K, 6% free 15652K/16483K, paused 15ms
08-07 11:18:38.443: I/dalvikvm-heap(15215): Grow heap (frag case) to 20.281MB for 5169196-byte allocation
08-07 11:18:38.463: D/dalvikvm(15215): GC_FOR_ALLOC freed 0K, 4% free 20700K/21539K, paused 13ms
08-07 11:18:38.483: D/dalvikvm(15215): GC_CONCURRENT freed <1K, 4% free 20700K/21539K, paused 2ms+2ms
08-07 11:18:38.543: D/AndroidRuntime(15215): Shutting down VM
08-07 11:18:38.543: W/dalvikvm(15215): threadid=1: thread exiting with uncaught exception (group=0x40ab2210)
08-07 11:18:38.553: E/AndroidRuntime(15215): FATAL EXCEPTION: main
08-07 11:18:38.553: E/AndroidRuntime(15215): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.demo/com.example.demo.MainActivity}: java.lang.ClassCastException: android.widget.ImageView cannot be cast to android.widget.Button
08-07 11:18:38.553: E/AndroidRuntime(15215): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1967)
08-07 11:18:38.553: E/AndroidRuntime(15215): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1992)
08-07 11:18:38.553: E/AndroidRuntime(15215): at android.app.ActivityThread.access$600(ActivityThread.java:127)
08-07 11:18:38.553: E/AndroidRuntime(15215): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1158)
08-07 11:18:38.553: E/AndroidRuntime(15215): at android.os.Handler.dispatchMessage(Handler.java:99)
08-07 11:18:38.553: E/AndroidRuntime(15215): at android.os.Looper.loop(Looper.java:137)
08-07 11:18:38.553: E/AndroidRuntime(15215): at android.app.ActivityThread.main(ActivityThread.java:4441)
08-07 11:18:38.553: E/AndroidRuntime(15215): at java.lang.reflect.Method.invokeNative(Native Method)
08-07 11:18:38.553: E/AndroidRuntime(15215): at java.lang.reflect.Method.invoke(Method.java:511)
08-07 11:18:38.553: E/AndroidRuntime(15215): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:823)
08-07 11:18:38.553: E/AndroidRuntime(15215): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:590)
08-07 11:18:38.553: E/AndroidRuntime(15215): at dalvik.system.NativeStart.main(Native Method)
08-07 11:18:38.553: E/AndroidRuntime(15215): Caused by: java.lang.ClassCastException: android.widget.ImageView cannot be cast to android.widget.Button
08-07 11:18:38.553: E/AndroidRuntime(15215): at com.example.demo.MainActivity.onCreate(MainActivity.java:16)
08-07 11:18:38.553: E/AndroidRuntime(15215): at android.app.Activity.performCreate(Activity.java:4465)
08-07 11:18:38.553: E/AndroidRuntime(15215): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
08-07 11:18:38.553: E/AndroidRuntime(15215): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1931)
i can run simple graphical-layout but whe i try to add some code onclick or any other its show me these errors. i deleted api 20 from sdk manager and trying to compile in api17. HOW TO SOLVE THESE ERRORS??????
this exception says that you was cast ImageView to Button .
Caused by: java.lang.ClassCastException: android.widget.ImageView cannot be cast to android.widget.Button
Please change (Button) To (ImageView) at Line No 16 in MainActivity.java

Why does startActivity cause crash?

Thank you guys! The reason is somewhere simpler than I think. I feel something futility.. :
-)
I have already added activity names on androidmanifest.xml.
My code is simple.
Intent intent=new Intent(MainActivity.this, AddAddressActivity.class);
intent.putExtra("respond", responsebody);
intent.putExtra("userid", txtID.getText().toString());
intent.putExtra("password", txtPW.getText().toString());
MainActivity.this.startActivity(intent);
just this.
Why are crashes caused in this code? I can't find on it.
But the more stranger thing is that crash aren't caused when I make AddAddressActivity like basic templete(source when it is made at first).
Then, is AddAddressActivity a problem?
Thanks to read my question. You could misunderstand it because of my short english. If you have something hard to understand, please ask me on comment.
Here is Logcat. I can't find reason in this text..
02-28 02:42:53.876: D/dalvikvm(6195): GC_FOR_ALLOC freed 122K, 19% free 9983K/12192K, paused 17ms, total 17ms
02-28 02:42:53.886: I/dalvikvm-heap(6195): Grow heap (frag case) to 15.536MB for 3936016-byte allocation
02-28 02:42:53.901: D/dalvikvm(6195): GC_FOR_ALLOC freed <1K, 14% free 13826K/16036K, paused 13ms, total 13ms
02-28 02:42:54.011: D/dalvikvm(6195): GC_FOR_ALLOC freed <1K, 14% free 13826K/16036K, paused 9ms, total 9ms
02-28 02:42:54.031: I/dalvikvm-heap(6195): Grow heap (frag case) to 30.549MB for 15744016-byte allocation
02-28 02:42:54.041: D/dalvikvm(6195): GC_FOR_ALLOC freed 0K, 8% free 29201K/31412K, paused 11ms, total 11ms
02-28 02:42:54.201: D/libEGL(6195): loaded /system/lib/egl/libEGL_mali.so
02-28 02:42:54.201: D/libEGL(6195): loaded /system/lib/egl/libGLESv1_CM_mali.so
02-28 02:42:54.206: D/libEGL(6195): loaded /system/lib/egl/libGLESv2_mali.so
02-28 02:42:54.211: E/(6195): Device driver API match
02-28 02:42:54.211: E/(6195): Device driver API version: 23
02-28 02:42:54.211: E/(6195): User space API version: 23
02-28 02:42:54.211: E/(6195): mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Wed Oct 30 09:36:10 KST 2013
02-28 02:42:54.276: D/OpenGLRenderer(6195): Enabling debug mode 0
02-28 02:43:02.696: I/webclipboard(6195): clipservice: android.sec.clipboard.ClipboardExManager#4419e048
02-28 02:43:02.711: D/AndroidRuntime(6195): Shutting down VM
02-28 02:43:02.711: W/dalvikvm(6195): threadid=1: thread exiting with uncaught exception (group=0x420ac700)
02-28 02:43:02.721: E/AndroidRuntime(6195): FATAL EXCEPTION: main
02-28 02:43:02.721: E/AndroidRuntime(6195): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.mcdelivery/com.example.mcdelivery.AddAddressActivity}: java.lang.NullPointerException
02-28 02:43:02.721: E/AndroidRuntime(6195): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2308)
02-28 02:43:02.721: E/AndroidRuntime(6195): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2362)
02-28 02:43:02.721: E/AndroidRuntime(6195): at android.app.ActivityThread.access$700(ActivityThread.java:168)
02-28 02:43:02.721: E/AndroidRuntime(6195): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1329)
02-28 02:43:02.721: E/AndroidRuntime(6195): at android.os.Handler.dispatchMessage(Handler.java:99)
02-28 02:43:02.721: E/AndroidRuntime(6195): at android.os.Looper.loop(Looper.java:137)
02-28 02:43:02.721: E/AndroidRuntime(6195): at android.app.ActivityThread.main(ActivityThread.java:5493)
02-28 02:43:02.721: E/AndroidRuntime(6195): at java.lang.reflect.Method.invokeNative(Native Method)
02-28 02:43:02.721: E/AndroidRuntime(6195): at java.lang.reflect.Method.invoke(Method.java:525)
02-28 02:43:02.721: E/AndroidRuntime(6195): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1209)
02-28 02:43:02.721: E/AndroidRuntime(6195): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1025)
02-28 02:43:02.721: E/AndroidRuntime(6195): at dalvik.system.NativeStart.main(Native Method)
02-28 02:43:02.721: E/AndroidRuntime(6195): Caused by: java.lang.NullPointerException
02-28 02:43:02.721: E/AndroidRuntime(6195): at com.example.mcdelivery.AddAddressActivity.onCreate(AddAddressActivity.java:18)
02-28 02:43:02.721: E/AndroidRuntime(6195): at android.app.Activity.performCreate(Activity.java:5372)
02-28 02:43:02.721: E/AndroidRuntime(6195): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1104)
02-28 02:43:02.721: E/AndroidRuntime(6195): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2270)
02-28 02:43:02.721: E/AndroidRuntime(6195): ... 11 more
02-28 02:43:02.751: V/webkit(6195): BrowserFrame constructor: this=Handler (android.webkit.BrowserFrame) {4419b1f0}
AddAddressActivity.java
package com.example.mcdelivery;
import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.webkit.WebView;
public class AddAddressActivity extends Activity {
WebView webview;
/** Called when the activity is first created. */
#Override
public void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_addaddress);
Intent intent=new Intent(this.getIntent());
webview.loadUrl("https://www.mcdelivery.co.kr/kr/jsp/sys/customerLogin.do?userName=" + intent.getStringExtra("username") + "&password=" + intent.getStringExtra("password") + "&imgLogin.x=0&imgLogin.y=0");
}
}
webView gives a NPE on this line
webview.loadUrl("https://www.mcdelivery.co.kr/kr/jsp/sys/customerLogin.do?userName=" + intent.getStringExtra("username") + "&password=" + intent.getStringExtra("password") + "&imgLogin.x=0&imgLogin.y=0");
Because you haven't yet initialized it. You only declare it
WebView webview;
Somewhere (before that line and after setContentView()) you need to initialize it
You have only declared WebView not initialized it
setContentView(R.layout.activity_addaddress);
webview =(WebView)findViewById(R.id.webView); //missing
Intent intent= getIntent();
webview.loadUrl("https://www.mcdelivery.co.kr/kr/jsp/sys/customerLogin.do?userName=" + intent.getStringExtra("username") + "&password=" + intent.getStringExtra("password") + "&imgLogin.x=0&imgLogin.y=0");
I think that's from a bad handling of the Context belonging to your app.
Replace
Intent intent=new Intent(MainActivity.this, AddAddressActivity.class);
with
Intent intent=new Intent(this, AddAddressActivity.class); .

can't show alert dialog

I can't show alert dialog. Everything is right until I set the method dialog.show(), then I can't open my application. Without this method everything is fine.
I declared two global objects:
AlertDialog.Builder builder;
AlertDialog dialog;
Then in MainActivity, I build a dialog by builder and create it.
builder = new AlertDialog.Builder(this.getApplicationContext());
builder.setMessage("We're sorry, but on Your device accelerometer isn't available")
.setCancelable(false)
.setPositiveButton("OK", new DialogInterface.OnClickListener() {
#Override
public void onClick(DialogInterface dialog, int which)
{
MainActivity.this.finish();
}
});
dialog = builder.create();
To this moment everything works and there's no any exceptions, but when I want to show the dialog, some exceptions appear and I can't run this application:
dialog.show(); //this method doesn't work and causes problems
What did I do wrong?
EDIT:
Exceptions:
06-26 20:49:03.540: D/dalvikvm(4085): GC_FOR_ALLOC freed 38K, 8% free 2499K/2712K, paused 42ms, total 45ms
06-26 20:49:03.580: I/dalvikvm-heap(4085): Grow heap (frag case) to 6.146MB for 3712016-byte allocation
06-26 20:49:03.700: D/dalvikvm(4085): GC_FOR_ALLOC freed 2K, 4% free 6121K/6340K, paused 112ms, total 112ms
06-26 20:49:03.770: D/dalvikvm(4085): GC_CONCURRENT freed <1K, 4% free 6121K/6340K, paused 6ms+16ms, total 71ms
06-26 20:49:04.460: D/gralloc_goldfish(4085): Emulator without GPU emulation detected.
06-26 20:49:42.030: E/Trace(4138): error opening trace file: No such file or directory (2)
06-26 20:49:42.900: D/dalvikvm(4138): GC_FOR_ALLOC freed 41K, 8% free 2499K/2716K, paused 66ms, total 68ms
06-26 20:49:42.940: I/dalvikvm-heap(4138): Grow heap (frag case) to 6.146MB for 3712016-byte allocation
06-26 20:49:43.050: D/dalvikvm(4138): GC_FOR_ALLOC freed 2K, 4% free 6121K/6344K, paused 107ms, total 107ms
06-26 20:49:43.120: D/dalvikvm(4138): GC_CONCURRENT freed <1K, 4% free 6121K/6344K, paused 5ms+5ms, total 70ms
06-26 20:49:43.540: D/dalvikvm(4138): GC_FOR_ALLOC freed 3638K, 53% free 3483K/7300K, paused 36ms, total 37ms
06-26 20:49:43.621: D/AndroidRuntime(4138): Shutting down VM
06-26 20:49:43.630: W/dalvikvm(4138): threadid=1: thread exiting with uncaught exception (group=0x40a71930)
06-26 20:49:43.640: E/AndroidRuntime(4138): FATAL EXCEPTION: main
06-26 20:49:43.640: E/AndroidRuntime(4138): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.accelerometertest/com.example.accelerometertest.MainActivity}: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.app.ActivityThread.access$600(ActivityThread.java:141)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.os.Handler.dispatchMessage(Handler.java:99)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.os.Looper.loop(Looper.java:137)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.app.ActivityThread.main(ActivityThread.java:5041)
06-26 20:49:43.640: E/AndroidRuntime(4138): at java.lang.reflect.Method.invokeNative(Native Method)
06-26 20:49:43.640: E/AndroidRuntime(4138): at java.lang.reflect.Method.invoke(Method.java:511)
06-26 20:49:43.640: E/AndroidRuntime(4138): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
06-26 20:49:43.640: E/AndroidRuntime(4138): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
06-26 20:49:43.640: E/AndroidRuntime(4138): at dalvik.system.NativeStart.main(Native Method)
06-26 20:49:43.640: E/AndroidRuntime(4138): Caused by: android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.view.ViewRootImpl.setView(ViewRootImpl.java:571)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.view.WindowManagerGlobal.addView(WindowManagerGlobal.java:246)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.view.WindowManagerImpl.addView(WindowManagerImpl.java:69)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.app.Dialog.show(Dialog.java:281)
06-26 20:49:43.640: E/AndroidRuntime(4138): at com.example.accelerometertest.MainActivity.onCreate(MainActivity.java:67)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.app.Activity.performCreate(Activity.java:5104)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
06-26 20:49:43.640: E/AndroidRuntime(4138): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
06-26 20:49:43.640: E/AndroidRuntime(4138): ... 11 more
change
builder = new AlertDialog.Builder(this.getApplicationContext());
to (As long as thisis your MainActivity )
builder = new AlertDialog.Builder(this);

Android: How to load an image from gallery into the OpenCv Mat variable?

I'm currently try to run some opencv filters (i.e find egde, Median, ...) on images which are stored in the image gallery folder.
But I get error for loading image. My device is galaxy tab 10.1 with android 3.2, my opencv - API level 8.
I have the following source on a Button:
#Override
public void onClick(View v) {
Bitmap myBitmap = BitmapFactory.decodeFile("/sdcard/image1.jpg");
Bitmap myBitmap32 = myBitmap.copy(Bitmap.Config.ARGB_8888, true);
Mat pic1 = Utils.bitmapToMat(myBitmap32);
}
Here is LogCat:
02-07 12:31:27.290: I/System.out(16522): Not a DRM File, opening notmally
02-07 12:31:27.290: I/System.out(16522): buffer returned
02-07 12:31:27.310: D/dalvikvm(16522): GC_FOR_ALLOC freed 11K, 21% free 6975K/8775K, paused 19ms
02-07 12:31:27.320: I/dalvikvm-heap(16522): Grow heap (frag case) to 12.918MB for 6291472-byte allocation
02-07 12:31:27.340: D/dalvikvm(16522): GC_FOR_ALLOC freed <1K, 13% free 13119K/14983K, paused 19ms
02-07 12:31:27.380: D/dalvikvm(16522): GC_CONCURRENT freed 0K, 13% free 13119K/14983K, paused 2ms+2ms
02-07 12:31:27.710: D/dalvikvm(16522): GC_FOR_ALLOC freed 55K, 13% free 13063K/14983K, paused 20ms
02-07 12:31:27.730: I/dalvikvm-heap(16522): Grow heap (frag case) to 24.864MB for 12582928-byte allocation
02-07 12:31:27.780: D/dalvikvm(16522): GC_FOR_ALLOC freed 0K, 8% free 25351K/27335K, paused 21ms
02-07 12:31:27.830: D/dalvikvm(16522): GC_CONCURRENT freed <1K, 8% free 25351K/27335K, paused 2ms+3ms
02-07 12:31:27.890: W/dalvikvm(16522): Exception Ljava/lang/UnsatisfiedLinkError; thrown while initializing Lorg/opencv/android/Utils;
02-07 12:31:27.890: D/AndroidRuntime(16522): Shutting down VM
02-07 12:31:27.890: W/dalvikvm(16522): threadid=1: thread exiting with uncaught exception (group=0x400fc760)
02-07 12:31:27.890: E/AndroidRuntime(16522): FATAL EXCEPTION: main
02-07 12:31:27.890: E/AndroidRuntime(16522): java.lang.ExceptionInInitializerError
02-07 12:31:27.890: E/AndroidRuntime(16522): at photo.klu.PhotoKLUActivity$1.onClick(PhotoKLUActivity.java:82)
02-07 12:31:27.890: E/AndroidRuntime(16522): at android.view.View.performClick(View.java:3127)
02-07 12:31:27.890: E/AndroidRuntime(16522): at android.view.View$PerformClick.run(View.java:12025)
02-07 12:31:27.890: E/AndroidRuntime(16522): at android.os.Handler.handleCallback(Handler.java:587)
02-07 12:31:27.890: E/AndroidRuntime(16522): at android.os.Handler.dispatchMessage(Handler.java:92)
02-07 12:31:27.890: E/AndroidRuntime(16522): at android.os.Looper.loop(Looper.java:132)
02-07 12:31:27.890: E/AndroidRuntime(16522): at android.app.ActivityThread.main(ActivityThread.java:4126)
02-07 12:31:27.890: E/AndroidRuntime(16522): at java.lang.reflect.Method.invokeNative(Native Method)
02-07 12:31:27.890: E/AndroidRuntime(16522): at java.lang.reflect.Method.invoke(Method.java:491)
02-07 12:31:27.890: E/AndroidRuntime(16522): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
02-07 12:31:27.890: E/AndroidRuntime(16522): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
02-07 12:31:27.890: E/AndroidRuntime(16522): at dalvik.system.NativeStart.main(Native Method)
02-07 12:31:27.890: E/AndroidRuntime(16522): Caused by: java.lang.UnsatisfiedLinkError: Couldn't load opencv_java: findLibrary returned null
02-07 12:31:27.890: E/AndroidRuntime(16522): at java.lang.Runtime.loadLibrary(Runtime.java:425)
02-07 12:31:27.890: E/AndroidRuntime(16522): at java.lang.System.loadLibrary(System.java:554)
02-07 12:31:27.890: E/AndroidRuntime(16522): at org.opencv.android.Utils.<clinit>(Utils.java:86)
02-07 12:31:27.890: E/AndroidRuntime(16522): ... 12 more
02-07 12:31:30.010: I/dalvikvm(16522): threadid=4: reacting to signal 3
02-07 12:31:30.010: I/dalvikvm(16522): Wrote stack traces to '/data/anr/traces.txt'
02-07 12:31:37.470: I/Process(16522): Sending signal. PID: 16522 SIG: 9
Any ideas?
Thank you.
The openCV library is not attached to your application. Please do the following (i assume that the openCV library is imported to your workspace). On Package Explorer > Right click on the application project > properties > under Library click Add > select openCV Be sure that on Java Build Path you don't have anything related to openCV

App force closes when returned back from the second activity to the first, the first activity no more works, has to be restarted again

I'm designing an application that allows the user to retrieve his data from the server, I'm furnishing this using two different activities, the first one receives the username as a text input and the second one displays the user's data based on the username. I'm using JSON schema for storing and retrieving the data. The app works fine for the first time but when I logout from the second screen using finish() and try to re-enter a new username in the first screen "the app force closes". This has been giving me sleepless nights, want to be overwhelmed with your support.
12-04 16:28:35.289: D/dalvikvm(553): GC_FOR_ALLOC freed 64K, 4% free 6893K/7171K, paused 64ms
12-04 16:28:35.299: I/dalvikvm-heap(553): Grow heap (frag case) to 7.757MB for 1000016-byte allocation
12-04 16:28:35.399: D/dalvikvm(553): GC_CONCURRENT freed 1K, 5% free 7868K/8199K, paused 16ms+3ms
12-04 16:28:35.529: D/dalvikvm(553): GC_FOR_ALLOC freed <1K, 5% free 7869K/8199K, paused 31ms
12-04 16:28:35.539: I/dalvikvm-heap(553): Grow heap (frag case) to 8.180MB for 443572-byte allocation
12-04 16:28:35.589: D/dalvikvm(553): GC_CONCURRENT freed 0K, 4% free 8302K/8647K, paused 3ms+5ms
12-04 16:28:35.889: D/gralloc_goldfish(553): Emulator without GPU emulation detected.
12-04 16:29:16.819: D/dalvikvm(553): GC_FOR_ALLOC freed 1079K, 14% free 7509K/8711K, paused 221ms
12-04 16:29:16.829: I/dalvikvm-heap(553): Grow heap (frag case) to 8.360MB for 1000016-byte allocation
12-04 16:29:16.889: D/dalvikvm(553): GC_CONCURRENT freed 2K, 3% free 8483K/8711K, paused 4ms+4ms
12-04 16:29:17.229: D/dalvikvm(553): GC_CONCURRENT freed 1016K, 13% free 7979K/9159K, paused 3ms+11ms
12-04 16:29:18.149: E/log_tag(553): Error parsing data org.json.JSONException: No value for Alert
12-04 16:29:20.949: D/dalvikvm(553): GC_CONCURRENT freed 274K, 12% free 8090K/9159K, paused 6ms+5ms
12-04 16:29:26.259: E/log_tag(553): Error parsing data org.json.JSONException: No value for Alert
12-04 16:29:26.859: D/AndroidRuntime(553): Shutting down VM
12-04 16:29:26.859: W/dalvikvm(553): threadid=1: thread exiting with uncaught exception (group=0x409951f8)
12-04 16:29:26.929: E/AndroidRuntime(553): FATAL EXCEPTION: main
12-04 16:29:26.929: E/AndroidRuntime(553): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.bombil.kustomizer/com.bombil.kustomizer.Menus}: java.lang.IndexOutOfBoundsException: Invalid index 2, size is 2
12-04 16:29:26.929: E/AndroidRuntime(553): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1955)
12-04 16:29:26.929: E/AndroidRuntime(553): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1980)
12-04 16:29:26.929: E/AndroidRuntime(553): at android.app.ActivityThread.access$600(ActivityThread.java:122)
12-04 16:29:26.929: E/AndroidRuntime(553): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1146)
12-04 16:29:26.929: E/AndroidRuntime(553): at android.os.Handler.dispatchMessage(Handler.java:99)
12-04 16:29:26.929: E/AndroidRuntime(553): at android.os.Looper.loop(Looper.java:137)
12-04 16:29:26.929: E/AndroidRuntime(553): at android.app.ActivityThread.main(ActivityThread.java:4340)
12-04 16:29:26.929: E/AndroidRuntime(553): at java.lang.reflect.Method.invokeNative(Native Method)
12-04 16:29:26.929: E/AndroidRuntime(553): at java.lang.reflect.Method.invoke(Method.java:511)
12-04 16:29:26.929: E/AndroidRuntime(553): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:784)
12-04 16:29:26.929: E/AndroidRuntime(553): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:551)
12-04 16:29:26.929: E/AndroidRuntime(553): at dalvik.system.NativeStart.main(Native Method)
12-04 16:29:26.929: E/AndroidRuntime(553): Caused by: java.lang.IndexOutOfBoundsException: Invalid index 2, size is 2
12-04 16:29:26.929: E/AndroidRuntime(553): at java.util.ArrayList.throwIndexOutOfBoundsException(ArrayList.java:251)
12-04 16:29:26.929: E/AndroidRuntime(553): at java.util.ArrayList.get(ArrayList.java:304)
12-04 16:29:26.929: E/AndroidRuntime(553): at com.bombil.kustomizer.Menus.AddEditText(Menus.java:309)
12-04 16:29:26.929: E/AndroidRuntime(553): at com.bombil.kustomizer.Menus.AddInsertView(Menus.java:121)
12-04 16:29:26.929: E/AndroidRuntime(553): at com.bombil.kustomizer.Menus.onCreate(Menus.java:88)
12-04 16:29:26.929: E/AndroidRuntime(553): at android.app.Activity.performCreate(Activity.java:4465)
12-04 16:29:26.929: E/AndroidRuntime(553): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
12-04 16:29:26.929: E/AndroidRuntime(553): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1919)
12-04 16:29:26.929: E/AndroidRuntime(553): ... 11 more
12-04 16:29:27.009: D/dalvikvm(553): GC_CONCURRENT freed 273K, 10% free 8248K/9159K, paused 4ms+6ms
12-04 16:32:56.799: I/Process(553): Sending signal. PID: 553 SIG: 9
Apparently, you're trying to access an object in an ArrayList at in your Menus.java file at line 309. You're trying to access the object with the index of 2, but the total ArrayList size is only 2, meaning the highest index would be 1. This causes an IndexOutOfBounds exception as shown here:
ComponentInfo{com.bombil.kustomizer/com.bombil.kustomizer.Menus}:
java.lang.IndexOutOfBoundsException: Invalid index 2, size is 2
E/AndroidRuntime(553): at com.bombil.kustomizer.Menus.AddEditText(Menus.java:309)
Do you have any objects that are being used by both activities? I know I saw this issue once with a project. One of the activities was messing up the HTTPClient object for the other activity. If you are getting a null exception being thrown try and find the variable. If it is a shared resource for both activities then just make sure to deal with it in a clean way when you exit the second activity.

Categories

Resources