Android deployment via SDK checkbox is HERE!

Momoko_Fan said:
@normen: you can still test this particular part .. In the emulator if the app loads but crashes (opengl error etc) then you know it works

Yeh, I looked in the ant script but I couldn't find anything so the comment still stands :P

The install ant command just calls “adb install” which isn’t running the app :confused:

Android SDK isn’t exposing any ant command to run the app. That part must be handled by the plugins (Eclipse ADT or NBAndroid).



However I found this:

Launch app through adb shell - Android News & UpdatesAndroid News & Updates



You only need the package and activity name and then you can call the appropriate executable

1 Like

@normen - all this looks very interesting, I’ve been waiting for something like this for a while. So I’ve taken one of the Android/JME3 programs that I’ve developed in Eclipse and I have tried to compile it with jMonkey IDE. I’ve found lots of issues - possibly I am not doing things right.

  1. It seems that once I created a project and enabled Android deployment, I had to exit the IDE and come back for the Android Files to appear in the project. Oh well, they are there now.
  2. Once the Android Files was added to the project, the only AndroidHarness activity to appear is the MainActivity, if you call it anything else it will not be visible, it is still in the files - I am not sure if you could control what classes appear in the Android Files section - should be all? None of the other Java files in that directory would ever show up. So I use the MainActivity for now.
  3. The resources, once parsed will generate the R class, however, you need to add mobile/gen and mobile/src to your sources by hand, otherwise you get syntax errors - they could be added automatically.
  4. There is a bit of confusion as to what Android library is to be added, in fact unlike Eclipse it has to be added by hand and if you are testing your program with multiple devices, I gather you’d have to switch the libraries in and out and keep track of the android target in default.properties and AndroidManifest.xml. I also had to exit the IDE and come back for the library to clear the syntax errors which were to do with the android.xxx imports.

    I imagine this Android Support is only in beta. So far so good, I assume that my MainActivity class should be in the same package as my SimpleApplication class - I think this is a default. Finally, I have no more syntax errors and I am ready for the clean and built, however, now I am getting the following error which stopped me in my track!
Importing rules file: toolsantmain_rules.xml
Creating output directories if needed...
Compiling aidl files into Java classes...
Compiling RenderScript files into Java classes and RenderScript bytecode...
Generating R.java / Manifest.java from the resources...
FPAStatue.compile:
Compiling 2 source files to F:JacobjMonkeyFPAStatueAndroidJmemobilebinclasses
Converting compiled files and external libraries into F:JacobjMonkeyFPAStatueAndroidJmemobilebinclasses.dex...
UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcom/pineberry/fpa/MainActivity$1;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
at com.android.dx.dex.file.DexFile.add(DexFile.java:143)
at com.android.dx.command.dexer.Main.processClass(Main.java:372)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:346)
at com.android.dx.command.dexer.Main.access$400(Main.java:59)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:294)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:130)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
at com.android.dx.command.dexer.Main.processOne(Main.java:313)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:233)
at com.android.dx.command.dexer.Main.run(Main.java:185)
at com.android.dx.command.dexer.Main.main(Main.java:166)
at com.android.dx.command.Main.main(Main.java:90)
trouble processing "java/security/Provider.class":
Ill-advised or mistaken usage of a core class (java.* or javax.*)
when not building a core library.

What does it mean? How can you get rid of it?

You cannot import android projects, just make a normal jME3 BasicGame project and move the code there. To edit and use android projects “standalone”, install NBAndroid, which is added to the update center list with the Android Deployment plugin.

@normen, I am not importing the project. I create a new project and then reinserting all my code from the Eclipse project and adding the necessary Android resources. I think this error is something to do with the creation or linking of the generated resource file R. As I have a few of them I think JME is getting confused and attempts to duplicate them. I started eliminating them but now I am unable to refresh the project so that it would regenerate the R.java file. Quiting JME no longer works and clicking and unclicking of the Android deployment (as suggested in that dialog box) in the project properties does nothing.

What is “all the code”? Android specific code should go into the android project (but ideally there should be none), all other game code in the main project. Apart from that you don’t need to add anything to the resource files, the assets.jar file is added automatically to the project (all asset data should go to the assets folder obviously).

Edit: Also, make sure to press “OK” as written in the hint to delete/recreate the project.

Oh, I just realize that you probably deleted code from the MainActivity because it was underlined red or something, you don’t have to do that. Installing NBAndroid will make sure that the editor knows the android class path and the red lines disappear if they disturb you or you want to code in the android project with special android classes (which you should not need to as eventually most functions of a phone will be wrapped in some platform-independent jME3 api, like e.g. TouchEventListener). Ideally you only have to configure things like the android icon or application name and similar to deploy your normal jME3 application to android.

OK, I’ll give it a go. I think at this stage a proper way would be to use NBAndroid if you need to develop custom Android-jME3 application (e.g. with Android specific interfaces such as touch and gestures, or the use of the Android database). The new AndroidSupport is applicable to jME3 application that need to be ported whole to Android as they are (e.g. they use Nifty for their GUI). This seems to be the way to go if you do not want to port all your jME3 code to Eclipse, which has better support for Android than NetBeans - this is what I am doing at the moment after my jME3 application is up and running. However jME3 IDE is indisputably the environment to use for.jME3 development.

Again, the plugin just creates a completely normal android project you can edit with NBAndroid (and that you should be able to open in eclipse as well) and makes sure it has all libraries and code you defined in your main project when you build that.

Also, I strongly suggest not making your application depend on android-specific code too much but make it as platform independent as possible. So don’t write too much of your code in the actual android project where you have access to the android.jar, just whats really needed for android. This way future deployment options like iOS, WebGL etc. etc. will work without hassle. We see jME3 less as a library and more as a platform to develop games. Why only deploy your game to android when it will run fine in a browser or another device too?

@Normen: Do you allready have an idea how to create a deployment option for iOS ? There is still no standard JRE included with iOS.



What I understand from the Unity website is that it created an Xcode project for you. Are you going to do a java->objective C conversion for jME3 ?

Vortex said:
@Normen: Do you allready have an idea how to create a deployment option for iOS ? There is still no standard JRE included with iOS.

What I understand from the Unity website is that it created an Xcode project for you. Are you going to do a java->objective C conversion for jME3 ?

Yeah, using xmlvm.

That’s a nice tool. I’m going to buy a new phone next summer. It looks like all options are still open with this tool (Android or IPhone/iOS).

Yeah, it doesn’t quite work out of the box yet otherwise I would have built it into the deployment right away but I’m playing with it every now and then… Basically we would go the way of converting the android project thats created to a xmlvm project (see their documentation) and then using that to build android and iOS. If anyone digs into this and finds out interesting stuff then report back here, its easy to try since you can rebuild the android project at any time :wink:

Having a problem getting started with the SDK android stuff.



I created a Basic Game with the ‘new project’ option and then added the android option. When I try to build or run I get the following messages. I have not changed any of the generated code. Help.



Morris





init:

Deleting: /Users/morrisford/jMonkeyProjects/MorrisBasicGame2/build/built-jar.properties

deps-jar:

Updating property file: /Users/morrisford/jMonkeyProjects/MorrisBasicGame2/build/built-jar.properties

compile:

Copying 1 file to /Users/morrisford/jMonkeyProjects/MorrisBasicGame2/build

Copy libraries to /Users/morrisford/jMonkeyProjects/MorrisBasicGame2/dist/lib.

To run this application from the command line without Ant, try:

java -jar “/Users/morrisford/jMonkeyProjects/MorrisBasicGame2/dist/MyGame.jar”

Copying 12 files to /Users/morrisford/jMonkeyProjects/MorrisBasicGame2/mobile/libs

jar:

run-android:

Android SDK Tools Revision 10

Project Target: Android 2.2

API level: 8


Resolving library dependencies:
No library dependencies.



Importing rules file: tools/ant/main_rules.xml
Creating output directories if needed...
Compiling aidl files into Java classes...
Compiling RenderScript files into Java classes and RenderScript bytecode...
Generating R.java / Manifest.java from the resources...
MyGame.compile:
Compiling 1 source file to /Users/morrisford/jMonkeyProjects/MorrisBasicGame2/mobile/bin/classes
Converting compiled files and external libraries into /Users/morrisford/jMonkeyProjects/MorrisBasicGame2/mobile/bin/classes.dex...

UNEXPECTED TOP-LEVEL EXCEPTION:
java.lang.IllegalArgumentException: already added: Lcheckers/quals/DefaultLocation;
at com.android.dx.dex.file.ClassDefsSection.add(ClassDefsSection.java:123)
at com.android.dx.dex.file.DexFile.add(DexFile.java:143)
at com.android.dx.command.dexer.Main.processClass(Main.java:372)
at com.android.dx.command.dexer.Main.processFileBytes(Main.java:346)
at com.android.dx.command.dexer.Main.access$400(Main.java:59)
at com.android.dx.command.dexer.Main$1.processFileBytes(Main.java:294)
at com.android.dx.cf.direct.ClassPathOpener.processArchive(ClassPathOpener.java:244)
at com.android.dx.cf.direct.ClassPathOpener.processOne(ClassPathOpener.java:130)
at com.android.dx.cf.direct.ClassPathOpener.process(ClassPathOpener.java:108)
at com.android.dx.command.dexer.Main.processOne(Main.java:313)
at com.android.dx.command.dexer.Main.processAllFiles(Main.java:233)
at com.android.dx.command.dexer.Main.run(Main.java:185)
at com.android.dx.command.dexer.Main.main(Main.java:166)
at com.android.dx.command.Main.main(Main.java:90)
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.xmlpull.v1.builder.impl.XmlDocumentImpl$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.xmlpull.v1.builder.impl.XmlElementImpl$1) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.xmlpull.v1.builder.impl.XmlElementImpl$2) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
warning: Ignoring InnerClasses attribute for an anonymous inner class
(org.xmlpull.v1.builder.impl.XmlElementImpl$3) that doesn't come with an
associated EnclosingMethod attribute. This class was probably produced by a
compiler that did not target the modern .class file format. The recommended
solution is to recompile the class from source, using an up-to-date compiler
and without specifying any "-target" type options. The consequence of ignoring
this warning is that reflective operations on this class will incorrectly
indicate that it is *not* an inner class.
1 error; aborting
/Users/morrisford/jMonkeyProjects/MorrisBasicGame2/nbproject/mobile-impl.xml:5: The following error occurred while executing this line:
/Users/morrisford/Downloads/android-sdk-mac_x86-1/tools/ant/main_rules.xml:472: The following error occurred while executing this line:
/Users/morrisford/Downloads/android-sdk-mac_x86-1/tools/ant/main_rules.xml:203: apply returned: 1
BUILD FAILED (total time: 15 seconds)

Hm, no idea, is there two jMonkeyEngine3.jar files being copied in the mobile project libs somehow?

In the project, I found one in dist/lib and one in mobile/libs. That’s what I would expect. Can you build a basic game from the project menu, add the mobile option and have it build and run?



Morris

Yeah, sure, and others too, thats why I wonder whats wrong there…

I removed the install of the SDK and the projects space and reinstalled from a new download.

I then installed the android support plugin.

Created a basic game.

Added the mobile option.

The MainActivity.java has errors on every line but it runs and installs to an android device.

I then added the jme3-android library. The errors in MainActivity went away and the error from before came back on trying to run.

I removed the jme3-android library and the errors in MainActivity came back but the program will not run and the error is as before.



It would appear that

adding the library jme3-android that way is not the correct thing to do.

removing that library leaves a copy somewhere.



What library do I add to get rid of the errors in MainActivity and still be able to run the program?



Morris

Re-read the first post, the android libraries are added automatically and the errors in the MainActivity are only in the editor, install NBAndroid (the plugin named “Android”) to have the editor recognize the files class path and the android project correctly. The point is that your project is a normal jME3 application and android is just one of the deployment options.

Thanks for your help. Now that I understand what that post meant, it’s easier to understand what that post meant.



Morris