Hi im trying to set up a frame animation with a series of images as a background for my splash page in an android application at the moment there is no errors but when I run the application it quits unexpectedly. The first error which follows 10 garbage collections is E/dalvikvm-heap(276): 1234272-byte external allocation too large for this process. I have 17 images I am using for the frame animation each of them are 50k or less so I dont think that the image sizes can be the issue.
The java code I have implemented in my main activity is as follows:
#Override
public void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.main);
ImageView frameanimation = (ImageView) findViewById(R.id.frame_animation);
AnimationDrawable frame_animation = (AnimationDrawable) frameanimation.getBackground();
frame_animation.setVisible(true, true);
frame_animation.start();
}
I then have this code implementing an image view within my XML Layout file:
<ImageView
android:id="#+id/frame_animation"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="#drawable/frame_animation"
android:background="#drawable/frame_animation"/>
and finally I have my animation drawable saved as 'frame_animation.xml' within my drawable folder.
<?xml version="1.0" encoding="utf-8"?>
<animation-list xmlns:android="http://schemas.android.com/apk/res/android" android:oneshot="false">
<item android:drawable="#drawable/homebckgrnda1" android:duration="200" />
<item android:drawable="#drawable/homebckgrnda2" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda3" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda4" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda5" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda6" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda7" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda8" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda9" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda10" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda11" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda12" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda13" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda14" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda15" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda16" android:duration="50" />
<item android:drawable="#drawable/homebckgrnda17" android:duration="50" />
</animation-list>
The full LogCat log that I get when running the application is shown here:
04-16 13:51:33.703: D/dalvikvm(276): GC_EXTERNAL_ALLOC freed 906 objects / 64688 bytes in 69ms
04-16 13:51:33.983: D/dalvikvm(276): GC_EXTERNAL_ALLOC freed 208 objects / 9952 bytes in 66ms
04-16 13:51:34.203: D/dalvikvm(276): GC_EXTERNAL_ALLOC freed 54 objects / 2112 bytes in 51ms
04-16 13:51:34.443: D/dalvikvm(276): GC_EXTERNAL_ALLOC freed 13 objects / 536 bytes in 52ms
04-16 13:51:34.683: D/dalvikvm(276): GC_EXTERNAL_ALLOC freed 13 objects / 512 bytes in 54ms
04-16 13:51:35.133: D/dalvikvm(276): GC_EXTERNAL_ALLOC freed 20 objects / 824 bytes in 52ms
04-16 13:51:35.593: D/dalvikvm(276): GC_EXTERNAL_ALLOC freed 26 objects / 1216 bytes in 70ms
04-16 13:51:36.023: D/dalvikvm(276): GC_EXTERNAL_ALLOC freed 24 objects / 1008 bytes in 51ms
04-16 13:51:36.394: D/dalvikvm(276): GC_EXTERNAL_ALLOC freed 26 objects / 1128 bytes in 55ms
04-16 13:51:36.803: D/dalvikvm(276): GC_EXTERNAL_ALLOC freed 24 objects / 984 bytes in 50ms
04-16 13:51:37.143: E/dalvikvm-heap(276): 1234272-byte external allocation too large for this process.
04-16 13:51:37.143: E/GraphicsJNI(276): VM won't let us allocate 1234272 bytes
04-16 13:51:37.153: D/AndroidRuntime(276): Shutting down VM
04-16 13:51:37.153: W/dalvikvm(276): threadid=1: thread exiting with uncaught exception (group=0x4001d800)
04-16 13:51:37.203: E/AndroidRuntime(276): FATAL EXCEPTION: main
04-16 13:51:37.203: E/AndroidRuntime(276): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.android.BadmintonTrain/com.android.BadmintonTrain.BadmintonTrainActivity}: android.view.InflateException: Binary XML file line #19: Error inflating class android.widget.ImageView
04-16 13:51:37.203: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.os.Handler.dispatchMessage(Handler.java:99)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.os.Looper.loop(Looper.java:123)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.app.ActivityThread.main(ActivityThread.java:4627)
04-16 13:51:37.203: E/AndroidRuntime(276): at java.lang.reflect.Method.invokeNative(Native Method)
04-16 13:51:37.203: E/AndroidRuntime(276): at java.lang.reflect.Method.invoke(Method.java:521)
04-16 13:51:37.203: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
04-16 13:51:37.203: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
04-16 13:51:37.203: E/AndroidRuntime(276): at dalvik.system.NativeStart.main(Native Method)
04-16 13:51:37.203: E/AndroidRuntime(276): Caused by: android.view.InflateException: Binary XML file line #19: Error inflating class android.widget.ImageView
04-16 13:51:37.203: E/AndroidRuntime(276): at android.view.LayoutInflater.createView(LayoutInflater.java:513)
04-16 13:51:37.203: E/AndroidRuntime(276): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:563)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.view.LayoutInflater.rInflate(LayoutInflater.java:618)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.view.LayoutInflater.inflate(LayoutInflater.java:407)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
04-16 13:51:37.203: E/AndroidRuntime(276): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:198)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.app.Activity.setContentView(Activity.java:1647)
04-16 13:51:37.203: E/AndroidRuntime(276): at com.android.BadmintonTrain.BadmintonTrainActivity.onCreate(BadmintonTrainActivity.java:21)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
04-16 13:51:37.203: E/AndroidRuntime(276): ... 11 more
04-16 13:51:37.203: E/AndroidRuntime(276): Caused by: java.lang.reflect.InvocationTargetException
04-16 13:51:37.203: E/AndroidRuntime(276): at android.widget.ImageView.<init>(ImageView.java:108)
04-16 13:51:37.203: E/AndroidRuntime(276): at java.lang.reflect.Constructor.constructNative(Native Method)
04-16 13:51:37.203: E/AndroidRuntime(276): at java.lang.reflect.Constructor.newInstance(Constructor.java:446)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.view.LayoutInflater.createView(LayoutInflater.java:500)
04-16 13:51:37.203: E/AndroidRuntime(276): ... 22 more
04-16 13:51:37.203: E/AndroidRuntime(276): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.Bitmap.nativeCreate(Native Method)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.Bitmap.createBitmap(Bitmap.java:468)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.Bitmap.createBitmap(Bitmap.java:435)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:340)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:488)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:462)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:323)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.content.res.Resources.loadDrawable(Resources.java:1709)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.content.res.Resources.getDrawable(Resources.java:581)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.drawable.AnimationDrawable.inflate(AnimationDrawable.java:265)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.drawable.Drawable.createFromXmlInner(Drawable.java:788)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.graphics.drawable.Drawable.createFromXml(Drawable.java:729)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.content.res.Resources.loadDrawable(Resources.java:1694)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.view.View.<init>(View.java:1885)
04-16 13:51:37.203: E/AndroidRuntime(276): at android.widget.ImageView.<init>(ImageView.java:112)
Any help is much appreciated, I just cannot figure out what is causing the problem.
Thanks
The images you are using might be too large for an animation. How large are they? In an animation, Android loads all of the images into memory and uncompresses them meaning that every pixel will take 4 bytes. So 50k would mean that your image is 111px x 111px. It seems from the error each frame is about 480 x 640, which is really large. Try using smaller images.
Related
I know that my question was asked before.
But no solution is working for me.
For now I tried this solutions:
Solution 1
Solution 2
Solution 3
Solution 4
But no one of them worked for me.
My application project include a JNI part so I added all the mentioned line from THIS tutorial to the Android.mk file,
I comment this line :
if(!OpenCVLoader.initAsync(OpenCVLoader.OPENCV_VERSION_2_4_6, this, mLoaderCallback));
And added:
static {
if (!OpenCVLoader.initDebug()) {
// Handle initialization error
}
}
After public void onResume()
My application gets stuck and crushed when the OpenCV started.
This is the LogCat output:
04-16 10:00:25.020: W/System.err(14797): java.io.FileNotFoundException: /storage/emulated/0/DCIM/Frames/20140416_100025.mp4: open failed: ENOENT (No such file or directory)
04-16 10:00:25.020: W/System.err(14797): at libcore.io.IoBridge.open(IoBridge.java:409)
04-16 10:00:25.020: W/System.err(14797): at java.io.FileOutputStream.<init>(FileOutputStream.java:88)
04-16 10:00:25.020: W/System.err(14797): at java.io.FileOutputStream.<init>(FileOutputStream.java:128)
04-16 10:00:25.020: W/System.err(14797): at java.io.FileOutputStream.<init>(FileOutputStream.java:117)
04-16 10:00:25.025: W/System.err(14797): at android.media.MediaRecorder.prepare(MediaRecorder.java:776)
04-16 10:00:25.025: W/System.err(14797): at com.example.homedevice.SampleTestingAct.prepareRecorder(SampleTestingAct.java:371)
04-16 10:00:25.025: W/System.err(14797): at com.example.homedevice.SampleTestingAct.StartTest(SampleTestingAct.java:443)
04-16 10:00:25.025: W/System.err(14797): at com.example.homedevice.SampleTestingAct.access$0(SampleTestingAct.java:420)
04-16 10:00:25.025: W/System.err(14797): at com.example.homedevice.SampleTestingAct$2$1.run(SampleTestingAct.java:2037)
04-16 10:00:25.025: W/System.err(14797): at java.util.Timer$TimerImpl.run(Timer.java:284)
04-16 10:00:25.025: W/System.err(14797): Caused by: libcore.io.ErrnoException: open failed: ENOENT (No such file or directory)
04-16 10:00:25.025: W/System.err(14797): at libcore.io.Posix.open(Native Method)
04-16 10:00:25.030: W/System.err(14797): at libcore.io.BlockGuardOs.open(BlockGuardOs.java:110)
04-16 10:00:25.030: W/System.err(14797): at libcore.io.IoBridge.open(IoBridge.java:393)
04-16 10:00:25.030: W/System.err(14797): ... 9 more
04-16 10:00:25.260: E/MediaRecorder(14797): start called in an invalid state: 4
04-16 10:00:25.260: W/dalvikvm(14797): threadid=16: thread exiting with uncaught exception (group=0x41c44700)
04-16 10:00:25.260: E/AndroidRuntime(14797): FATAL EXCEPTION: Timer-2
04-16 10:00:25.260: E/AndroidRuntime(14797): java.lang.IllegalStateException
04-16 10:00:25.260: E/AndroidRuntime(14797): at android.media.MediaRecorder.start(Native Method)
04-16 10:00:25.260: E/AndroidRuntime(14797): at com.example.homedevice.SampleTestingAct.StartTest(SampleTestingAct.java:445)
04-16 10:00:25.260: E/AndroidRuntime(14797): at com.example.homedevice.SampleTestingAct.access$0(SampleTestingAct.java:420)
04-16 10:00:25.260: E/AndroidRuntime(14797): at com.example.homedevice.SampleTestingAct$2$1.run(SampleTestingAct.java:2037)
04-16 10:00:25.260: E/AndroidRuntime(14797): at java.util.Timer$TimerImpl.run(Timer.java:284)
04-16 10:00:32.555: I/Choreographer(14797): Skipped 436 frames! The application may be doing too much work on its main thread.
04-16 10:00:32.715: E/ViewSystem(14797): ViewRootImpl #2 Surface is not valid.
04-16 10:00:32.725: E/MediaRecorder(14797): stop called in an invalid state: 4
04-16 10:00:32.725: D/AndroidRuntime(14797): Shutting down VM
04-16 10:00:32.725: W/dalvikvm(14797): threadid=1: thread exiting with uncaught exception (group=0x41c44700)
04-16 10:00:32.730: I/Process(14797): Sending signal. PID: 14797 SIG: 9
04-16 10:00:33.060: D/dalvikvm(15019): GC_FOR_ALLOC freed 56K, 12% free 9605K/10840K, paused 13ms, total 14ms
04-16 10:00:33.060: I/dalvikvm-heap(15019): Grow heap (frag case) to 11.604MB for 1127536-byte allocation
04-16 10:00:33.080: D/dalvikvm(15019): GC_FOR_ALLOC freed <1K, 11% free 10706K/11944K, paused 20ms, total 20ms
04-16 10:00:33.115: D/dalvikvm(15019): GC_FOR_ALLOC freed <1K, 10% free 11593K/12832K, paused 11ms, total 11ms
04-16 10:00:33.200: D/libEGL(15019): loaded /system/lib/egl/libEGL_mali.so
04-16 10:00:33.200: D/libEGL(15019): loaded /system/lib/egl/libGLESv1_CM_mali.so
04-16 10:00:33.205: D/libEGL(15019): loaded /system/lib/egl/libGLESv2_mali.so
04-16 10:00:33.210: E/(15019): Device driver API match
04-16 10:00:33.210: E/(15019): Device driver API version: 23
04-16 10:00:33.210: E/(15019): User space API version: 23
04-16 10:00:33.210: E/(15019): mali: REVISION=Linux-r3p2-01rel3 BUILD_DATE=Wed Oct 9 21:05:57 KST 2013
04-16 10:00:33.265: D/OpenGLRenderer(15019): Enabling debug mode 0
Is it possible to work with OpenCV without the OpenCV manager(maybe include him in my app?)
Hope that someone can help here.
Thanks!
sure you can do that. You just need to have the specific OpenCV libraries packed in your APK. Have a look at my reply here.
I am fairly new to all this, so please bear with me! I have been trying to work out the style of my app today, and cant quite get it. I keep getting this error inflating class when I try to run the app on my AVD. I have no clue what it means, or how to fix it. I can tell its talking about my MainActivity, so Ill post the information for that as well.
07-29 21:41:35.751: D/dalvikvm(431): GC_EXTERNAL_ALLOC freed 53K, 53% free 2546K/5379K, external 1625K/2137K, paused 104ms
07-29 21:41:35.811: E/dalvikvm-heap(431): 31740000-byte external allocation too large for this process.
07-29 21:41:35.911: E/GraphicsJNI(431): VM won't let us allocate 31740000 bytes
07-29 21:41:35.911: D/dalvikvm(431): GC_FOR_MALLOC freed <1K, 53% free 2546K/5379K, external 1625K/2137K, paused 91ms
07-29 21:41:35.911: D/skia(431): --- decoder->decode returned false
07-29 21:41:35.971: D/AndroidRuntime(431): Shutting down VM
07-29 21:41:35.971: W/dalvikvm(431): threadid=1: thread exiting with uncaught exception (group=0x40015560)
07-29 21:41:36.021: E/AndroidRuntime(431): FATAL EXCEPTION: main
07-29 21:41:36.021: E/AndroidRuntime(431): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.madonk.louisiana.festivals/com.madonk.louisiana.festivals.MainActivity}: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
07-29 21:41:36.021: E/AndroidRuntime(431): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1647)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.app.ActivityThread.access$1500(ActivityThread.java:117)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.os.Handler.dispatchMessage(Handler.java:99)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.os.Looper.loop(Looper.java:123)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.app.ActivityThread.main(ActivityThread.java:3683)
07-29 21:41:36.021: E/AndroidRuntime(431): at java.lang.reflect.Method.invokeNative(Native Method)
07-29 21:41:36.021: E/AndroidRuntime(431): at java.lang.reflect.Method.invoke(Method.java:507)
07-29 21:41:36.021: E/AndroidRuntime(431): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
07-29 21:41:36.021: E/AndroidRuntime(431): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
07-29 21:41:36.021: E/AndroidRuntime(431): at dalvik.system.NativeStart.main(Native Method)
07-29 21:41:36.021: E/AndroidRuntime(431): Caused by: android.view.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
07-29 21:41:36.021: E/AndroidRuntime(431): at android.view.LayoutInflater.createView(LayoutInflater.java:518)
07-29 21:41:36.021: E/AndroidRuntime(431): at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:568)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.view.LayoutInflater.inflate(LayoutInflater.java:386)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.view.LayoutInflater.inflate(LayoutInflater.java:320)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.view.LayoutInflater.inflate(LayoutInflater.java:276)
07-29 21:41:36.021: E/AndroidRuntime(431): at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:207)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.app.Activity.setContentView(Activity.java:1657)
07-29 21:41:36.021: E/AndroidRuntime(431): at com.madonk.louisiana.festivals.MainActivity.onCreate(MainActivity.java:16)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
07-29 21:41:36.021: E/AndroidRuntime(431): ... 11 more
07-29 21:41:36.021: E/AndroidRuntime(431): Caused by: java.lang.reflect.InvocationTargetException
07-29 21:41:36.021: E/AndroidRuntime(431): at java.lang.reflect.Constructor.constructNative(Native Method)
07-29 21:41:36.021: E/AndroidRuntime(431): at java.lang.reflect.Constructor.newInstance(Constructor.java:415)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.view.LayoutInflater.createView(LayoutInflater.java:505)
07-29 21:41:36.021: E/AndroidRuntime(431): ... 21 more
07-29 21:41:36.021: E/AndroidRuntime(431): Caused by: java.lang.OutOfMemoryError: bitmap size exceeds VM budget
07-29 21:41:36.021: E/AndroidRuntime(431): at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:460)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:336)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:697)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.content.res.Resources.loadDrawable(Resources.java:1709)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.view.View.<init>(View.java:1951)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.view.View.<init>(View.java:1899)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.view.ViewGroup.<init>(ViewGroup.java:286)
07-29 21:41:36.021: E/AndroidRuntime(431): at android.widget.RelativeLayout.<init>(RelativeLayout.java:173)
07-29 21:41:36.021: E/AndroidRuntime(431): ... 24 more
07-29 21:42:43.762: I/Process(431): Sending signal. PID: 431 SIG: 9
Main_Activity.xml
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#drawable/background" >
<TextView
android:id="#+id/textView1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_marginBottom="39dp"
android:text="#string/Definitive"
android:textColor="#style/AppTheme"
android:textSize="20dp"
android:textStyle="bold"
tools:context=".MainActivity" />
<Button
android:id="#+id/button_southwest"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginBottom="136dp"
android:onClick="showOther"
android:text="#string/Southwest" />
<TextView
android:id="#+id/textView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#+id/textView1"
android:layout_centerHorizontal="true"
android:text="#string/Select_a_region"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#style/AppTheme"
android:textSize="20dp" />
</RelativeLayout>
Looks like your background drawable is too big, try to run app without background for RelativeLayout. Consider using color instead of drawable for your background.
You cannot use uppercase letters when naming resources in Android. Here you have #string/Definitive and #string/Select_a_region. Rename those and you should be fine. Hope this helps.
I am trying to setup barcode scanner for an android app. I was able to setup the barcode scanner using the plugin provided by phonegap. That worked fine on some phones but was not working on some HTC phones. I searched online and some one suggested that upgrading to zxing 2.0 should solve the problem. So, I downloaded the zxing-2.0 and followed the following steps:
1. Unzipped the zxing-2.0 and built the core package.
2. Added the android package to eclipse as an Android Project and selected it as library( named zxing-2 ).
3. Added core.jar as an external jar to the zxing-2 which made it build successfully on eclipse.
4. Added the zxing-2 as project dependency of my main app(myApp). Also added core.jar as an external jar in myApp.
MyApp's mainfest.xml now contains( earlier it contained the action name as com.phonegap.plugins.barcodescanner.SCAN):
<activity android:name="com.google.zxing.client.android.CaptureActivity"
android:screenOrientation="landscape"
android:configChanges="orientation|keyboardHidden"
android:theme="#android:style/Theme.NoTitleBar.Fullscreen"
android:windowSoftInputMode="stateAlwaysHidden">
<intent-filter>
<action android:name="com.google.zxing.client.android.SCAN"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
<activity android:name="com.google.zxing.client.android.encode.EncodeActivity"
android:label="#string/share_name">
<intent-filter>
<action android:name="com.google.zxing.client.android.ENCODE"/>
<category android:name="android.intent.category.DEFAULT"/>
</intent-filter>
</activity>
I am using the BarcodeScanner.java provided in phone gap plugin to invoke the barcode scanner. I changed the scan() method in it to:
//new version
public void scan() {
Intent intentScan = new Intent("com.google.zxing.client.android.SCAN");
intentScan.addCategory(Intent.CATEGORY_DEFAULT);
this.ctx.startActivityForResult((Plugin) this, intentScan, REQUEST_CODE);
}
//earlier version(it worked with zxing 1.7)
public void scan() {
Intent intentScan = new Intent("com.phonegap.plugins.barcodescanner.SCAN");
intentScan.addCategory(Intent.CATEGORY_DEFAULT);
this.ctx.startActivityForResult((Plugin) this, intentScan, REQUEST_CODE);
}
The project builds fine but when I run it and trigger the scan, I get the following runtime exception:
03-03 19:43:13.499: E/AndroidRuntime(276): FATAL EXCEPTION: main
03-03 19:43:13.499: E/AndroidRuntime(276): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.phonegap.myApp/com.google.zxing.client.android.CaptureActivity}: android.view.InflateException: Binary XML file line #2: Error inflating class phonegap
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2663)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2679)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.ActivityThread.access$2300(ActivityThread.java:125)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:2033)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.os.Handler.dispatchMessage(Handler.java:99)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.os.Looper.loop(Looper.java:123)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.ActivityThread.main(ActivityThread.java:4627)
03-03 19:43:13.499: E/AndroidRuntime(276): at java.lang.reflect.Method.invokeNative(Native Method)
03-03 19:43:13.499: E/AndroidRuntime(276): at java.lang.reflect.Method.invoke(Method.java:521)
03-03 19:43:13.499: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:868)
03-03 19:43:13.499: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:626)
03-03 19:43:13.499: E/AndroidRuntime(276): at dalvik.system.NativeStart.main(Native Method)
03-03 19:43:13.499: E/AndroidRuntime(276): Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class phonegap
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:441)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.GenericInflater.inflate(GenericInflater.java:317)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.GenericInflater.inflate(GenericInflater.java:263)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.PreferenceManager.inflateFromResource(PreferenceManager.java:251)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.PreferenceManager.setDefaultValues(PreferenceManager.java:444)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.PreferenceManager.setDefaultValues(PreferenceManager.java:422)
03-03 19:43:13.499: E/AndroidRuntime(276): at com.google.zxing.client.android.CaptureActivity.onCreate(CaptureActivity.java:167)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2627)
03-03 19:43:13.499: E/AndroidRuntime(276): ... 11 more
03-03 19:43:13.499: E/AndroidRuntime(276): Caused by: java.lang.ClassNotFoundException: android.preference.phonegap in loader dalvik.system.PathClassLoader[/data/app/com.phonegap.myApp-1.apk]
03-03 19:43:13.499: E/AndroidRuntime(276): at dalvik.system.PathClassLoader.findClass(PathClassLoader.java:243)
03-03 19:43:13.499: E/AndroidRuntime(276): at java.lang.ClassLoader.loadClass(ClassLoader.java:573)
03-03 19:43:13.499: E/AndroidRuntime(276): at java.lang.ClassLoader.loadClass(ClassLoader.java:532)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.GenericInflater.createItem(GenericInflater.java:375)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.GenericInflater.onCreateItem(GenericInflater.java:417)
03-03 19:43:13.499: E/AndroidRuntime(276): at android.preference.GenericInflater.createItemFromTag(GenericInflater.java:428)
03-03 19:43:13.499: E/AndroidRuntime(276): ... 19 more
Can someone help me figure out what I am doing wrong here or have I missed something.
Thanks.
Your major problem is that you are trying to integrate by Intent, but are also including core/ and android/. You should never use android/ like this, and only use core/ if building your own internal scanning. Remove these entirely.
All you want from the project is android-integration/ and all you need to do is here: http://code.google.com/p/zxing/wiki/ScanningViaIntent
I don't know Phonegap well, but it's not worth using it on Android for this.
It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 11 years ago.
This is my logcat and the problem is that the application is force closing and i want to knw the line or method which is causing this. I m new to android so cant understand a word of logcat. Thanks in advance
01-16 17:32:56.584: D/dalvikvm(276): GC freed 596 objects / 49984 bytes in 101ms
01-16 17:33:09.233: D/AndroidRuntime(276): Shutting down VM
01-16 17:33:09.233: W/dalvikvm(276): threadid=3: thread exiting with uncaught exception (group=0x4001b188)
01-16 17:33:09.233: E/AndroidRuntime(276): Uncaught handler: thread main exiting due to uncaught exception
01-16 17:33:09.273: E/AndroidRuntime(276): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.ymappuser/com.ymappuser.Manualloc}: java.lang.RuntimeException: java.lang.NullPointerException
01-16 17:33:09.273: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
01-16 17:33:09.273: E/AndroidRuntime(276): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
01-16 17:33:09.273: E/AndroidRuntime(276): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
01-16 17:33:09.273: E/AndroidRuntime(276): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
01-16 17:33:09.273: E/AndroidRuntime(276): at android.os.Handler.dispatchMessage(Handler.java:99)
01-16 17:33:09.273: E/AndroidRuntime(276): at android.os.Looper.loop(Looper.java:123)
01-16 17:33:09.273: E/AndroidRuntime(276): at android.app.ActivityThread.main(ActivityThread.java:4363)
01-16 17:33:09.273: E/AndroidRuntime(276): at java.lang.reflect.Method.invokeNative(Native Method)
01-16 17:33:09.273: E/AndroidRuntime(276): at java.lang.reflect.Method.invoke(Method.java:521)
01-16 17:33:09.273: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
01-16 17:33:09.273: E/AndroidRuntime(276): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
01-16 17:33:09.273: E/AndroidRuntime(276): at dalvik.system.NativeStart.main(Native Method)
01-16 17:33:09.273: E/AndroidRuntime(276): Caused by: java.lang.RuntimeException: java.lang.NullPointerException
01-16 17:33:09.273: E/AndroidRuntime(276): at com.ymappuser.Manualloc.getCountries(Manualloc.java:270)
01-16 17:33:09.273: E/AndroidRuntime(276): at com.ymappuser.Manualloc.fillcountry(Manualloc.java:83)
01-16 17:33:09.273: E/AndroidRuntime(276): at com.ymappuser.Manualloc.onCreate(Manualloc.java:75)
01-16 17:33:09.273: E/AndroidRuntime(276): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
01-16 17:33:09.273: E/AndroidRuntime(276): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
01-16 17:33:09.273: E/AndroidRuntime(276): ... 11 more
01-16 17:33:09.273: E/AndroidRuntime(276): Caused by: java.lang.NullPointerException
01-16 17:33:09.273: E/AndroidRuntime(276): at com.ymappuser.Manualloc.getCountries(Manualloc.java:243)
01-16 17:33:09.273: E/AndroidRuntime(276): ... 15 more
01-16 17:33:09.384: I/dalvikvm(276): threadid=7: reacting to signal 3
01-16 17:33:09.404: I/dalvikvm(276): Wrote stack trace to '/data/anr/traces.txt'
01-16 17:33:11.353: I/Process(276): Sending signal. PID: 276 SIG: 9
01-16 17:33:13.004: D/dalvikvm(284): GC freed 623 objects / 51024 bytes in 125ms
01-16 17:34:21.646: D/dalvikvm(284): GC freed 288 objects / 14672 bytes in 987ms
you are getting null pointer exception in method getCountries, in class Manualloc at line 270, you can check there by debugging what object on the line is null, and work accordingly.
I've an application in the market and many users have reported that the app is crashing a lot randomly. I'm trying to fix this but cannot fully understand the logs. Here's a extract from the log,
04-16 13:16:32.407 E/AndroidRuntime( 9237): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.maya.mobile.chiki/com.maya.mobile.chiki.tabview.Tabs3}: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.maya.mobile.chiki/com.maya.mobile.chiki.featured.FeaturedView}: java.lang.ClassCastException: android.view.AbsSavedState$1
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2512)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.app.ActivityThread.access$2200(ActivityThread.java:119)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1863)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.os.Handler.dispatchMessage(Handler.java:99)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.os.Looper.loop(Looper.java:123)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.app.ActivityThread.main(ActivityThread.java:4363)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at java.lang.reflect.Method.invokeNative(Native Method)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at java.lang.reflect.Method.invoke(Method.java:521)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:860)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:618)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at dalvik.system.NativeStart.main(Native Method)
04-16 13:16:32.407 E/AndroidRuntime( 9237): Caused by: java.lang.RuntimeException: Unable to start activity ComponentInfo{com.maya.mobile.chiki/com.maya.mobile.chiki.featured.FeaturedView}: java.lang.ClassCastException: android.view.AbsSavedState$1
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2496)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.app.ActivityThread.startActivityNow(ActivityThread.java:2335)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.app.LocalActivityManager.moveToState(LocalActivityManager.java:127)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.app.LocalActivityManager.startActivity(LocalActivityManager.java:339)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.widget.TabHost$IntentContentStrategy.getContentView(TabHost.java:648)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.widget.TabHost.setCurrentTab(TabHost.java:320)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at com.maya.mobile.chiki.tabview.CustomTabHost.setCurrentTab(CustomTabHost.java:43)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.widget.TabHost.addTab(TabHost.java:213)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at com.maya.mobile.chiki.tabview.Tabs3.doCreateTabs(Tabs3.java:180)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at com.maya.mobile.chiki.tabview.Tabs3.onCreate(Tabs3.java:149)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2459)
04-16 13:16:32.407 E/AndroidRuntime( 9237): ... 11 more
04-16 13:16:32.407 E/AndroidRuntime( 9237): Caused by: java.lang.ClassCastException: android.view.AbsSavedState$1
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.widget.AbsSpinner.onRestoreInstanceState(AbsSpinner.java:440)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.view.View.dispatchRestoreInstanceState(View.java:5940)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.view.ViewGroup.dispatchThawSelfOnly(ViewGroup.java:1140)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.widget.AdapterView.dispatchRestoreInstanceState(AdapterView.java:767)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1127)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1127)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1127)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.view.ViewGroup.dispatchRestoreInstanceState(ViewGroup.java:1127)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.view.View.restoreHierarchyState(View.java:5919)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at com.android.internal.policy.impl.PhoneWindow.restoreHierarchyState(PhoneWindow.java:1454)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.app.Activity.onRestoreInstanceState(Activity.java:835)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.app.Activity.performRestoreInstanceState(Activity.java:807)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.app.Instrumentation.callActivityOnRestoreInstanceState(Instrumentation.java:1096)
04-16 13:16:32.407 E/AndroidRuntime( 9237): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2473)
04-16 13:16:32.407 E/AndroidRuntime( 9237): ... 22 more
I got this log from one of my users.
Any help on this would be very very helpful.
Regards,
Hari
I was finally able to replicate this issue through an emulator set up with 50MB memory and running on GSM network speed. The issue seems to be because of history being cleared and so the data being lost which the app was already having. Not sure how I can handle this though.. any help???
My guess is that:
You have an activity containing a TabHost (fine)
The contents of those tabs are activities (bad)
You are duplicating android:id values among some of the widgets in those activities (fatal)
I had this issue as well. I had two activities with widgets bearing the same IDs. In one file, this widget was a Button and in another file the widget was a Spinner. I changed the IDs so that the Spinner had a different ID than the Button and the problem went away. It seems that Android runs in to problems if you use the same ID on two different classes of widgets.
I had a similar problem
It was a result of two views [Button] having the same ID
it happend to me because
the eclipse xml editor showed one button but registered 2 of the same ID
I solved it by cutting the button saving and then pasting it and saving again.
see: http://code.google.com/p/android/issues/detail?id=3981
Sometimes this happens to me.
First Try This:
Delete the R.java file so that it regenerates.
Then try this:
I rename the id of the widget in the XML, and in the java.
Then delete the R.java file so it regenerates.
Run it to flush it out. Rename it back to the way it was, and its good to go.