Problems with compilation in Android
Monkey Targets Forums/Android/Problems with compilation in Android
| ||
Is there a reason i am getting thoses errors while trying to compile with the Android target.. ? Ive just tried to extend the object instance.Class WsockTesting Extends Wsock Field state:String Method Render:Void() DrawText(state, 0, 0) End Method OnConnecting:Void() #If TARGET = "html5" Or TARGET = "android" Print("Connecting...") #ElseIf TARGET = "xna" state = "Connecting..." #End End Method OnDataReceived:Void(data:String) #If TARGET = "html5" Or TARGET = "android" Print("Received: " + data) #ElseIf TARGET = "xna" state = "Received: " + data #End End Method OnDisconnect:Void(code:String, reason:String, cleanClose:Bool) #If TARGET = "html5" Or TARGET = "android" Print("You have been disconnected: Code[" + code + "] Reason[" + reason + "]") #ElseIf TARGET = "xna" state = "You have been disconnected: Code[" + code + "] Reason[" + reason + "]" #End End Method OnError:Void(error:String) #If TARGET = "html5" Or TARGET = "android" Print("An error occured: " + error) #ElseIf TARGET = "xna" state = "An error occured: " + error #End End End -compile: [javac] Compiling 3 source files to G:\Programmes\MonkeyPro65\modules\wsock\wsock_demo.build\android\bin\classes [javac] G:\Programmes\MonkeyPro65\modules\wsock\wsock_demo.build\android\src\com\monkey\MonkeyGame.java:2798: error: cannot find symbol [javac] class bb__WsockTesting extends Wsock{ [javac] ^ [javac] symbol: class Wsock [javac] G:\Programmes\MonkeyPro65\modules\wsock\wsock_demo.build\android\src\com\monkey\MonkeyGame.java:2430: error: cannot find symbol [javac] f_ws.Connect("ws://192.168.1.100:8880/"); [javac] ^ [javac] symbol: method Connect(String) BUILD FAILED G:\Programmes\AndroidSDKTools\tools\ant\build.xml:679: The following error occurred while executing this line: G:\Programmes\AndroidSDKTools\tools\ant\build.xml:692: Compile failed; see the compiler error output for details. Total time: 1 second [javac] location: variable f_ws of type bb__WsockTesting [javac] G:\Programmes\MonkeyPro65\modules\wsock\wsock_demo.build\android\src\com\monkey\MonkeyGame.java:2441: error: cannot find symbol [javac] if(f_ws.IsConnected() && f_test==0){ [javac] ^ [javac] symbol: method IsConnected() [javac] location: variable f_ws of type bb__WsockTesting [javac] G:\Programmes\MonkeyPro65\modules\wsock\wsock_demo.build\android\src\com\monkey\MonkeyGame.java:2443: error: cannot find symbol [javac] f_ws.Send("TC abc\u00e9"); [javac] ^ [javac] symbol: method Send(String) [javac] location: variable f_ws of type bb__WsockTesting [javac] Note: G:\Programmes\MonkeyPro65\modules\wsock\wsock_demo.build\android\src\com\monkey\MonkeyGame.java uses unchecked or unsafe operations. [javac] Note: Recompile with -Xlint:unchecked for details. [javac] 4 errors Class Wsock = "Wsock" Method Connect:Bool(url:String) Method Disconnect:Void(reason:String) Method GetReadyState:Int() Method Send:Void(message:String) Method IsConnected:Bool() Method OnConnecting:Void() Method OnDataReceived:Void(data:String) Method OnDisconnect:Void(code:String, reason:String, cleanClose:Bool) Method OnError:Void(error:String) End Class |
| ||
It seem that extending a class with the Android target is not supported. Can someone confirm ? Also i think ive found a bug with Trans which uppercase the second letter of the class while the reference to it is lowercase which make a build error. |
| ||
Ive been able to build it.. but i am getting on Android Monkey Runtime Error : Can't create handler inside thread that has not called Looper.prepare(). It seem to be related to .. ws = New WsockTesting() which refer to the extended class.. Class WsockTesting Extends Wsock app.monkey in Mojo Method OnCreate() SetFont Null Return app.OnCreate() End |
| ||
Finally got it to work !! =D Found a way to execute handler threads like this ... which fix the error and everything work !public final boolean Connect(final String url) { MonkeyGame.activity.runOnUiThread(new Runnable() { public void run() { _connection = new WebSocketConnection(); try { _connection.connect(url, new WebSocketConnectionHandler() { @Override public void onOpen() { OnConnecting(); _readyState = 1; } @Override public void onTextMessage(String payload) { OnDataReceived(payload); } @Override public void onClose(int code, String reason) { OnDisconnect(Integer.toString(code), reason, true); _readyState = 3; } }); } catch (WebSocketException e) { OnError(e.toString()); } } }); return true; } Ive finally finished the WebSockets client module proof of concept targetting XNA (Windows), Android and HTML 5 which is a success ! Now i will polish it. |