0

I'm trying to get the Blackjack Google TV sample working on a Vizio Co-Star (Google TV). I downloaded the sample code from https://code.google.com/p/googletv-android-samples/ but when I deploy it to the Vizio, I get an OutOfMemory error.

Has anyone gotten the Blackjack GTV sample working?

Full Stack Trace:

04-02 13:32:56.364: E/dalvikvm-heap(4027): Out of memory on a 78655376-byte allocation. 04-02 13:32:56.374: E/AndroidRuntime(4027): FATAL EXCEPTION: main 04-02 13:32:56.374: E/AndroidRuntime(4027): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.google.android.tv.blackjack/com.google.android.tv.blackjack.BlackJackTableActivity}: android.view.InflateException: Binary XML file line #17: Error inflating class 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1836) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1852) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.app.ActivityThread.access$500(ActivityThread.java:124) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1038) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.os.Handler.dispatchMessage(Handler.java:99) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.os.Looper.loop(Looper.java:132) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.app.ActivityThread.main(ActivityThread.java:4196) 04-02 13:32:56.374: E/AndroidRuntime(4027): at java.lang.reflect.Method.invokeNative(Native Method) 04-02 13:32:56.374: E/AndroidRuntime(4027): at java.lang.reflect.Method.invoke(Method.java:491) 04-02 13:32:56.374: E/AndroidRuntime(4027): at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:841) 04-02 13:32:56.374: E/AndroidRuntime(4027): at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:599) 04-02 13:32:56.374: E/AndroidRuntime(4027): at dalvik.system.NativeStart.main(Native Method) 04-02 13:32:56.374: E/AndroidRuntime(4027): Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.view.LayoutInflater.createView(LayoutInflater.java:596) 04-02 13:32:56.374: E/AndroidRuntime(4027): at com.android.internal.policy.impl.tv.TvLayoutInflater.onCreateView(TvLayoutInflater.java:50) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.view.LayoutInflater.onCreateView(LayoutInflater.java:644) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.view.LayoutInflater.inflate(LayoutInflater.java:457) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.view.LayoutInflater.inflate(LayoutInflater.java:391) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.view.LayoutInflater.inflate(LayoutInflater.java:347) 04-02 13:32:56.374: E/AndroidRuntime(4027): at com.android.internal.policy.impl.tv.TvWindow.setContentView(TvWindow.java:248) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.app.Activity.setContentView(Activity.java:1809) 04-02 13:32:56.374: E/AndroidRuntime(4027): at com.google.android.tv.blackjack.BlackJackTableActivity.onCreate(BlackJackTableActivity.java:58) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.app.Activity.performCreate(Activity.java:4438) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1048) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1800) 04-02 13:32:56.374: E/AndroidRuntime(4027): ... 11 more 04-02 13:32:56.374: E/AndroidRuntime(4027): Caused by: java.lang.reflect.InvocationTargetException 04-02 13:32:56.374: E/AndroidRuntime(4027): at java.lang.reflect.Constructor.constructNative(Native Method) 04-02 13:32:56.374: E/AndroidRuntime(4027): at java.lang.reflect.Constructor.newInstance(Constructor.java:416) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.view.LayoutInflater.createView(LayoutInflater.java:576) 04-02 13:32:56.374: E/AndroidRuntime(4027): ... 23 more 04-02 13:32:56.374: E/AndroidRuntime(4027): Caused by: java.lang.OutOfMemoryError 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.graphics.Bitmap.nativeCreate(Native Method) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.graphics.Bitmap.createBitmap(Bitmap.java:604) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.graphics.Bitmap.createBitmap(Bitmap.java:551) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.graphics.Bitmap.createScaledBitmap(Bitmap.java:437) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.graphics.BitmapFactory.finishDecode(BitmapFactory.java:524) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.graphics.BitmapFactory.decodeStream(BitmapFactory.java:499) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.graphics.BitmapFactory.decodeResourceStream(BitmapFactory.java:351) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.graphics.drawable.Drawable.createFromResourceStream(Drawable.java:738) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.content.res.Resources.loadDrawable(Resources.java:1918) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.content.res.TypedArray.getDrawable(TypedArray.java:601) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.view.View.(View.java:2477) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.view.ViewGroup.(ViewGroup.java:379) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.widget.FrameLayout.(FrameLayout.java:94) 04-02 13:32:56.374: E/AndroidRuntime(4027): at android.widget.FrameLayout.(FrameLayout.java:90) 04-02 13:32:56.374: E/AndroidRuntime(4027): ... 26 more

forevercrashed
  • 135
  • 1
  • 1
  • 8

1 Answers1

0

If you open the layout file and remove the android:background="@drawable/green_background" from the source then it will work for you. There was a memory partition change recently and the sample has not been updated to reduce its memory footprint (eg. Big Bitmap image)

Krispy
  • 1,098
  • 1
  • 7
  • 11
  • Thanks...I assumed it was something to do with their images. Is there documentation on a proper way to use a background image such as that? – forevercrashed Apr 03 '13 at 12:56
  • The issue is more about the size of the image used. If you keep the use of big images to a minimum you will be fine. 1920x1080 pixels by 4bytes per pixel + header ~= 8Mb - your application needs to strive to use less then 64Mb or it will run out of memory. The bg image being loaded is 8.3Mb – Krispy Apr 03 '13 at 15:58
  • Ok, so the memory footprint can't be any larger than normal Android apps...if we wanted a background image like the one in the sample, would it be better to use a smaller image and tile it and apply a gradient after, or just use a lower quality image and stretch it? I assume a stretched image will look far worse on a 46" screen than on a 5" screen... – forevercrashed Apr 03 '13 at 20:02
  • You have a few options - you could go to a lower res resource. Or you can try to bypass the scaling step by using a no-scale resource (when android loads images that dont match the view it makes an in memory copy which effectivly doubling the memory footprint) - have a look at: http://stackoverflow.com/questions/13115006/drawing-bitmap-without-scaling-on-android – Krispy Apr 03 '13 at 23:08