Building to 3.2 not 4.2?

Monkey Targets Forums/Android/Building to 3.2 not 4.2?

Xyloman(Posted 2013) [#1]
Monkey says its building for 3.2 is there a way to change it to build to 4.2 android?


Ironstorm(Posted 2013) [#2]
You've to set the "targetSDKversion" in the AndroidManifest.xml to 17.


Xyloman(Posted 2013) [#3]
Still says
[gettarget] Project Target: Android 3.2


Ironstorm(Posted 2013) [#4]
I'm currently not on my PC. Are you sure, you've changed the right AndroidManifest.xml? In the build dir there are two of them. In "android/Layouts/" is the right one. Monkey overrides the other one while compiling.


Xyloman(Posted 2013) [#5]
Ahhh yep i changed the wrong one. cheers


Midimaster(Posted 2013) [#6]
What about this "targetSDKversion"? By default mark set it to 7.
Now I have some questions. Maybe you can help me?

Do I have to expect any problems with installations on older smart phones (2.3) when I change the value to 17?

Do I have to download any updates of the android SDK to do this?

There is no folder "android/Layouts/" in my build folder? And I thought I have to change the manifest in "android/templates/" permanent?


Ironstorm(Posted 2013) [#7]
As I said, I wasn't at my PC. Of course, the folder could be "templates".
You've two values. "targetSDKversion" is the Android version which you (the developer) tested. Any newer Android Version can install your app, but you doesn't guarantee that your app work properly.
The second value is "minSDKversion". This is the minimum Android version which your app will work on.

And on devices with honycomb (android 3.x) or newer your app automatically get this software menu button, which cause your screen resolution will be smaller. Because newer smartphones hasn't those hardware menu buttons anymore.
But if you set your targetSDKversion to Android 4.x, it just shown up when you create a context menu. And as I understand, there isn't any other way to deactivate this software menu button than set your targetSDKversion higher.

And yeah, you've to install the target SDK through the Sdk tool.


Xyloman(Posted 2013) [#8]
Changed them and still says target is 3.2 in log.


DGuy(Posted 2013) [#9]
Two ways:

For all projects:
In the file "/targets/android/project.properties", change "target=android-13" to "target=android-17"

NOTE: The "<appname>.build/android" directory will need to be deleted for this change to take affect.


For a single project:
In the file "<appname>.build/android/ant.properties", add "target=android-17"


Midimaster(Posted 2013) [#10]
Ironstorm, thank you a lot for this additional informations. I'm not very firm in Android things.... and always unsure, what will be the side effects, when changing my running system.

So in general it makes sense to update now the SDK to version 17 and set the parameters in monkey permanant to 17.

From this moment Monkey would compile with the SDK 17. And it has no negative effects on older (2.3) smartphones... OK...

*** EDIT ***

Ok, I tried to fetch the SDK 17 with the Android SDK Manager. But after actualizing at the beginning the manager only offers me 3 downloads in the SDK 17 area:

Intel X86...
Mips System..
Google Apis...

The older SDKs always contain also "SDK Platform API xx" and Samples and Documentation.

And when I try to start these 3 downloads the SDK manager informs me about dependencies to the missing "SDK Platform API 17"

But the Manager does not offer me the download of this. What do I do wrong?


Ironstorm(Posted 2013) [#11]
Try to check "Force https://... sources to be fetched using http://..." in Tools->Options. After that install the previous SDK "API 16". Maybe you've to install this at first.


Midimaster(Posted 2013) [#12]
Oh! Nice! This https.. worked! Thank you

SDK API 16 was already installed.

Suddenly the manager detects 13 updates. Now I will update all and hope, that afterwards my monkey still compiles to android target. keep fingers crossed... as a pessimist I don't like updates


Gerry Quinn(Posted 2013) [#13]
Thanks for the tip about versions. My current project can live with the soft menu, but I have another where I'd really like the option of killing it.

It really hurts a lot of landscape-mode games. How many times have you accidentally hit soft-back in Fruit Ninja, for example? Terrible decision by google to not have a way to escape it (there could be a special gesture to force it back if apps go bad).

[And even more annoying to read Googlebots on forums telling us why hard keys are bad.]


Midimaster(Posted 2013) [#14]
ok, I have changed all things as you told me. But the result is still a build with this lines in ANDROID.MANIFEST:

...	<uses-sdk 
		android:minSdkVersion="3"
		android:targetSdkVersion="7" />
...


That's like before! What would be the corrrect value? ="17"?

And the apps are not running on Android 4.2.

When I build the protocoll shows this:


Could it be, that I additional have to set the targetSdkVersion in the ANDROID.MANIFEST manually? Or should (can) I change this in...

C:\MonkeyPro66\targets\android\templates\android.manifest

???

An what about Monkey V69? There is no file "/targets/android/project.properties" any more. Where can I set the SDK version now?


Is this bug message still valid? Do I have to do this fix? Or is it already solved in V66?:

http://www.monkeycoder.co.nz/Community/post.php?topic=4138&post=44418
buf.position( 0 ); 
GLES11.glTexImage2D


Please help me...


Midimaster(Posted 2013) [#15]
Could somebody please run this code and the corresponding apk on a android 4.2 target.

All users that reported problems with this test-app had a Nexus 4.2 tablet, and I do'nt know whether this is a only "nexus" problem. They tell me,the app does not "crash", but ends immediately.

sample:


here is the compiled apk. Done with Monkey V66 and SDK 21

http://www.midimaster.de/temp/monkeygameD.apk

Strange, but this code would run on 4.2:



mteo77(Posted 2013) [#16]
hello.
I tried to download your .apk and it didn't even start.
If i compile the code, install it and then run it its fine.
I would suspect it's something to do with whats installed on your pc.
I tried it on a SGS2 with 4.1 and nexus 10 with 4.2


Midimaster(Posted 2013) [#17]
What monkey version do you use? What SDK?

I don't have problems on all android 4.x version, but 4.2. At first I thoung about a problem in my code. But because I can reduce it to this above, I am sure too, it has to be a problem with the files of building...

I will now download monkey V69 and compile it. Could somebody please test this on a 4.2 smartphone?

This time the filename ends with an "E" and the testscreen has blue color:

http://www.midimaster.de/temp/monkeygameE.apk

I have some new lines in the protocol. I saw nver before:

and the "red button" on TED does not stop. Is this normal?


mteo77(Posted 2013) [#18]
I have SDK 21.1 rc3.
Monkey 67f.
Apache ant 1.9.0.
Java 32 1.7.0.17.
I remember having the missing dependencies error before.
What i did was to uninstall java, uninstall the sdk, uninstall apache ant.
Download the right version from the web, after that i updated and installed nearly every package from the sdk manager.
You probably already tried all of this , but that's what i did.


Midimaster(Posted 2013) [#19]
can you please test this build on a android 4.2:

http://www.midimaster.de/temp/monkeygameE.apk

It is the same test app like yesterday. This time the file name ends with an "E" and the testscreen should show blue color.

thank you


mteo77(Posted 2013) [#20]
It works on a nexus 10 4.2.
But the screen isn't blue its purple.


Midimaster(Posted 2013) [#21]
Oh! nice to hear!!! thanks a lot. Maybe it was really a problem of the V66....

You'r right: it was purple.. 225,0,255

So I would start another test. Would you help me again?

I try to compile my main app "Score-Trainer" with V69 and will put it on my server. Then you could install an run it for only testing, whether it starts or not. I know you have not much time at the moment, so a test about "it's starting" is sufficient.

I will be ready in about 7 hours and check back in...


mteo77(Posted 2013) [#22]
Don't worry i am happy to help for a change.
Usually it's me asking for it :P


Midimaster(Posted 2013) [#23]
Sorry for the delay. When I changed my app to monkey V69 the builder found so many bug, that I needed a whole further night to remove them.

Now it seems, that I can show it to the world...

Would you please have a look on it. I'm only interested, whether it runs or not on Android 4.2. You can also check on 4.1. Advanced tests are not necessary yet.

Here is the file:

http://www.midimaster.de/temp/score.apk


mteo77(Posted 2013) [#24]
On both of my devices the app install, start but as soon as you see the first screen it freezes and it says "Unfortunately blabla has stopped".
That means the new version doesn't run on 4.0.4 and on 4.2.


Midimaster(Posted 2013) [#25]
that are no good news, because the last stabil version...

https://play.google.com/store/apps/details?id=com.midimaster.scoretrainer

.... made with V66 runs on 4.0 and 4.1 as far as I know!

Could please somebody confirm, that the app store version runs with android 4.0 and 4.1?


Now I only can hope, that this is only a small bug in my code and not a fundamental monkey error.

"first screen" means you saw the picture of "two hand on an piano". Or did you already see the main screen?


Midimaster(Posted 2013) [#26]
ok... I updated...
ant to 1.9.0
java to 1.7.17
Monkey is V69
Android SDK 17

With this I builded a new version of my score-trainer:

http://www.midimaster.de/temp/scoreb.apk

Can someone please test this on any Android 4?


mteo77(Posted 2013) [#27]
Yes it stops on the 2 hands on the piano.
And latest version stops on all my devices.


Midimaster(Posted 2013) [#28]
thank you,..

to get any results I now devided the code. I hope to surround the bug this way.

This part of today contains all OnCreate() stuff, but nearly no OnUpdate() stuff. The OnRender() stuff is reduced to only show the hands and the manual. As a proof that it's still running you will see the Millisecs() on the screen.

Would you please test the code agin on both Android 4 devices?

here is the app:

http://www.midimaster.de/temp/scoreD.apk


With the help of JIM I think now the MNET module could cause the problems. So I have isolated the MNET to a small test app.

http://www.midimaster.de/temp/TestMnet.apk

it should contact my server and send you back a phrase. Please check if the Millisecs() keep on running after a break of 3 seconds.

Here is the code. Only if the app above crashes you could test the code for me. The code needs the MNET module.



My MNET module has a single workaround in mnet.android.java. It prevents from crashing monkey if there is no internet connecection:

....
  public String convertStreamToString( InputStream is )
  {
	// this line is added by MIDIMASTER:
	if (is == null) return "ERROR no Connection";
    StringBuilder sb = new StringBuilder();
    try
    {
....



JIM(Posted 2013) [#29]
Hi there! I tested both. scoreD.apk works fine. TestMNet works fine until I tap the screen and the crash looks the same: Apparently MNet Get is having an issue.

(probably a stupid question) Did you request internet permissions in the manifest?

This looks like MNet needs an update. Took a look into ZygoteInit.java and mnet.android.java and at first glance it looks ok, but I think there might be changes to the way http requests are made in 4.2.

EDIT: Herp derp. Took a closer look at the log. I knew something is different with http requests in 4 or 4.x;

android.os.NetworkOnMainThread exception. Apparently the request must be threaded. This should be made as an update to MNet. Or as an alternative try to find another library for the http requests.


Midimaster(Posted 2013) [#30]
yes, both permissions are integraded:
	<uses-permission android:name="android.permission.INTERNET" />
	<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" />

...and I know, it runs perfect on 2.3 to 4.0.



ScoreD.apk is without MNET, and TestNmet.apk is without MNET until you Touch(). Then it tries to use the Http request. I did sent also the source code of TestNmet.apk. (see post #28 above...)


What I would like to know is now, whether MY system builded a buggy code, or whether the MNET module has bugs also, if somebody else build the sample code on his computer.

Would you please also test the source code of the post #28?

I feel, we are closed to the target...


thank you so much


JIM(Posted 2013) [#31]
I added another edit as you replied :)

MNet must be modified to work in ASync mode. This is a good practice anyway since it won't freeze your app while you do the request.

EDIT: And another edit! MNet already supports this, yay!

Don't use Get! Use AGet(...) and GetResult()

You will have to check and make sure it's not "" or starts with "ERR".


Midimaster(Posted 2013) [#32]
thanks a lot, you are the best...I will test this and reply tomorrow


mteo77(Posted 2013) [#33]
sorry i couldn't test anything cause i am actually on holiday.far from work and far from a pc (but not from a smartphone...)hopefully you will sort the problem.it seems you are near!


Midimaster(Posted 2013) [#34]
hi JIM

I exchanged MNET on android with Mark's new HttpRequest() on hope it will work on Android 4.

The code looks a little bit confusing, because I still need http requests on HTML5 too. So now it works on both targets. But I'm only interested in your test on Android 4.

Could you please check this test:

After starting you should see Millisecs() countdown. Touch the display. Now you should see "wait", then it should change to server's respond.

Strict
Import mojo
Import mnet
#If TARGET="android"
	Import brl.httprequest
#Endif

Class Game Extends App 
	Field Timer%, Result$, Wait%, Server:Komm
	
	Method OnCreate%()
			SetUpdateRate 15
			Timer=Millisecs()+13000
			Server=Komm.StartUp()
	
			Return 0
	End	



	Method OnUpdate%()
			If KeyHit(KEY_ESCAPE) Then Error ""
			If Wait=2
					Server.Sende("L=123456")
					Wait=3
			Endif
			
			If TouchHit(0) Then
					Result="wait..."
					Wait=1
			Endif
			UpdateAsyncEvents
			Return 0
	End	



	Method OnRender%()
			Cls 0,0,255
			SetColor 255,0,0
			Scale 2,2
			DrawText (Timer-Millisecs()),10,5
			DrawText "Touch: Test Http-Get",10,20
			DrawText " V02",10,50
			
			If Wait>0
				Wait=Wait+1
				DrawText Server.Receive(),10,35
			Endif
			If Timer<Millisecs()
				Error ""
			endif
	
			Return 0
	End	
End



Function Main%()
	New Game
	Return 0
End



Class Komm

	#If TARGET="android"
		Field SubServer:AndroidServer
	#Else
		Field  SubServer:Http
	#Endif

	Field Adresse$,Result$

	Function StartUp:Komm()
		Local loc:Komm = New Komm
		#If TARGET="android"
			loc.SubServer=New AndroidServer
		#Else
			loc.SubServer = New Http()
		#Endif	
		Return loc
	End
	
	
	Method Sende:Void(Anfrage$)
			Print "send"
			#If TARGET="android"
					Adresse="http://www.midimaster.de/temp/score.php?" ' für endversion
					SubServer.LastResponse="wait"
					SubServer.Get Adresse+Anfrage
			#Else
					Adresse="http://localhost/temp/score.php?" ' für lokales http	
					Result= SubServer.Get( Adresse + Anfrage, 3000) 
			#Endif
	End	
	
	Method Receive$()
		#If TARGET="android"
			Result= SubServer.LastResponse
			Return Result
		#Else
			Return Result				
		#Endif
	End
End



Class AndroidServer Implements IOnHttpRequestComplete

	Field Request:HttpRequest=New HttpRequest
	
	Field LastResponse$=""

	Method Get:Void(Adresse$)
		Request.Open "GET", Adresse, Self
		Request.Send
	End
	
	
	
	Method OnHttpRequestComplete:Void( req:HttpRequest )
		Print "Http GET complete!"

		Print "Status="+req.Status()
		LastResponse =req.ResponseText()
		Print "ResponseText="+req.ResponseText()
	End
End



and here is my apk for a second check:

http://www.midimaster.de/temp/TestMnetB.apk


JIM(Posted 2013) [#35]
Yup, the APK works as expected. It says "wait" then "THANK YOU"


Midimaster(Posted 2013) [#36]
thank you JIM. That are good news. Now I want to add it to the main program. Also thank you to mteo77. I hope I can contact you both again, if a new problem appears.


JIM(Posted 2013) [#37]
Well, if I happen to not stumble upon a thread around here, my email is in my profile :)


Midimaster(Posted 2013) [#38]
Ok, I did a lot of changes in my app to perhaps get it running also on Android 4.1 and 4.2. The reason for the problems is, that Android 4.x no longer seems to accept synchronous http requests. They have to be asynchron now.

Mark's new function does this! But not on HTML5 device, which I also need. So I created a network module which serves both targets...

perhaps...

The problem is: I cannot test it... I have no Android 4 device...

Could somebody please test this app on "running or not"? The test is OK, if you are able to anser the notes on the piano:

http://www.midimaster.de/temp/scoreF.apk


mteo77(Posted 2013) [#39]
it runs on my sgs2 with 4.0.4 but i cant test it with the nexus 10 cause i left it at home :P


Midimaster(Posted 2013) [#40]
Ok... 4.0! This are good news. Thank you

But 4.1 and 4.2 have been much more problematic... Perhaps somebody else can check this? This time it is very important for me...


JIM(Posted 2013) [#41]
It seems to run over here. No crash but no confirmation that there was a http request either. (4.1.1 btw)


Midimaster(Posted 2013) [#42]
Ok... 4.1! This are the next good news. Jim, did you tell me, you have the chance to test also on a 4.2 device?

There are 2 http request, when the app is starting, but it falls back to internal memory, when there is no connection. The old version already crashed here.

If you want to test a http request you can touch the settings symbol in the upper right corner and enter a teachers 6-digit code. On Return it checks, whether this account exists.


c.k.(Posted 2013) [#43]
Midimaster, I can run this on my Nexus 4 phone, which is running 4.2.2.

I entered a random teacher number and it tried to verify it. It gave me no error/warning/confirm after the test though, so I don't know if it was successful.


Midimaster(Posted 2013) [#44]
@C.K.
>"... It looks like it restarts every time the orientation changes. I get the start-up screen each time, then it connects to the server each time..."

Did forget to ask you, which of your devices your are talking about.

Can somebody else please test a orientation change problem on his 4.xx device? contact me on info@...


c.k.(Posted 2013) [#45]
Tested on Nexus 4 with 4.2.2.


Midimaster(Posted 2013) [#46]
*** solved ****

see http://www.monkeycoder.co.nz/Community/posts.php?topic=4946#54630