I am trying to develop a game for android and I started to learn from jMonkey tutorials for beginners.
The examples are running well on jMonkey SDK but when I try them on my phone, or emulator I am getting an error. I tried HelloCollision example and it has some asset files (town.zip) There is a screenshot from my phone. Click here
If I put some files into the Project Assets folder and try to use them in code, there is no problem with jMonkey SDK in computer but doesn’t work on my phone, emulator etc.
But the examples like creating some cubes, rotating them or like these examples (not relevant with asset folder) run on android well.
Is there anyone can help me?
I think the last time I ran that tutorial I had to put the town.zip file on the root of the SDCARD directory on the phone and use “/town.zip” or "town.zip’ in your code.
I’m sure he would be, since he made it for me
@iwgeric said: I think the last time I ran that tutorial I had to put the town.zip file on the root of the SDCARD directory on the phone and use "/town.zip" or "town.zip' in your code.
I tried like you said and some other possibilities but I got same error.
We are moving to another 3d game engine. Thanks for your attention
@wezrule said: i'm sure @nehon would be proud, if he was still arounduh....I'm still around...where do you think I'm going?
Sorry to hear you are moving on. I was able to get this to work by copying the town.zip file to the root of the internal storage memory of my phone and changing the following line of code.
This example is a little tricky when using it on Android because the storage location path is device specific and is a little different on devices that have multiple storage locations (ie. internal storage memory + external storage memory).
Normally, assets would be stored inside the project Assets folder in the jME SDK as normal files, not as zip files. They would then be automatically found by the jME asset manager system. This one is special because it is using a zip file outside the normal jME assets folder.
jME is a good engine, even on Android. I hope you keep looking at it.
I am really appreciate for your reply. Trying to work with zip file did not work on my phone but I tried extract it and used FileLocator.class and after that it worked fine.
My problem is gone now.
I have one more question. After I finished my project, how can I share this with other people or how can publish it on google play? I mean, the apk file doesnt include the files in assets folders. I am running the application because I put them onto sdcard manually. Is there a solution for this?
Publishing on google play is exactly the same as for any other android app. There is loads of info out there that is probably more detailed/current than anything we could give you.
I have already some applications on google play, and I have experience about that. But for this situation, I have to put the assets files manually into the sdcard and after that I can be able to install and run the application.
I know I am not good at English. I hope you understand what my problem is
@yns1905 said: I have one more question. After I finished my project, how can I share this with other people or how can publish it on google play? I mean, the apk file doesnt include the files in assets folders. I am running the application because I put them onto sdcard manually. Is there a solution for this?
Using resources outside the project should be the exception, not the norm. If you place your assets in the Project Assets directory in the SDK a lot of this is managed automatically during the build process. For example, if you have textures or j3o models that you are loading and you’ve placed them in the Project Assets directory like the wiki recommends, then an apk is created that includes the assets inside it.
For your own assets build them into the jar files (and hence the apk) and they will just install as part of one package.
If you just put the assets in the Project Assets directory in the SDK and hit Play, everything is handled automatically and all the assets will end up in the apk file.
I already did like you said but the apk file doesnt include the assets files. I solved the problem like that; put the files manually and change the assets directory to “mnt/sdcard/…”
My problem is occuring because of apk doesnt have the assets
Anyway, I am really appreciate for your interests. I should finish the project and then think about that problem
Thank you guys
Ok, I figured out why this is happening. Here is what happens when you build a project:
The first step in building the project includes taking the assets in the Project Assets directory and packing them into assets.jar. This file is used by the PC version and includes the project assets. However, during the creation of the assets.jar file, *.scene and *.mesh.xml files are excluded.
After the PC version of the app is built, the Android build kicks in. This includes taking the assets.jar file and unzipping it into the mobile/assets directory so the files are available on the Android platform. However, since the *.scene and *.mesh.xml files are excluded from the assets.jar file, they do not end up in the mobile/assets directory and therefore do not end up in the apk file.
To do this the right way, extract the town.zip file into a directory like project_root/assets/Scenes/Town, right click on the main.scene file and select “Convert to j3o Binary”. This will create a main.j3o file that will be included in the assets.jar file and the apk file.
You’ll then need to change the source code load the j3o file instead of the main.scene file.
// assetManager.registerLocator("/mnt/sdcard/town.zip", ZipLocator.class);
// sceneModel = assetManager.loadModel(“Scenes/Town/main.scene”);
sceneModel = assetManager.loadModel(“Scenes/Town/main.j3o”);
Sorry for my late reply.
It is running great and I am able to focus only my project. I am really thankful for your interest.