I’m trying to load texture from mounted obb expansion file, but AndEngine can’t open this file. That’s my code:
BuildableBitmapTextureAtlas atlas = new BuildableBitmapTextureAtlas(textureManager, 2048, 2048, TextureOptions.BILINEAR_PREMULTIPLYALPHA);
BitmapTextureAtlasTextureRegionFactory.setAssetBasePath(obbManager.getMainRoot() + "/");
File file = new File(obbManager.getMainRoot() + "/background.png");
if (file.exists()) {
System.out.println("!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!");
}
background = BitmapTextureAtlasTextureRegionFactory.createFromAsset(atlas, this, "background.png");
And that’s what I see in Logcat:
02-10 22:40:09.170: INFO/System.out(20962): !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
02-10 22:40:09.180: ERROR/AndEngine(20962): Failed loading Bitmap in AssetBitmapTextureAtlasSource. AssetPath: /mnt/obb/8d6d9efb8ab5fbfaa452d7ff7e8047c5/background.png
java.io.FileNotFoundException: /mnt/obb/8d6d9efb8ab5fbfaa452d7ff7e8047c5/background.png
at android.content.res.AssetManager.openAsset(Native Method)
at android.content.res.AssetManager.open(AssetManager.java:315)
at android.content.res.AssetManager.open(AssetManager.java:289)
at org.andengine.opengl.texture.atlas.bitmap.source.AssetBitmapTextureAtlasSource.create(AssetBitmapTextureAtlasSource.java:48)
at org.andengine.opengl.texture.atlas.bitmap.source.AssetBitmapTextureAtlasSource.create(AssetBitmapTextureAtlasSource.java:39)
at org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory.createFromAsset(BitmapTextureAtlasTextureRegionFactory.java:140)
at org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory.createFromAsset(BitmapTextureAtlasTextureRegionFactory.java:132)
at org.andengine.opengl.texture.atlas.bitmap.BitmapTextureAtlasTextureRegionFactory.createFromAsset(BitmapTextureAtlasTextureRegionFactory.java:128)
So, the file exists, but I’m still getting FileNotFoundException.
I’ve got it:
createFromAssettried to find my file not in/mnt/.../background.png, but in apk’sassets/mnt/.../background.png. So I should use AndEngine’s FileBitmapTextureAtlasSource: