Multiple Imageview within Framelayout, an error occurs

Asked

Viewed 120 times

3

Well the problem is I’ve got a few ImageView which are called buttons, run cool, but when setting 4 images it still goes well, add one more ImageViewwith another picture there the error program, in that same ImagemView put an image of the 4 the program runs because this occurs?

Logcat:

02-01 17:53:07.950: E/AndroidRuntime(767): FATAL EXCEPTION: main
02-01 17:53:07.950: E/AndroidRuntime(767): Process: com.teste.testeaplicao, PID: 767
02-01 17:53:07.950: E/AndroidRuntime(767): java.lang.RuntimeException: Unable to start activity 
ComponentInfo{com.teste.testeaplicacao/com.teste.testeaplicao.Teste}: android.view.InflateException: Binary XML file line #12: Error inflating class <unknown>
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.app.ActivityThread.access$800(ActivityThread.java:135)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.os.Handler.dispatchMessage(Handler.java:102)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.os.Looper.loop(Looper.java:136)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.app.ActivityThread.main(ActivityThread.java:5017)
02-01 17:53:07.950: E/AndroidRuntime(767):  at java.lang.reflect.Method.invokeNative(Native Method)
02-01 17:53:07.950: E/AndroidRuntime(767):  at java.lang.reflect.Method.invoke(Method.java:515)
02-01 17:53:07.950: E/AndroidRuntime(767):  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
02-01 17:53:07.950: E/AndroidRuntime(767):  at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
02-01 17:53:07.950: E/AndroidRuntime(767):  at dalvik.system.NativeStart.main(Native Method)
02-01 17:53:07.950: E/AndroidRuntime(767): Caused by: android.view.InflateException: Binary XML file line #12: Error inflating class <unknown>
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.view.LayoutInflater.createView(LayoutInflater.java:620)
02-01 17:53:07.950: E/AndroidRuntime(767):  at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
02-01 17:53:07.950: E/AndroidRuntime(767):  at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.app.Activity.setContentView(Activity.java:1929)
02-01 17:53:07.950: E/AndroidRuntime(767):  at com.teste.testeaplicacao.Teste.onCreate(Teste.java:40)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.app.Activity.performCreate(Activity.java:5231)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
02-01 17:53:07.950: E/AndroidRuntime(767):  ... 11 more
02-01 17:53:07.950: E/AndroidRuntime(767): Caused by: java.lang.reflect.InvocationTargetException
02-01 17:53:07.950: E/AndroidRuntime(767):  at java.lang.reflect.Constructor.constructNative(Native Method)
02-01 17:53:07.950: E/AndroidRuntime(767):  at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.view.LayoutInflater.createView(LayoutInflater.java:594)
02-01 17:53:07.950: E/AndroidRuntime(767):  ... 24 more
02-01 17:53:07.950: E/AndroidRuntime(767): Caused by: java.lang.OutOfMemoryError
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.graphics.BitmapFactory.nativeDecodeAsset(Native Method)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:587)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:422)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:840)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.content.res.Resources.loadDrawable(Resources.java:2110)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.widget.ImageView.<init>(ImageView.java:129)
02-01 17:53:07.950: E/AndroidRuntime(767):  at android.widget.ImageView.<init>(ImageView.java:119)
02-01 17:53:07.950: E/AndroidRuntime(767):  ... 27 more
  • It gets a little complicated to know what the problem is. It could include the stacktrace of the error and/or the code that adds these images?

  • In that case it’s a mistake, yes, some Exception occurs that force the closure of the app. Nothing appears in the logcat of your IDE?

  • At first I see no error in this layout. I think it is worth you investigate the problem that occurred. Can access the IDE’s log to find out what happened?

  • Rodolfo, this log doesn’t help much, try to get the whole log of the error, in general it has more than 10 lines.

  • You had a java.lang.OutOfMemoryError in image recovery. This means that memory has been missing for allocation while uploading images. How large are these images? There’s no way to reduce?

  • all of it together from 13 MB

  • you ta speaking of the resolution of the image? has how to increase the memory for fucione

  • 1

    It’s quite something. Android provides 16 to 32 MB of memory by default. To increase this you can use the "largeHeap" property in your manifest. But know that it is never good to use a lot of memory. I recommend doing an optimization, because by your logic, only one image is visible at a time correct? It would be good to load only one image in memory at a time. Understood?

  • more or less, would you use a variable to call the images? if you could give an example?

  • the solution may be here http://developer.android.com/intl/es/training/displaying-bitmaps/load-bitmap.html

  • I took a look there because I find it difficult to apply the method.

Show 6 more comments

1 answer

0


From your log we can analyze that the problem is in memory matter - OutOfMemory.

Usually this occurs by the size of the images you are trying to render! I recommend you redesign the design of your app.

I noticed you have one FrameLayout containing a ImageView as background. Is that it? If it is, remove it and use the property android:background="@drawable/..."

Browser other questions tagged

You are not signed in. Login or sign up in order to post.