Android 5.1 error [solved]

BlitzMax Forums/Brucey's Modules/Android 5.1 error [solved]

markcw(Posted 2016) [#1]
I just followed Dabz handy tutorial for Android 5.1 (I have ARM v7a) but I'm getting an error I can't solve now:

Error creating class file 'C:/../firepaintAndroid/android-project-firepaint/src/net/dabz/test/firepaint/BlitzMaxApp.java'


I have no idea what that is but I did solve another error by creating empty folders in Bmx-ng root:

Missing resources folder for Android build : C:/../resources/android/android-project


My custom.bmk looks like this. I installed the sdk to another drive partition could that be the problem? Thanks.
addoption android.home "D:\android-sdk-windows"
addoption android.sdk "D:\android-sdk-windows"
addoption android.ndk "D:\android-ndk-r11c"
addoption android.toolchain.version "4.9"
addoption android.platform "12"
addoption ant.home "D:\apache-ant-1.9.7"


NOTE: Since there's a few essential steps missing from Dabz's Android tutorial I added them here...

- Use the latest stable release of Bmx NG here currently 0.70 with gcc 5.1, not the latest unstable to avoid unexpected errors
- When building for android remove this win32 lib link from env variable BMK_LD_OPTS "-lmsvcrt"
- Building modules for android from cmd needs syntax "bmk makemods -r -l android -g armeabiv7a pub" or armeabi/arm64v8a for older/newer architecture
- If you have a processor before armv8 it's 32 bit so you'll need the 32 bit Android NDK. Anything before Lollipop/5.0 is a 32 bit OS
- If you see "unable to resolve project target" you need to install an API with the SDK Manager, for example I needed Android 6.0/api23, 5.1/api22 and 4.4.2/api19



RustyKristi(Posted 2016) [#2]
Hey munch,

I have the same bmk but with just different SDK/NDK versions when I got to compile NG with Android the first time.

I don't think it's the drive partition but after I'm done with some work stuff I could help out and will try this NG/Android thing again and do a clean NG install.


markcw(Posted 2016) [#3]
Hey RustyKristi, well don't put yourself out if it's working for you, it's such a slow process to install this stuff.


RustyKristi(Posted 2016) [#4]
hey it's totally fine munch, it's the least I can do anyway with all the help here and your help with my stuff! :-)

I was also planning to do some NG test again because it bothered me that my last setup was broken.

So I did a quick install using Dabz's win32 package. I got my paths here (custom.bmk)

addoption android.home "C:\Users\home\AppData\Local\Android\android-sdk\"
addoption android.sdk "C:\Users\home\AppData\Local\Android\android-sdk\"
addoption android.ndk "C:\android-ndk\"
addoption android.toolchain.version "4.8"
addoption android.platform "18"
addoption ant.home "C:\apache-ant"


System Variables:

JAVA_HOME = C:\Program Files (x86)\Java\jdk1.7.0_02

I just had to remove some win32 stuff in this environment variable BMK_LD_OPTS "-lmsvcrt" and I got it in one go.. wow.


It's probably because I'm using older NDK/SDK versions.

hope this will help you in some way. cheers


RustyKristi(Posted 2016) [#5]
My only problem is it's always building in target 5.1 where I only have a 4.4 phone :/

[Edit] Took out platform-22 to use 19 (atm) but I'm still getting exit errors just like before


RustyKristi(Posted 2016) [#6]
..I ended getting my own build to work. It was the platform-22 package tool that was keeping it from building and I got it by chance when I took it out earlier.

It's a MinGW 4.8 version with a custom bmk.exe from Dabz. Firepaint example works great on my device.


markcw(Posted 2016) [#7]
Thanks RustyKristi, good to see you got it working. I'll have another go at it when I get the time.


Pingus(Posted 2016) [#8]
@Rusty, would you mind to upload somewhere the apk of firepaint ?

I also have a 5.1 arm7 and I would be amazed to see a bmx app running on it.


RustyKristi(Posted 2016) [#9]
You got it Pingus. I was just thinking about uploading it earlier. It's only 750kb in apk size with target 19 (Android 4.4) and Arm v7.

It's a stripped down version of the desktop example so it's blank with the fps counter on top left unless you started touching the screen. Just ignore the permissions, it won't do anything as I just unzipped the code and build as is.

FirePaint (Android BMX-NG)
http://www.mediafire.com/download/y970eq45rlxc5z7/firepaint-debug.apk

@munch

Great. you could try building with the default release and MinGW 4.8. I was having problems with MinGW 5.1 to build 3rd party mods even with vanilla bmx. I'm not sure the same applies with NG or I'm just doing something wrong there.


Pingus(Posted 2016) [#10]
Thanks a lot Rusty.

Guess what... it RUNS :) ! So its possible !
Funny, it generate a firework on multiple 'touches', that's great. Now I have to find what's wrong with my apk (the building works but apk stuck on a black screen few sec before quitting).

Do you have also this warning during compile ? :

Compile Warning: In call to Function SetColor:Int(red:Int,green:Int,blue:Int). Argument #1 is "Float" but declaration is "Int".




RustyKristi(Posted 2016) [#11]
Ah awesome, I'm glad! :D I also got some hint when you try building it with android and if you get a larger file (2Mb), somehow it doesn't work and it closes. I'm guessing it was the copy over libraries that I have skipped when I used the latest download from Dabz NG site.

Yes, those compiler warnings can be easily fixed by removing the float sign in the r#g# b# declarations since the colors are 0-255 integers.


Pingus(Posted 2016) [#12]
if you get a larger file (2Mb)


Yes indeed, that's the file size of my apk (even a "hello"). So how to get rid of thoses extra libraries ?


RustyKristi(Posted 2016) [#13]
I'm really not sure but if I would itemized the tools that I acquired to get it finally working, here it is:

BMX-NG v0.62
https://github.com/bmx-ng/bmx-ng/releases/tag/v0.62.3.06.win32

I think that comes with MinGW 4.8.1 so download TDM GCC 4.8.1. I remember doing the overwrite libs and ar.exe and ld.exe binaries batch script, I'm sure you already know that.

replace bmk.exe with Dabz built (hey, it's still there..)
Link: http://www.bmx-ng.com/main/files/bmk.7z

custom.bmk I already posted above

SDL mod is not included so download that, if the latest does not work, rollback and download the commit around 7 months back.

I got it for the first time months ago and when I upgraded my android tools for some other engine I'm trying to check out, it kinda ruined it but I managed to get it back a few days ago. :)


markcw(Posted 2016) [#14]
Well this is wierd, I followed all your instructions and I still get the message "Error creating class file" so it must be the partition thing.

Also, I had an error with the latest sdl.mod so I downloaded the sdl.mod dated Nov 9, 2015 before "Added multigesture support" since the error was:

C:/../sdl.mod/sdlsystem.mod/glue.c:144:26: error: 'BBEVENT_MULTIGESTURE' undeclared (first use in this function)
bbSDLSystemEmitEvent(BBEVENT_MULTIGESTURE, source,event->mgesture.touchId, 0, x, y, gesture);



RustyKristi(Posted 2016) [#15]
That is really weird munch. I wouldn't mind and could probably simulate that partition thing and see if it does throw that exact same error.

I do have another separate internal drive where I can test it.

Here's my workscreen just for reference.



I could also upload my modified BMX-NG copy or the sdl mod if you need to compare or at least narrow this issue down. I just need to remove some unnecessary build files and other stuff to make it lighter as the folder is around 800mb.

I'll upload the SDL mod first in a bit..


RustyKristi(Posted 2016) [#16]
Here you go munch.. :)

SDL Mod
http://www.mediafire.com/download/anug5o0tsl2d8pz/sdl.mod.zip

I can also confirm that it's not a partition issue, when I copied my NG installation to my D: drive and rebuild it from there.


markcw(Posted 2016) [#17]
Thanks RustyKristi! Unfortunately, your sdl mod makes no difference and I still get "Error creating class file" but I'm obviously doing something dumb here. I'm going to try to repartition my drive to make enough space for the sdk.


RustyKristi(Posted 2016) [#18]
No sweat munch :) Let me know if you still need the NG copy.


markcw(Posted 2016) [#19]
No I think I've figured it was just a dumb mistake, sorry to trouble you RustyKristi.

I wasn't building the modules for android architecture with "bmk makemods -r -l android -g armeabiv7a pub/brl/sdl".

And it seems Android is 32 bit until Lollipop/5.0 and the first 64 bit ARM processor is armv8. I got the 64 bit ndk version which caused this error:

C:\BlitzMaxNG\bin>bmk makemods -r -l android -g armeabiv7a pub
gcc not found at 'D:/android-ndk-r11c/toolchains/arm-linux-androideabi-4.9/prebuilt/windows/bin/arm-linux-androideabi-gcc.exe'

The files are there but the folder in the 64 bit ndk is "windows-x86_64".


markcw(Posted 2016) [#20]
More trouble, I built the mods with gcc 4.8.1 okay but there's a new error now. It's some kind of linker library issue, missing or path broken.

D:/android-ndk-r11c/toolchains/arm-linux-androideabi-4.9/prebuilt/windows/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld.exe: cannot find -lmsvcrt



RustyKristi(Posted 2016) [#21]
Oh I already mentioned that above, just remove "-lmscvrt" in your BMK_LD_OPTS environment or make sure it's not triggered when you target android because I thinks that's for windows only.


markcw(Posted 2016) [#22]
Thanks again RustyKristi, that was the problem.

Then I got another error but solved it by installing Android 4.4.2 (api 19) with the sdk manager:

BUILD FAILED
D:\android-sdk-windows\tools\ant\build.xml:538: Unable to resolve project target 'android-19'



So now I have "BUILD SUCCESSFUL" and an apk in the bin folder. :)

Just have to find out how to install it now.


markcw(Posted 2016) [#23]
Well, I installed Astro File Manager and switched on Security>Unknown Sources, I needed a restart after that as new apps weren't showing up. Then I copied the apk to Downloads from the PC and used Astro to find and install it which worked but when I run it I just get a black screen, this was with both my own build and RustyKristi's (I had to uninstall first from Settings>Apps).

It also does the same with Dabz's build "andytest-debug.apk" so what could it be? Do I need to be rooted?


RustyKristi(Posted 2016) [#24]
Hey munch, that's awesome when you finally got it to build! :) As for the blank screen, you can post your created apk so it can be tested publicly, at least your build can be checked on other devices.

About transferring, if you have a router on your home/work network and an apache webserver, just place it on the www folder and access it from your device like http://192.168.x.x/myapp.apk

Otherwise, just download any portable web server such as python (2 or 3) or php (5.x) builtin features

python -m SimpleHTTPServer [port]

I'm suspecting it's just some security measures on your phone..


Dabhand(Posted 2016) [#25]
Just to note, I havent tried an Android build in quite a while... But there was a bit of a major issue with Samsung Knox, as in, something was happening in code it didnt like (Like creeping out of the container your app is run in), and thus, causing Knox to throw a hissy fit and shut down your app.

I never actually figured it out why, and I did hunt, unfortunately there wasnt really any clue why from the debugger... And alas, I give up... I did try to figure it out, but, without anything meaningful from the debugger, well... Needle and haystacks!

Technology eh... You can drag and drop blocks to create a program, even create a program to create a program, use neural network programming to draw computer dreams... But if you dare want anything remotely sensible like decent error messages, your knackered... As an example and no way related to this, it boils my piss when I see:-

*Error 51: Unknown Error*
*Message 02: PID 2013 will be forcefully closed*
*Message 10: Due to an unknown error, the system has closed PID 2013, please contact Mystic Meg for more details.*

It's 2016 FFS, I had better info debugging bloody Z80 assembly using Maxam!!!

Dabz


RustyKristi(Posted 2016) [#26]
Thanks for the heads up Dabhand! So are you trying to say that the Android build does not work with the latest NG?


markcw(Posted 2016) [#27]
Thanks RustyKristy, I renamed and uploaded the apk to box.com.

Dabhand, I don't seem to have Knox on my Motorola, but there is probably an equivalent app.

Strange, when I run any installed Bmx app and touch the black screen it produces a sparkle/fireworks trail.


RustyKristi(Posted 2016) [#28]
@munch Great, hey finally works great from here! :)


markcw(Posted 2016) [#29]
Well it's still not working but some progress.

I tried removing any permissions by editing AndroidManifest.xml but no change.

I tried different settings available in Developer options such as: Disable HW overlays (GPU for screen compositing) but no change. With Motorola you need to tap 7 times on Build number to unlock Developer options.

I tried building with Dabz NG version (which has gcc 5.1) which wouldn't build until I installed api23/6.0, changing project.properties didn't seem to override it. This created an apk of about double the size made by Official NG release linked by RustyKristi (which has gcc 4.8). When installed the app was about 6.5 compared to 2.5 MB. The larger apk has an extra file libstlport_shared.so in it about 3 MB. The larger app behaves like Pingus reported, black screen for a few seconds then a message "Unfortunately, firepaint has stopped".


RustyKristi(Posted 2016) [#30]
Hey munch, I always wanted to try other emulators so I downloaded a fresh virtualbox image copy of android 5.1. When I tried my build in there it does not work as expected (exit or message stopped).

I'm going for a 4.4.2 android image later and maybe it has something to do with android os version but I'm not sure.

Anyways, maybe you can try it with an older phone with 4.4.2? Pingus got it to run which is a good thing. Your build works ok btw in my phone.


markcw(Posted 2016) [#31]
Well I've realized I was just being dumb again and it was a black screen because the firepaint demo has been changed to a sparkler. So it works in Android 5.1. Yay!

I rebuilt mods with gcc 5.1 with the player.png ship to make sure and it was fine using the official NG 0.62 release (Dabz NG release builds an apk that crashes).

I did get an error "Cannot determine toolchain dir for 'windows'" when I tried to use official bmk 3.06 to build mods but it works with Dabz bmk 3.06.


RustyKristi(Posted 2016) [#32]
great, glad it worked out. :-) yes Dabhands made some changes to the original firepaint.

I got it to work on latest NG 0.70 5.1, actually a clean install without any modifications so I'm not sure why you're getting that error. It's really awesome Brucey has fixed a lot of those android build issues. :D


markcw(Posted 2016) [#33]
Well, I tried the latest NG release 0.70 with gcc 5.1 and it worked without needing to worry about bmk which is great. The only thing I had to do was edit custom.bmk which is necessary.

Yes, Brucey has done an amazing job! Definitely.


RustyKristi(Posted 2016) [#34]
yes that custom bmk really straighten things out.

I think the only feature missing is generating a .android file. is it possible with pre.bmk, make.bmk or some file like that?

I have to do this manually otherwise I got a bunch of demos getting replaced one after the other labelled 'Blitzmax Application'

I also wonder why some apps runs on any android, emulator or actual device, given the correct api required and platform.

take for example monkey apps and other engines like unity, godot.


markcw(Posted 2016) [#35]
I think AppTitle has the default value "BlitzMax Application" maybe that would work?

I can't find any information on what a .android file is, can you explain please?

It must be something in Bmx apps that causes the issue with Knox, if that's what you mean.


RustyKristi(Posted 2016) [#36]
I can't find any information on what a .android file is, can you explain please?


Same here, but I first got that from Dab's firepaint example which kinda acts like a manifest file for android. It generates and passes more build info on the actual android build files (.xml, .properties) like a setup script.

Check out the firepaint.android file. It seems you need to name it the same as your main bmx file. Inside that you can set App name, package name, default orientation, version and other stuff.

I think it's obvious if you're doing the android build, the AppTitle$ command is ignored and instead it gets info from the corresponding .android file or else it churns out the default "BlitzMax Application" as title and without other info.

Sample Firepaint.android file (included in zip)

# application package name for Java class
app.package=net.dabz.test.firepaint

# application version code
#    An integer value that represents the version of the application code, relative to other versions.
#    You can set the value to any integer you want, however you should make sure that each successive release of your application uses a greater value.
app.version.code=1

# application version name
#    A string value that represents the release version of the application code, as it should be shown to users.
#    The value is a string so that you can describe the application version as a <major>.<minor>.<point> string, or as any other type of absolute or relative version identifier.
app.version.name=1.0

app.name=FirePaint
app.orientation=landscape


maybe Brucey could give us more details about this file


markcw(Posted 2016) [#37]
Doh! I should have thought of that. Look in bmk/bmk_util.bmx and you get the answer:
	If Not FileType(path) Then
		Print "Not Found : application settings file '" + appId + ".android'. Using defaults..."
		Return DefaultAndroidSettings()
	End If

...

Function DefaultAndroidSettings:TMap()
	Local settings:TMap = New TMap
	settings.Insert("app.package", "com.blitzmax.android")
	settings.Insert("app.version.code", "1")
	settings.Insert("app.version.name", "1.0")
	settings.Insert("app.name", "BlitzMax Application")
	settings.Insert("app.orientation", "landscape")
...

So you can change the default app.name there and rebuild bmk but I don't think it's too much hassle to manually edit the .android file.


RustyKristi(Posted 2016) [#38]
Yes it may not be much of a hassle. Thanks, I'll look into that.