[android] Crash when adding a bitmap from assets

Hello,

I don’t know if it’s a known problem (couldn’t find it with the search) but it seems that I can’t add a bitmap from assets in an android app. It keeps crashing at startup.

It seems to work with -Dlegacy though but I’d prefer to use the next version. When I make the BitmapData with code it works too. There is also no problems with html/flash/windows/neko versions, only Android.

My test project is pretty simple :

package;

import openfl.Assets;
import openfl.display.Bitmap;
import openfl.display.Sprite;
import openfl.Lib;

/**
 * ...
 * @author davel
 */
class Main extends Sprite 
{

	public function new() 
	{
		super();
		
		var bmp:Bitmap = new Bitmap(Assets.getBitmapData("assets/gameelements/decor-couleur.jpg"), null, true);
		this.addChild(bmp);		
	}

}

I don’t know what to get to help you see the problem, the logcat is pretty full of everything and i’m not used to read it and i’m not sur what to copy-paste in it. But i searched for my app name and that’s the result :

I/Timeline( 1574): Timeline: Activity_launch_request id:com.davel.demenage time:294867
V/ApplicationPolicy(  874): isApplicationStateBlocked userId 0 pkgname com.davel.demenage
D/ResourcesManager(  874): creating new AssetManager and set to /data/app/com.davel.demenage-2/base.apk
I/ActivityManager(  874): Start proc com.davel.demenage for activity com.davel.demenage/.MainActivity: pid=10822 uid=10307 gids={50307, 9997, 3003} abi=armeabi
D/ResourcesManager(10822): creating new AssetManager and set to /data/app/com.davel.demenage-2/base.apk
W/ActivityThread(10822): Application com.davel.demenage can be debugged on port 8100...
I/Timeline(  874): Timeline: Activity_windows_visible id: ActivityRecord{22913f3b u0 com.davel.demenage/.MainActivity t806} time:295548
I/WindowManager(  874): Screen frozen for +545ms due to Window{5ca9417 u0 Starting com.davel.demenage}
I/DEBUG   (  291): pid: 10822, tid: 10848, name: SDLThread  >>> com.davel.demenage <<<
I/DEBUG   (  291):     #01 pc 00127988  /data/app/com.davel.demenage-2/lib/arm/liblime.so
I/DEBUG   (  291):     #02 pc 00127c34  /data/app/com.davel.demenage-2/lib/arm/liblime.so
I/DEBUG   (  291):     #03 pc 00047c48  /data/app/com.davel.demenage-2/lib/arm/liblime.so
I/DEBUG   (  291):     #04 pc 000369ac  /data/app/com.davel.demenage-2/lib/arm/liblime.so
I/DEBUG   (  291):     #05 pc 0076696c  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (lime::graphics::Image_obj::__fromFile(String, Dynamic, Dynamic)+264)
I/DEBUG   (  291):     #06 pc 0076b9b8  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (lime::graphics::Image_obj::fromFile(String, Dynamic, Dynamic)+612)
I/DEBUG   (  291):     #07 pc 008fdbc4  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (DefaultAssetLibrary_obj::getImage(String)+976)
I/DEBUG   (  291):     #08 pc 008a2fb4  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (lime::Assets_obj::getImage(String, hx::Null<bool>)+1992)
I/DEBUG   (  291):     #09 pc 0046c470  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (openfl::Assets_obj::getBitmapData(String, hx::Null<bool>)+1040)
I/DEBUG   (  291):     #10 pc 009091f8  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (Main_obj::__construct()+212)
I/DEBUG   (  291):     #11 pc 00908614  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (DocumentClass_obj::__construct()+256)
I/DEBUG   (  291):     #12 pc 009088fc  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (DocumentClass_obj::__Create(Array<Dynamic>)+100)
I/DEBUG   (  291):     #13 pc 009b7350  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (hx::Class_obj::ConstructArgs(Array<Dynamic>)+60)
I/DEBUG   (  291):     #14 pc 008e9210  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (Type_obj::createInstance(hx::ObjectPtr<hx::Class_obj>, hx::ObjectPtr<hx::ArrayBase>)+244)
I/DEBUG   (  291):     #15 pc 00946060  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (ApplicationMain_obj::start()+1020)
I/DEBUG   (  291):     #16 pc 00944dc8  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (ApplicationMain_obj::init()+432)
I/DEBUG   (  291):     #17 pc 00944e40  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (__ApplicationMain_objinit()+12)
I/DEBUG   (  291):     #18 pc 009bbde0  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (hx::CStaticFunction0::__run()+32)
I/DEBUG   (  291):     #19 pc 0035cf14  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (Dynamic::operator()()+64)
I/DEBUG   (  291):     #20 pc 008ae0fc  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (lime::app::Event_Void_Void_obj::dispatch()+468)
I/DEBUG   (  291):     #21 pc 00819a44  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (lime::app::Preloader_obj::start()+192)
I/DEBUG   (  291):     #22 pc 001fcbb4  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (openfl::display::Preloader_obj::display_onComplete(hx::ObjectPtr<openfl::events::Event_obj>)+684)
I/DEBUG   (  291):     #23 pc 001fcc70  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (openfl::display::__Preloader_objdisplay_onComplete(hx::Object*, Dynamic const&)+72)
I/DEBUG   (  291):     #24 pc 009bc1b0  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (hx::CMemberFunction1::__run(Dynamic const&)+64)
I/DEBUG   (  291):     #25 pc 0007ba84  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (Dynamic::operator()(Dynamic const&)+72)
I/DEBUG   (  291):     #26 pc 00941694  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (openfl::events::EventDispatcher_obj::__dispatchEvent(hx::ObjectPtr<openfl::events::Event_obj>)+2248)
I/DEBUG   (  291):     #27 pc 009201e8  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (openfl::display::DisplayObject_obj::__dispatchEvent(hx::ObjectPtr<openfl::events::Event_obj>)+180)
I/DEBUG   (  291):     #28 pc 0093f730  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (openfl::events::EventDispatcher_obj::dispatchEvent(hx::ObjectPtr<openfl::events::Event_obj>)+456)
I/DEBUG   (  291):     #29 pc 008f45a4  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (NMEPreloader_obj::onLoaded()+312)
I/DEBUG   (  291):     #30 pc 001fc5a8  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (openfl::display::Preloader_obj::start()+884)
I/DEBUG   (  291):     #31 pc 008196fc  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (lime::app::Preloader_obj::create(Dynamic)+132)
I/DEBUG   (  291):     #32 pc 00944760  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (ApplicationMain_obj::create()+836)
I/DEBUG   (  291):     #33 pc 00945b94  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (ApplicationMain_obj::main()+184)
I/DEBUG   (  291):     #34 pc 0094813c  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (__hxcpp_main+4)
I/DEBUG   (  291):     #35 pc 00948038  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (hxcpp_main+40)
I/DEBUG   (  291):     #36 pc 0094812c  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (Java_org_haxe_HXCPP_main+12)
I/DEBUG   (  291):     #37 pc 000000c1  /data/dalvik-cache/arm/[email protected]@[email protected]@classes.dex
W/ActivityManager(  874):   Force finishing activity com.davel.demenage/.MainActivity
I/WindowState(  874): WIN DEATH: Window{3415ef0f u0 com.davel.demenage/com.davel.demenage.MainActivity}
I/ActivityManager(  874): Process com.davel.demenage (pid 10822)(adj 0) has died(73,566)
E/WindowState(  874): The process of this window already died: Window{3415ef0f u0 com.davel.demenage/com.davel.demenage.MainActivity} : android.os.DeadObjectException
D/CrashAnrDetector(  874): pid: 10822, tid: 10848, name: SDLThread  >>> com.davel.demenage <<<
D/CrashAnrDetector(  874):     #01 pc 00127988  /data/app/com.davel.demenage-2/lib/arm/liblime.so
D/CrashAnrDetector(  874):     #02 pc 00127c34  /data/app/com.davel.demenage-2/lib/arm/liblime.so
D/CrashAnrDetector(  874):     #03 pc 00047c48  /data/app/com.davel.demenage-2/lib/arm/liblime.so
D/CrashAnrDetector(  874):     #04 pc 000369ac  /data/app/com.davel.demenage-2/lib/arm/liblime.so
D/CrashAnrDetector(  874):     #05 pc 0076696c  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (lime::graphics::Image_obj::__fromFile(String, Dynamic, Dynamic)+264)
D/CrashAnrDetector(  874):     #06 pc 0076b9b8  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (lime::graphics::Image_obj::fromFile(String, Dynamic, Dynamic)+612)
D/CrashAnrDetector(  874):     #07 pc 008fdbc4  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (DefaultAssetLibrary_obj::getImage(String)+976)
D/CrashAnrDetector(  874):     #08 pc 008a2fb4  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (lime::Assets_obj::getImage(String, hx::Null<bool>)+1992)
D/CrashAnrDetector(  874):     #09 pc 0046c470  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (openfl::Assets_obj::getBitmapData(String, hx::Null<bool>)+1040)
D/CrashAnrDetector(  874):     #10 pc 009091f8  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (Main_obj::__construct()+212)
D/CrashAnrDetector(  874):     #11 pc 00908614  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (DocumentClass_obj::__construct()+256)
D/CrashAnrDetector(  874):     #12 pc 009088fc  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (DocumentClass_obj::__Create(Array<Dynamic>)+100)
D/CrashAnrDetector(  874):     #13 pc 009b7350  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (hx::Class_obj::ConstructArgs(Array<Dynamic>)+60)
D/CrashAnrDetector(  874):     #14 pc 008e9210  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (Type_obj::createInstance(hx::ObjectPtr<hx::Class_obj>, hx::ObjectPtr<hx::ArrayBase>)+244)
D/CrashAnrDetector(  874):     #15 pc 00946060  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (ApplicationMain_obj::start()+1020)
D/CrashAnrDetector(  874):     #16 pc 00944dc8  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (ApplicationMain_obj::init()+432)
D/CrashAnrDetector(  874):     #17 pc 00944e40  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (__ApplicationMain_objinit()+12)
D/CrashAnrDetector(  874):     #18 pc 009bbde0  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (hx::CStaticFunction0::__run()+32)
D/CrashAnrDetector(  874):     #19 pc 0035cf14  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (Dynamic::operator()()+64)
D/CrashAnrDetector(  874):     #20 pc 008ae0fc  /data/app/com.davel.demenage-2/lib/arm/libApplicationMain.so (lime::app::Event_Void_Void_obj::dispatch()+468)
D/CrashAnrDetector(  874): processName:com.davel.demenage
D/CrashAnrDetector(  874): broadcastEvent : com.davel.demenage SYSTEM_TOMBSTONE

I’m using :
lime 2.8.2
openfl 3.5.3
(I code with flashdevelop on windows10 and test on an galaxy S4)

PS : I tried the “Displaying a Bitmap” sample : same problem.

Just posted this yesterday.
Seems like a bug in latest openfl/lime.

My temp solution:
If you revert to openfl 3.4.0 and lime 2.7.0, this will be ok.

Hope they will resolve this soon…

Oh I’ve seen it but I thought it was a different problem since you load external images, thanks !
I’ll use -Dlegacy for the moment.

Yep, I have the same trouble. Here is the output what I got in -verbose mode:
http://hastebin.com/kudidiwoma.vbs

Lime 2.8.1 should be fine, Lime 2.8.2 has a regression here, but it’s fixed in the repository and should go out in the next release pretty soon

1 Like