Error when creating a new Android Project

Today I tried to make an Android Project in the JMonkeyEngine for the first time. So I went to New Project → Android → Android Project an created a new one. The problem was that there was already an exception in the main class.



[java]package my.android.testapp2;



import android.R;

import android.app.Activity;

import android.os.Bundle;



public class MainActivity extends Activity

{

/** Called when the activity is first created. */

@Override

public void onCreate(Bundle savedInstanceState)

{

super.onCreate(savedInstanceState);

setContentView(R.layout.main);

}

}[/java]



The problem was that it couldn’t find R.layout.main although it existed and was in the R.java file of the project. So I was really wondering why it wasn’t working because I didn’t even change anything. After some time I noticed that the import was incorrect.



So I replaced import android.R; through import my.android.testapp2.R or just deleted that line and it worked without any problems.



My question did somebody else have this issue and is this bug known?

Read the manual about android, you do not need to create an android project for that.

I already tried to create a new JmonkeyProject and enable Android Deployment but for some reason then I can only select “Android Device” and not “Android Emulator” in the project configuration and I would really like to run the project in my Android emulator.



Also is there any tutorial or wiki where I can find information about how to write programms for Android using the JMonkeyEngine because the only thing I found was the link how to set up and start in Android.

@hyrrokkin said:
I already tried to create a new JmonkeyProject and enable Android Deployment but for some reason then I can only select "Android Device" and not "Android Emulator" in the project configuration and I would really like to run the project in my Android emulator.


You can't. Android emulator does not support Opengl ES 2.0. You have to test on a device.


@hyrrokkin said:
Also is there any tutorial or wiki where I can find information about how to write programms for Android using the JMonkeyEngine because the only thing I found was the link how to set up and start in Android.

there is no more doc about android, because all the other doc also apply for desktop.
You write a program with JME, and then it's deployed on android...
1 Like
@nehon said:
You can't. Android emulator does not support Opengl ES 2.0. You have to test on a device.

Actually that might work (in the next release) but it would be the same, you'd just start the emulator instead of connecting a phone and then select "Android Device" for both emulator or phone.

@nehon @norman



OpenGL ES 2.0 works in some way in the Android emulator now. See this thread:

http://hub.jmonkeyengine.org/groups/android/forum/topic/tracer-for-opengl-es/



You have do the following things:

  • Create an AVD with a system image of Android 4.1.x.
  • Set the parameter hw.gpu.enable=yes.



    I have only tested the BasicGame template, so I don’t know if advanced features work too. The refreshing bug is fixed at least.

Last time I tried it the gui viewport was not refreshing correctly and fill rate was even worse than on a device…

This emulator is not meant for 3D, they tried but they failed.