Android Loading HelloTerrain

Hi guys,

I’m getting the following error when trying to load Hello terrain on android.

I/AndroidImageInfo(14373): Bitmap was deleted. I/AndroidHarness(14373): INFO AndroidHarness 11:10:52 AM Splash Screen Picture Resource ID: 0 W/dalvikvm(14373): threadid=11: thread exiting with uncaught exception (group=0x40a5b1f8) E/AndroidHarness(14373): Exception thrown in Thread[GLThread 1482,5,main] E/AndroidHarness(14373): com.jme3.renderer.RendererException: OpenGL Error 1280. Enable error checking for more info. E/AndroidHarness(14373): at E/AndroidHarness(14373): at E/AndroidHarness(14373): at android.opengl.GLSurfaceView$GLThread.guardedRun( E/AndroidHarness(14373): at android.opengl.GLSurfaceView$ D/dalvikvm(14373): GC_CONCURRENT freed 1642K, 71% free 7085K/24135K, paused 1ms+7ms

Here is the code i'm using to create the map
Material mat_terrain; TerrainQuad terrain; mat_terrain = new Material(assetManager, "Common/MatDefs/Terrain/Terrain.j3md"); /** 1.1) Add ALPHA map (for red-blue-green coded splat textures) */ mat_terrain.setTexture("Alpha", assetManager.loadTexture( "Textures/alphamap1.png"));
    /** 1.2) Add GRASS texture into the red layer (Tex1). */
    Texture grass = assetManager.loadTexture(
    mat_terrain.setTexture("Tex1", grass);
    mat_terrain.setFloat("Tex1Scale", 64f);

    /** 1.3) Add DIRT texture into the green layer (Tex2) */
    Texture dirt = assetManager.loadTexture(
    mat_terrain.setTexture("Tex2", dirt);
    mat_terrain.setFloat("Tex2Scale", 32f);

    /** 1.4) Add ROAD texture into the blue layer (Tex3) */
    Texture rock = assetManager.loadTexture(
    mat_terrain.setTexture("Tex3", rock);
    mat_terrain.setFloat("Tex3Scale", 128f);

    Texture heightMapImage = assetManager.loadTexture(
    ImageBasedHeightMap heightmap = null;
    try {
        Class c = Class.forName("com.mycompany.mygame.AndroidImageBasedHeightMap");
        heightmap = (ImageBasedHeightMap) c.newInstance();
    } catch (Exception ex) {
    int patchSize = 20;
    terrain = new TerrainQuad("my terrain", patchSize, 129, heightmap.getHeightMap());

Device Details
Samsung S2 running Android 4, with custom cyanogenmod.

BTW android SDK 2.2 is used for this project.

The error only ocurres when using TerrainQuad. Currently i’m working on porting a PC game to Android most of the functionality has been completed without using terrain. I’ve searched the entire website but failed to find any terrain working examples on android.

if anyone has a working terrain example on android please share it :slight_smile: i will really appreciate your help.

a few months ago, i remember someone saying terramonkey had trouble on android. It may be fixed now, idk, try updating everything

Hi wezrule,

Thanks for the reply, I updated the SDK with nightly build still having the same problem. By any chance have you tried using a terrain on android,

was it successful? I’m just wondering whether we can use terrains on android at all.


Downloaded the JME Test from Google play, tested the Hello Terrain example which doesn’t seem to work on Samsung S2 and S3.

I don’t think terrain works for Android yet. At least it didn’t the last time I tried it. However, I would have expected an npe on the image.getData call not the 1280 error. In any case, I don’t terrain works yet for Android.

Bugger!, my entire game is based on a terrain :(.

My game is based on a terrain and I have a crash on Android too. When I run the TerrainGridTileLoader sample it also crashes.

When I have time want to debug my application and see if it is the terrain what makes it crash.

@Sploreg : Do you know you what the current status of TerraMonkey on Android is ? Maybe I want to look myself for the problem, but I don’t know if I have the knowledge to find it.

I’m not sure why you are getting that error, I haven’t seen anyone else get it before. I don’t have any android devices at my disposal and I haven’t tried terrain on any yet, although others have and have gotten it to work, hence the AndroidImageBasedHeightMap that does the pixel reading of the heightmap. That should be the only thing needed.

What happens if you try the terrain with the Unshaded material?

@Sploreg : I have tried it with the Unshaded material, but It still gives the same error. I’ll come back to this later this week.

Thanks for your help.

Edit: It’s for this game if your interested: :slight_smile:

Let me know how it goes, I would like to get it working seamlessly eventually.

How are you loading the heightmap?

I load it this way:



AbstractHeightMap heightmap = null;

try {

//heightmap = new HillHeightMap(1025, 1000, 50, 100, (byte) 3);

heightmap = new ImageBasedHeightMap(heightMapImage.getImage(), 1f);


} catch (Exception e) {




I’m going to make the heightmap a little bit smaller to reduce the loading time for my phone. I have this phone:

You cannot use ImageBasedHeightMap on android. You have to use a specialized one to load the raster data. Currently the getPixel/setPixel stuff is in a bit of a flux state, once it settles down an official AndroidImageBasedHeightmap will be created.

This post has a sample class that should work for loading the heightmap on android.

I tried to implement the code, but I’ve got some trouble with the imports. I have these imports:

import com.jme3.asset.AndroidImageInfo;

import com.jme3.math.ColorRGBA;

import com.jme3.terrain.heightmap.ImageBasedHeightMap;

import com.jme3.texture.Image;

import java.nio.ByteBuffer;

But it can’t find the following classes:

Bitmap → Bitmap bitmap = imageInfo.getBitmap();

Color → float h = * heightScale;

Do you know what imports I should add ? The IDE doesn’t give the right suggestions.

Bitmap is in the package. This page tells you how to set up Android in your project and add the proper plugin.

I have installed NBAndroid and added the following imports:

It still doesn’t find the imports. When I manually add the android.jar it finds the imports, but it goes wrong with the Pre-Dexing.

Is the getPixel/setPixel stuff still in a little bit of a flux state ? Has it to do with the new JOGL renderer ?

@Sploreg : I saw you checked in and the other changes. I didn’t had time to test is it yet, but already thanks for it.