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); .
Related
I am developing for Android 2.3.3 and attempting to use the support GridLayout.
After SetContentView is run on onCreate in a class I am using, my app crashes.
I have the following GridLayout in a view:
<android.support.v7.widget.GridLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/chaptergrid"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:columnCount="4">
</android.support.v7.widget.GridLayout>
And I get the following in the Log Cat:
01-04 08:43:05.648: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed 55K, 53% free 2566K/5379K, external 716K/1038K, paused 56ms
01-04 08:43:05.708: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed 1K, 53% free 2565K/5379K, external 1382K/1894K, paused 26ms
01-04 08:43:05.768: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed <1K, 53% free 2565K/5379K, external 1902K/2568K, paused 27ms
01-04 08:43:05.848: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed <1K, 53% free 2565K/5379K, external 2944K/3677K, paused 36ms
01-04 08:43:05.937: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed <1K, 53% free 2566K/5379K, external 4160K/4795K, paused 25ms
01-04 08:43:05.987: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed <1K, 53% free 2566K/5379K, external 4883K/5590K, paused 25ms
01-04 08:43:06.107: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed 1K, 53% free 2567K/5379K, external 6330K/6493K, paused 33ms
01-04 08:43:06.207: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed 1K, 53% free 2568K/5379K, external 7776K/8299K, paused 32ms
01-04 08:43:36.217: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed 14K, 52% free 2595K/5379K, external 2163K/2886K, paused 24ms
01-04 08:43:36.277: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed 1K, 52% free 2594K/5379K, external 2481K/3205K, paused 24ms
01-04 08:43:36.347: D/dalvikvm(346): GC_EXTERNAL_ALLOC freed <1K, 52% free 2595K/5379K, external 3697K/4332K, paused 23ms
01-04 08:43:36.777: D/dalvikvm(346): GC_CONCURRENT freed 189K, 48% free 3036K/5831K, external 4181K/5012K, paused 4ms+4ms
01-04 08:43:36.998: D/szipinf(346): Initializing inflate state
01-04 08:43:38.547: I/dalvikvm(346): Jit: resizing JitTable from 512 to 1024
01-04 08:43:38.598: W/dalvikvm(346): VFY: unable to resolve static field 1174 (default_gap) in Landroid/support/v7/gridlayout/R$dimen;
01-04 08:43:38.598: D/dalvikvm(346): VFY: replacing opcode 0x60 at 0x0024
01-04 08:43:38.598: D/dalvikvm(346): VFY: dead code 0x0026-007b in Landroid/support/v7/widget/GridLayout;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;I)V
01-04 08:43:38.618: I/dalvikvm(346): Could not find method android.support.v4.view.ViewCompat.resolveSizeAndState, referenced from method android.support.v7.widget.GridLayout.onMeasure
01-04 08:43:38.618: W/dalvikvm(346): VFY: unable to resolve static method 2483: Landroid/support/v4/view/ViewCompat;.resolveSizeAndState (III)I
01-04 08:43:38.618: D/dalvikvm(346): VFY: replacing opcode 0x71 at 0x0050
01-04 08:43:38.618: D/dalvikvm(346): VFY: dead code 0x0053-005b in Landroid/support/v7/widget/GridLayout;.onMeasure (II)V
01-04 08:43:38.618: D/AndroidRuntime(346): Shutting down VM
01-04 08:43:38.618: W/dalvikvm(346): threadid=1: thread exiting with uncaught exception (group=0x40015560)
01-04 08:43:38.627: E/AndroidRuntime(346): FATAL EXCEPTION: main
01-04 08:43:38.627: E/AndroidRuntime(346): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.turbo/com.example.turbo.Chapter}: android.view.InflateException: Binary XML file line #28: Error inflating class android.support.v7.widget.GridLayout
01-04 08:43:38.627: E/AndroidRuntime(346): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.os.Handler.dispatchMessage(Handler.java:99)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.os.Looper.loop(Looper.java:123)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.app.ActivityThread.main(ActivityThread.java:3683)
01-04 08:43:38.627: E/AndroidRuntime(346): at java.lang.reflect.Method.invokeNative(Native Method)
01-04 08:43:38.627: E/AndroidRuntime(346): at java.lang.reflect.Method.invoke(Method.java:507)
01-04 08:43:38.627: E/AndroidRuntime(346): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
01-04 08:43:38.627: E/AndroidRuntime(346): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
01-04 08:43:38.627: E/AndroidRuntime(346): at dalvik.system.NativeStart.main(Native Method)
01-04 08:43:38.627: E/AndroidRuntime(346): Caused by: android.view.InflateException: Binary XML file line #28: Error inflating class android.support.v7.widget.GridLayout
01-04 08:43:38.627: E/AndroidRuntime(346): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:570)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.view.LayoutInflater.rInflate(LayoutInflater.java:623)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.view.LayoutInflater.inflate(LayoutInflater.java:408)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
01-04 08:43:38.627: E/AndroidRuntime(346): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.app.Activity.setContentView(Activity.java:1657)
01-04 08:43:38.627: E/AndroidRuntime(346): at com.example.turbo.Chapter.onCreate(Chapter.java:21)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
01-04 08:43:38.627: E/AndroidRuntime(346): ... 11 more
01-04 08:43:38.627: E/AndroidRuntime(346): Caused by: java.lang.reflect.InvocationTargetException
01-04 08:43:38.627: E/AndroidRuntime(346): at java.lang.reflect.Constructor.constructNative(Native Method)
01-04 08:43:38.627: E/AndroidRuntime(346): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
01-04 08:43:38.627: E/AndroidRuntime(346): ... 21 more
01-04 08:43:38.627: E/AndroidRuntime(346): Caused by: java.lang.NoClassDefFoundError: android.support.v7.gridlayout.R$dimen
01-04 08:43:38.627: E/AndroidRuntime(346): at android.support.v7.widget.GridLayout.<init>(GridLayout.java:270)
01-04 08:43:38.627: E/AndroidRuntime(346): at android.support.v7.widget.GridLayout.<init>(GridLayout.java:289)
01-04 08:43:38.627: E/AndroidRuntime(346): ... 24 more
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);
on my person name device i get an error caused by out of memory but when i tried the same program on another device it seems to work just fine
05-14 21:52:54.625: I/dalvikvm(3561): Wrote stack traces to '/data/anr/traces.txt'
05-14 21:52:55.135: I/dalvikvm(3561): threadid=3: reacting to signal 3
05-14 21:52:55.135: I/dalvikvm(3561): Wrote stack traces to '/data/anr/traces.txt'
05-14 21:52:56.785: D/dalvikvm(3561): GC_FOR_ALLOC freed 10K, 3% free 9663K/9863K, paused 13ms
05-14 21:52:56.785: I/dalvikvm-heap(3561): Grow heap (frag case) to 10.158MB for 633616-byte allocation
05-14 21:52:56.820: D/dalvikvm(3561): GC_CONCURRENT freed 3K, 3% free 10278K/10503K, paused 1ms+1ms
05-14 21:52:56.845: D/dalvikvm(3561): GC_FOR_ALLOC freed <1K, 3% free 10280K/10503K, paused 10ms
05-14 21:52:56.850: I/dalvikvm-heap(3561): Grow heap (frag case) to 10.759MB for 633616-byte allocation
05-14 21:52:56.885: D/dalvikvm(3561): GC_CONCURRENT freed <1K, 3% free 10898K/11143K, paused 2ms+2ms
05-14 21:52:56.910: D/dalvikvm(3561): GC_FOR_ALLOC freed <1K, 3% free 10899K/11143K, paused 13ms
05-14 21:52:56.910: I/dalvikvm-heap(3561): Grow heap (frag case) to 11.365MB for 633616-byte allocation
05-14 21:52:56.935: D/dalvikvm(3561): GC_CONCURRENT freed <1K, 3% free 11518K/11783K, paused 1ms+1ms
05-14 21:53:04.005: D/dalvikvm(3561): GC_FOR_ALLOC freed 13K, 2% free 11708K/11847K, paused 24ms
05-14 21:53:04.055: D/dalvikvm(3561): GC_CONCURRENT freed 419K, 5% free 12089K/12679K, paused 1ms+2ms
05-14 21:53:04.080: D/dalvikvm(3561): GC_FOR_ALLOC freed 0K, 5% free 12089K/12679K, paused 9ms
05-14 21:53:04.080: I/dalvikvm-heap(3561): Grow heap (frag case) to 13.680MB for 1843216-byte allocation
05-14 21:53:04.105: D/dalvikvm(3561): GC_CONCURRENT freed 0K, 5% free 13889K/14535K, paused 1ms+1ms
05-14 21:53:04.150: D/dalvikvm(3561): GC_FOR_ALLOC freed 800K, 10% free 13891K/15367K, paused 9ms
05-14 21:53:04.155: I/dalvikvm-heap(3561): Grow heap (frag case) to 15.440MB for 1843216-byte allocation
05-14 21:53:04.175: D/dalvikvm(3561): GC_CONCURRENT freed <1K, 9% free 15691K/17223K, paused 1ms+2ms
05-14 21:53:05.370: E/AndroidRuntime(3561): at dalvik.system.NativeStart.main(Native Method)
05-14 21:53:05.370: E/AndroidRuntime(3561): Caused by: android.view.InflateException: Binary XML file line #158: Error inflating class <unknown>
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.view.LayoutInflater.createView(LayoutInflater.java:606)
05-14 21:53:05.370: E/AndroidRuntime(3561): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
05-14 21:53:05.370: E/AndroidRuntime(3561): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.app.Activity.setContentView(Activity.java:1835)
05-14 21:53:05.370: E/AndroidRuntime(3561): at pilestudios.dirtyyou.singleplay.onCreate(singleplay.java:23)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.app.Activity.performCreate(Activity.java:4465)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1920)
05-14 21:53:05.370: E/AndroidRuntime(3561): ... 11 more
05-14 21:53:05.370: E/AndroidRuntime(3561): Caused by: java.lang.reflect.InvocationTargetException
05-14 21:53:05.370: E/AndroidRuntime(3561): at java.lang.reflect.Constructor.constructNative(Native Method)
05-14 21:53:05.370: E/AndroidRuntime(3561): at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.view.LayoutInflater.createView(LayoutInflater.java:586)
05-14 21:53:05.370: E/AndroidRuntime(3561): ... 26 more
05-14 21:53:05.370: E/AndroidRuntime(3561): Caused by: java.lang.OutOfMemoryError
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.graphics.Bitmap.nativeCreate(Native Method)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:773)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.content.res.Resources.loadDrawable(Resources.java:1966)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.widget.ImageView.<init>(ImageView.java:119)
05-14 21:53:05.370: E/AndroidRuntime(3561): at android.widget.ImageView.<init>(ImageView.java:109)
Different devices have different heap sizes.
You can try scaling down your image to see if it helps.
when I use an imageview in my app, it works fine on a galaxy s with android 2.2 and on the emulator with versions 2.1 & 2.2
however when I launch it on my phone ( xperia X10 mini pro with android 2.1) it crashes
The problem is definitely from the image view.
but I can't see where.
here's my code XML
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="#color/white"
>
<ImageView
android:id="#+id/logo"
android:src="#drawable/logo"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
>
</ImageView>
<TextView
android:id="#+id/espace"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Hello"
android:layout_gravity="center_horizontal"
/>
</LinearLayout>
here's the logcat :
02-28 10:55:32.833 I/ActivityManager(1214): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.ecovalim/.startEco }
02-28 10:55:32.923 I/ActivityManager(1214): Start proc com.ecovalim for activity com.ecovalim/.startEco: pid=10784 uid=10087 gids={3003, 1015}
02-28 10:55:33.053 W/ResourceType(10784): Failure getting entry for 0x7f020015 (t=1 e=21) in package 0: 0xffffffb5
02-28 10:55:33.063 D/AndroidRuntime(10784): Shutting down VM
02-28 10:55:33.063 W/dalvikvm(10784): threadid=3: thread exiting with uncaught exception (group=0x40026160)
02-28 10:55:33.063 E/AndroidRuntime(10784): Uncaught handler: thread main exiting due to uncaught exception
02-28 10:55:33.093 E/AndroidRuntime(10784): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ecovalim/com.ecovalim.startEco}: android.view.InflateException: Binary XML file line #9: Error inflating class android.widget.ImageView
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2503)
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2519)
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.app.ActivityThread.access$2200(ActivityThread.java:123)
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1870)
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.os.Handler.dispatchMessage(Handler.java:99)
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.os.Looper.loop(Looper.java:123)
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.app.ActivityThread.main(ActivityThread.java:4370)
02-28 10:55:33.093 E/AndroidRuntime(10784): at java.lang.reflect.Method.invokeNative(Native Method)
02-28 10:55:33.093 E/AndroidRuntime(10784): at java.lang.reflect.Method.invoke(Method.java:521)
02-28 10:55:33.093 E/AndroidRuntime(10784): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
02-28 10:55:33.093 E/AndroidRuntime(10784): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
02-28 10:55:33.093 E/AndroidRuntime(10784): at dalvik.system.NativeStart.main(Native Method)
02-28 10:55:33.093 E/AndroidRuntime(10784): Caused by: android.view.InflateException: Binary XML file line #9: Error inflating class android.widget.ImageView
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
02-28 10:55:33.093 E/AndroidRuntime(10784): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
02-28 10:55:33.093 E/AndroidRuntime(10784): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.app.Activity.setContentView(Activity.java:1625)
02-28 10:55:33.093 E/AndroidRuntime(10784): at com.ecovalim.startEco.onCreate(startEco.java:30)
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2466)
02-28 10:55:33.093 E/AndroidRuntime(10784): ... 11 more
02-28 10:55:33.093 E/AndroidRuntime(10784): Caused by: java.lang.reflect.InvocationTargetException
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.widget.ImageView.<init>(ImageView.java:109)
02-28 10:55:33.093 E/AndroidRuntime(10784): at java.lang.reflect.Constructor.constructNative(Native Method)
02-28 10:55:33.093 E/AndroidRuntime(10784): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
02-28 10:55:33.093 E/AndroidRuntime(10784): ... 22 more
02-28 10:55:33.093 E/AndroidRuntime(10784): Caused by: android.content.res.Resources$NotFoundException: File res/drawable-ldpi/title_bar_shadow.9.png from drawable resource ID #0x7f020015
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.content.res.Resources.loadDrawable(Resources.java:1710)
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.content.res.TypedArray.getDrawable(TypedArray.java:548)
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.widget.ImageView.<init>(ImageView.java:119)
02-28 10:55:33.093 E/AndroidRuntime(10784): ... 26 more
02-28 10:55:33.093 E/AndroidRuntime(10784): Caused by: java.io.FileNotFoundException: res/drawable-ldpi/title_bar_shadow.9.png
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.content.res.AssetManager.openNonAssetNative(Native Method)
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.content.res.AssetManager.openNonAsset(AssetManager.java:390)
02-28 10:55:33.093 E/AndroidRuntime(10784): at android.content.res.Resources.loadDrawable(Resources.java:1702)
02-28 10:55:33.093 E/AndroidRuntime(10784): ... 28 more
02-28 10:55:33.113 E/SemcCheckin(10784): Get crash dump level : java.io.FileNotFoundException: /data/semc-checkin/crashdump
02-28 10:55:33.113 W/ActivityManager(1214): Unable to start service Intent { act=com.sonyericsson.android.jcrashcatcher.action.BUGREPORT_AUTO cmp=com.sonyericsson.android.jcrashcatcher/.JCrashCatcherService (has extras) }: not found
02-28 10:55:33.153 I/Process (1214): Sending signal. PID: 10784 SIG: 3
02-28 10:55:33.153 I/dalvikvm(10784): threadid=7: reacting to signal 3
02-28 10:55:33.163 I/dalvikvm(10784): Wrote stack trace to '/data/anr/traces.txt'
02-28 10:55:33.223 E/SemcCheckin(6866): Get Crash Level : java.io.FileNotFoundException: /data/semc-checkin/crashdump
02-28 10:55:34.793 I/Process (10784): Sending signal. PID: 10784 SIG: 9
02-28 10:55:34.793 I/ActivityManager(1214): Process com.ecovalim (pid 10784) has died.
02-28 10:55:34.803 I/UsageStats(1214): Unexpected resume of com.sonyericsson.homescreen while already resumed in com.ecovalim
02-28 10:55:34.833 W/InputManagerService(1214): Window already focused, ignoring focus gain of: com.android.internal.view.IInputMethodClient$Stub$Proxy#45d8f048
02-28 10:55:35.643 I/ActivityManager(1214): Starting activity: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] flg=0x10200000 cmp=com.nolanlawson.logcat/.LogcatActivity }
02-28 10:55:35.803 I/ActivityManager(1214): Displayed activity com.nolanlawson.logcat/.LogcatActivity: 130 ms (total 2921 ms)
02-28 10:55:36.043 D/dalvikvm(10689): GC freed 4019 objects / 330232 bytes in 79ms
02-28 10:55:36.433 D/dalvikvm(10689): GC freed 14022 objects / 1069568 bytes in 86ms
02-28 10:55:36.723 D/dalvikvm(10689): GC freed 5244 objects / 476048 bytes in 71ms
02-28 10:55:37.033 D/dalvikvm(10689): GC freed 5325 objects / 460208 bytes in 84ms
02-28 10:55:37.333 D/dalvikvm(10689): GC freed 4784 objects / 474496 bytes in 81ms
The reason for the error is that the xperia x10 mini has a screen that goes as 'small', meaning that it won't find the resources in your drawable-normal folder.
You can fix this by either adding a drawable folder without any special tags to fall back on if no other folders are available to the current configuration, or create one for each possible config, i.e. drawable-small, drawable-large and drawable-xlarge
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.