GridLayout (Support Version) - Android 2.3.3 - android

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

Related

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); .

App crash because of big picture

In my Activity I have the following code:
int picture = Const.a1;
Const.backgroundBitmap = BitmapFactory.decodeResource(getResources(), picture);
Const.backgroundBitmapBonus0 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[0]);
Const.backgroundBitmapBonus1 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[1]);
Const.backgroundBitmapBonus2 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[2]);
Const.backgroundBitmapBonus3 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[3]);
Const.bitmapBackBonus = new Bitmap[4];
Const.bitmapBackBonus[0]= Const.backgroundBitmapBonus0;
Const.bitmapBackBonus[1] = Const.backgroundBitmapBonus1;
Const.bitmapBackBonus[2] = Const.backgroundBitmapBonus2;
Const.bitmapBackBonus[3] = Const.backgroundBitmapBonus3;
And in Const class I have
public static int[] bonus_back = { R.drawable.back_b0 , R.drawable.back_b1 , R.drawable.back_b2 , R.drawable.back_b3};
When I run the app on my device it crashes, while in AVD it worked fine.
How can I use these pictures in right way?
EDIT:
new code using http://developer.android.com/training/displaying-bitmaps/load-bitmap.html
still the same problem
Const.screenWidth = this.getWindowManager().getDefaultDisplay().getWidth();
Const.screenHeight = this.getWindowManager().getDefaultDisplay().getHeight();
int picture = Const.a1;
Const.backgroundBitmapBonus0 = decodeSampledBitmapFromResource(getResources(), Const.bonus_back[0], Const.screenWidth, Const.screenHeight);
Const.backgroundBitmapBonus1 =decodeSampledBitmapFromResource(getResources(), Const.bonus_back[1], Const.screenWidth, Const.screenHeight);
Const.backgroundBitmapBonus2 = decodeSampledBitmapFromResource(getResources(), Const.bonus_back[2], Const.screenWidth, Const.screenHeight);
Const.backgroundBitmapBonus3 = decodeSampledBitmapFromResource(getResources(), Const.bonus_back[3], Const.screenWidth, Const.screenHeight);
Const.backgroundBitmap = decodeSampledBitmapFromResource(getResources(), picture, 100, 100);
/*Const.backgroundBitmap = BitmapFactory.decodeResource(getResources(), picture);
Const.backgroundBitmapBonus0 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[0]);
Const.backgroundBitmapBonus1 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[1]);
Const.backgroundBitmapBonus2 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[2]);
Const.backgroundBitmapBonus3 = BitmapFactory.decodeResource(getResources(), Const.bonus_back[3]);
*/
Const.bitmapBackBonus = new Bitmap[4];
Const.bitmapBackBonus[0]= Const.backgroundBitmapBonus0;
Const.bitmapBackBonus[1] = Const.backgroundBitmapBonus1;
Const.bitmapBackBonus[2] = Const.backgroundBitmapBonus2;
Const.bitmapBackBonus[3] = Const.backgroundBitmapBonus3;
EDIT 2 : Logcat
11-14 09:45:45.525: D/dalvikvm(5623): Late-enabling CheckJNI
11-14 09:45:45.805: D/skia(5623): ---- fAsset->read(3346) returned 0
11-14 09:45:45.905: D/dalvikvm(5623): GC_FOR_ALLOC freed 99K, 3% free 13923K/14343K, paused 37ms
11-14 09:45:45.905: I/dalvikvm-heap(5623): Grow heap (frag case) to 14.807MB for 992016-byte allocation
11-14 09:45:45.945: D/dalvikvm(5623): GC_CONCURRENT freed 1K, 4% free 14890K/15367K, paused 2ms+2ms
11-14 09:45:46.025: D/dalvikvm(5623): GC_FOR_ALLOC freed 0K, 4% free 14890K/15367K, paused 13ms
11-14 09:45:46.075: I/dalvikvm-heap(5623): Grow heap (frag case) to 29.942MB for 15872016-byte allocation
11-14 09:45:46.115: D/dalvikvm(5623): GC_CONCURRENT freed 0K, 2% free 30390K/30919K, paused 2ms+2ms
11-14 09:45:46.515: D/dalvikvm(5623): GC_FOR_ALLOC freed 969K, 5% free 30391K/31943K, paused 18ms
11-14 09:45:46.565: I/dalvikvm-heap(5623): Grow heap (frag case) to 45.080MB for 15872016-byte allocation
11-14 09:45:46.595: D/dalvikvm(5623): GC_CONCURRENT freed <1K, 4% free 45890K/47495K, paused 2ms+3ms
11-14 09:45:46.905: D/dalvikvm(5623): GC_FOR_ALLOC freed 969K, 4% free 45891K/47495K, paused 15ms
11-14 09:45:46.970: I/dalvikvm-heap(5623): Grow heap (frag case) to 60.216MB for 15872016-byte allocation
11-14 09:45:46.990: D/dalvikvm(5623): GC_FOR_ALLOC freed <1K, 3% free 61391K/63047K, paused 18ms
11-14 09:45:47.050: D/dalvikvm(5623): GC_CONCURRENT freed 0K, 3% free 61391K/63047K, paused 2ms+5ms
11-14 09:45:47.345: D/dalvikvm(5623): GC_FOR_ALLOC freed 969K, 3% free 61391K/63047K, paused 14ms
11-14 09:45:47.345: I/dalvikvm-heap(5623): Forcing collection of SoftReferences for 15872016-byte allocation
11-14 09:45:47.390: D/dalvikvm(5623): GC_BEFORE_OOM freed 9K, 3% free 61382K/63047K, paused 32ms
11-14 09:45:47.390: E/dalvikvm-heap(5623): Out of memory on a 15872016-byte allocation.
11-14 09:45:47.390: I/dalvikvm(5623): "main" prio=5 tid=1 RUNNABLE
11-14 09:45:47.390: I/dalvikvm(5623): | group="main" sCount=0 dsCount=0 obj=0x40c6d460 self=0x8a9288
11-14 09:45:47.390: I/dalvikvm(5623): | sysTid=5623 nice=0 sched=0/0 cgrp=default handle=1074558216
11-14 09:45:47.390: I/dalvikvm(5623): | schedstat=( 1288354466 258529951 3812 ) utm=106 stm=22 core=2
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.Bitmap.nativeCreate(Native Method)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:618)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:593)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
11-14 09:45:47.390: I/dalvikvm(5623): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:468)
11-14 09:45:47.390: I/dalvikvm(5623): at com.example.fishe.FullscreenActivity.decodeSampledBitmapFromResource(FullscreenActivity.java:248)
11-14 09:45:47.390: I/dalvikvm(5623): at com.example.fishe.FullscreenActivity.onCreate(FullscreenActivity.java:142)
11-14 09:45:47.390: I/dalvikvm(5623): at android.app.Activity.performCreate(Activity.java:4533)
11-14 09:45:47.395: I/dalvikvm(5623): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
11-14 09:45:47.395: I/dalvikvm(5623): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
11-14 09:45:47.395: I/dalvikvm(5623): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
11-14 09:45:47.395: I/dalvikvm(5623): at android.app.ActivityThread.access$600(ActivityThread.java:128)
11-14 09:45:47.395: I/dalvikvm(5623): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
11-14 09:45:47.395: I/dalvikvm(5623): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 09:45:47.395: I/dalvikvm(5623): at android.os.Looper.loop(Looper.java:137)
11-14 09:45:47.395: I/dalvikvm(5623): at android.app.ActivityThread.main(ActivityThread.java:4517)
11-14 09:45:47.395: I/dalvikvm(5623): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 09:45:47.395: I/dalvikvm(5623): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 09:45:47.395: I/dalvikvm(5623): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
11-14 09:45:47.395: I/dalvikvm(5623): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
11-14 09:45:47.395: I/dalvikvm(5623): at dalvik.system.NativeStart.main(Native Method)
11-14 09:45:47.395: D/AndroidRuntime(5623): Shutting down VM
11-14 09:45:47.395: W/dalvikvm(5623): threadid=1: thread exiting with uncaught exception (group=0x40c6c1f8)
11-14 09:45:47.395: E/AndroidRuntime(5623): FATAL EXCEPTION: main
11-14 09:45:47.395: E/AndroidRuntime(5623): java.lang.OutOfMemoryError
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.Bitmap.nativeCreate(Native Method)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.Bitmap.createBitmap(Bitmap.java:605)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.Bitmap.createBitmap(Bitmap.java:551)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:618)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:593)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:445)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.graphics.BitmapFactory.decodeResource(BitmapFactory.java:468)
11-14 09:45:47.395: E/AndroidRuntime(5623): at com.example.fishe.FullscreenActivity.decodeSampledBitmapFromResource(FullscreenActivity.java:248)
11-14 09:45:47.395: E/AndroidRuntime(5623): at com.example.fishe.FullscreenActivity.onCreate(FullscreenActivity.java:142)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.Activity.performCreate(Activity.java:4533)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1053)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1934)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1995)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.ActivityThread.access$600(ActivityThread.java:128)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1161)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.os.Handler.dispatchMessage(Handler.java:99)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.os.Looper.loop(Looper.java:137)
11-14 09:45:47.395: E/AndroidRuntime(5623): at android.app.ActivityThread.main(ActivityThread.java:4517)
11-14 09:45:47.395: E/AndroidRuntime(5623): at java.lang.reflect.Method.invokeNative(Native Method)
11-14 09:45:47.395: E/AndroidRuntime(5623): at java.lang.reflect.Method.invoke(Method.java:511)
11-14 09:45:47.395: E/AndroidRuntime(5623): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:993)
11-14 09:45:47.395: E/AndroidRuntime(5623): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:760)
11-14 09:45:47.395: E/AndroidRuntime(5623): at dalvik.system.NativeStart.main(Native Method)
11-14 09:45:56.490: I/Process(5623): Sending signal. PID: 5623 SIG: 9
If the image is too big you're probably running out of memory.
Check http://developer.android.com/training/displaying-bitmaps/load-bitmap.html to learn how to load a scaled-down version of the image.

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);

Could not find class 'oauth.signpost.commonshttp.CommonsHttpOAuthConsumer'

Recently, I encountered a problem,My android app always stopped unexpectedly and some errors are printed on the log.In fact, I do not know how to debug my program base on logcat which everybody I asked for help wanted.please help me!
Here's my log.
04-22 11:57:20.653: W/dalvikvm(346): VFY: unable to resolve new-instance 41 (Loauth/signpost/commonshttp/CommonsHttpOAuthConsumer;) in LOAuth4Sina/com/AuthActivity;
04-22 11:57:20.653: D/dalvikvm(346): VFY: replacing opcode 0x22 at 0x000f
04-22 11:57:20.673: D/dalvikvm(346): VFY: dead code 0x0011-0039 in LOAuth4Sina/com/AuthActivity;.onCreate (Landroid/os/Bundle;)V
04-22 11:57:20.673: I/dalvikvm(346): Could not find method oauth.signpost.OAuthProvider.setOAuth10a, referenced from method OAuth4Sina.com.AuthActivity.onNewIntent
04-22 11:57:20.693: W/dalvikvm(346): VFY: unable to resolve interface method 41: Loauth/signpost/OAuthProvider;.setOAuth10a (Z)V
04-22 11:57:20.693: D/dalvikvm(346): VFY: replacing opcode 0x72 at 0x0010
04-22 11:57:20.733: W/dalvikvm(346): VFY: unable to resolve exception class 44 (Loauth/signpost/exception/OAuthMessageSignerException;)
04-22 11:57:20.733: W/dalvikvm(346): VFY: unable to find exception handler at addr 0x68
04-22 11:57:20.733: W/dalvikvm(346): VFY: rejected LOAuth4Sina/com/AuthActivity;.onNewIntent (Landroid/content/Intent;)V
04-22 11:57:20.766: W/dalvikvm(346): VFY: rejecting opcode 0x0d at 0x0068
04-22 11:57:20.766: W/dalvikvm(346): VFY: rejected LOAuth4Sina/com/AuthActivity;.onNewIntent (Landroid/content/Intent;)V
04-22 11:57:20.766: W/dalvikvm(346): Verifier rejected class LOAuth4Sina/com/AuthActivity;
04-22 11:57:20.766: W/dalvikvm(346): Class init failed in newInstance call (LOAuth4Sina/com/AuthActivity;)
04-22 11:57:20.785: D/AndroidRuntime(346): Shutting down VM
04-22 11:57:20.785: W/dalvikvm(346): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-22 11:57:20.812: E/AndroidRuntime(346): FATAL EXCEPTION: main
04-22 11:57:20.812: E/AndroidRuntime(346): java.lang.VerifyError: OAuth4Sina.com.AuthActivity
04-22 11:57:20.812: E/AndroidRuntime(346): at java.lang.Class.newInstanceImpl(Native Method)
04-22 11:57:20.812: E/AndroidRuntime(346): at java.lang.Class.newInstance(Class.java:1429)
04-22 11:57:20.812: E/AndroidRuntime(346): at android.app.Instrumentation.newActivity(Instrumentation.java:1021)
04-22 11:57:20.812: E/AndroidRuntime(346): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2577)
04-22 11:57:20.812: E/AndroidRuntime(346): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-22 11:57:20.812: E/AndroidRuntime(346): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-22 11:57:20.812: E/AndroidRuntime(346): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-22 11:57:20.812: E/AndroidRuntime(346): at android.os.Handler.dispatchMessage(Handler.java:99)
04-22 11:57:20.812: E/AndroidRuntime(346): at android.os.Looper.loop(Looper.java:123)
04-22 11:57:20.812: E/AndroidRuntime(346): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-22 11:57:20.812: E/AndroidRuntime(346): at java.lang.reflect.Method.invokeNative(Native Method)
04-22 11:57:20.812: E/AndroidRuntime(346): at java.lang.reflect.Method.invoke(Method.java:521)
04-22 11:57:20.812: E/AndroidRuntime(346): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-22 11:57:20.812: E/AndroidRuntime(346): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-22 11:57:20.812: E/AndroidRuntime(346): at dalvik.system.NativeStart.main(Native Method)

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

Categories

Resources