Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (499)
Games in Android Showcase (118)
games submitted by our members
Games in WIP (567)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1]
  ignore  |  Print  
  [KROYONET] Android 4.2 doesn't connect, 2.2 do  (Read 1639 times)
0 Members and 1 Guest are viewing this topic.
Offline cronosDev

Senior Newbie





« Posted 2013-04-24 17:06:57 »

Hello Community,

at the moment i'm writing a mulitplayer app for Android. For this i use Kroyonet. At least i wrote the server application (a simple Java programm running on my PC) and the Android app as the client part. When i try to connect my Nexus 4 (Android 4.2.2) with the server the application crash but if i run the app on a VM (Android 2.2) the  client connect to the server. Have someone an idea how to fix this problem?

Thanks
Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #1 - Posted 2013-04-24 18:50:44 »

Since it only works on a VM is the nexus 4 on the same network? Is the ip addressing correct?

Offline cronosDev

Senior Newbie





« Reply #2 - Posted 2013-04-24 20:05:00 »

A VM with 4.2.2 also doesnt work, so i think the nexus is okay. All devices are in the same Network.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #3 - Posted 2013-04-24 20:07:01 »

is 4.2 above your android supported version? I think this is defined in the android manifest.xml

Offline cronosDev

Senior Newbie





« Reply #4 - Posted 2013-04-25 11:22:03 »

The supported Version ist 4.2.2, so the highst i can choose. Any other idea?
Offline wreed12345

JGO Knight


Medals: 24
Projects: 2
Exp: 2 years


http://linebylinecoding.blogspot.com/


« Reply #5 - Posted 2013-04-25 20:29:09 »

Maybe you could share your project and I'll take a look

Offline cronosDev

Senior Newbie





« Reply #6 - Posted 2013-04-27 14:01:59 »

How can i share it?

I can show you the erro that i get with a 4.2.2 client:

1  
2  
3  
4  
5  
6  
7  
8  
9  
10  
11  
12  
13  
14  
15  
16  
17  
18  
19  
20  
21  
22  
23  
24  
25  
26  
27  
28  
29  
30  
31  
04-27 15:57:10.851: E/AndroidRuntime(11936): FATAL EXCEPTION: main
04-27 15:57:10.851: E/AndroidRuntime(11936): java.lang.RuntimeException: Unable to start activity ComponentInfo{conros.dev.spacerush/cronos.dev.spacerush.SpaceRushStart}: android.os.NetworkOnMainThreadException
04-27 15:57:10.851: E/AndroidRuntime(11936):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2180)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2230)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at android.app.ActivityThread.access$600(ActivityThread.java:141)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1234)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at android.os.Handler.dispatchMessage(Handler.java:99)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at android.os.Looper.loop(Looper.java:137)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at android.app.ActivityThread.main(ActivityThread.java:5041)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at java.lang.reflect.Method.invokeNative(Native Method)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at java.lang.reflect.Method.invoke(Method.java:511)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:793)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:560)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at dalvik.system.NativeStart.main(Native Method)
04-27 15:57:10.851: E/AndroidRuntime(11936): Caused by: android.os.NetworkOnMainThreadException
04-27 15:57:10.851: E/AndroidRuntime(11936):    at android.os.StrictMode$AndroidBlockGuardPolicy.onNetwork(StrictMode.java:1117)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at libcore.io.BlockGuardOs.connect(BlockGuardOs.java:84)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at libcore.io.IoBridge.connectErrno(IoBridge.java:144)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at libcore.io.IoBridge.connect(IoBridge.java:112)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:192)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at java.net.PlainSocketImpl.connect(PlainSocketImpl.java:459)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at java.net.Socket.connect(Socket.java:842)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at java.nio.SocketChannelImpl$SocketAdapter.connect(SocketChannelImpl.java:521)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at com.esotericsoftware.kryonet.TcpConnection.connect(TcpConnection.java:77)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at com.esotericsoftware.kryonet.Client.connect(Client.java:147)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at com.esotericsoftware.kryonet.Client.connect(Client.java:108)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at cronos.dev.spacerush.SpaceRushStart.onCreate(SpaceRushStart.java:87)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at android.app.Activity.performCreate(Activity.java:5104)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1080)
04-27 15:57:10.851: E/AndroidRuntime(11936):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2144)
04-27 15:57:10.851: E/AndroidRuntime(11936):    ... 11 more


My 2.2 Client run without this erros. Pls Help
Offline nexsoftware

Junior Member


Medals: 9



« Reply #7 - Posted 2013-04-27 14:59:21 »

The stack trace indicates you are running the connect operation on the main thread. You'll need to put that into a background thread so as to not lock up your UI during connect. This is due to StrictMode, added in Android 2.3 but on by default since 3.0. Alternatively, if you really need the connect operation to be on the main thread, then you change the StrictMode policy.
Offline cronosDev

Senior Newbie





« Reply #8 - Posted 2013-04-27 15:21:03 »

Ohh okay thanks. Is it right that when i but the connection into a background Thread, i can switch between activitys and the connection also hold the line?
Offline nexsoftware

Junior Member


Medals: 9



« Reply #9 - Posted 2013-04-27 17:03:59 »

The connect thread will only exist as long as the connection is being established. Kryonet maintains its own update thread. As long as your Client is maintained outside of the scope of any specific Activity, there should not be any problem using it from any Activity.
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline cronosDev

Senior Newbie





« Reply #10 - Posted 2013-04-28 14:48:20 »

Okay, i swap the client creation, addListener and client start in a background thread. But now when i start the client it connect with the server, the server sends a TCP frame and then the client disconnect. Do you have any idea?
Pages: [1]
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Pippogeek (38 views)
2014-09-24 16:13:29

Pippogeek (29 views)
2014-09-24 16:12:22

Pippogeek (18 views)
2014-09-24 16:12:06

Grunnt (42 views)
2014-09-23 14:38:19

radar3301 (24 views)
2014-09-21 23:33:17

BurntPizza (61 views)
2014-09-21 02:42:18

BurntPizza (31 views)
2014-09-21 01:30:30

moogie (36 views)
2014-09-21 00:26:15

UprightPath (49 views)
2014-09-20 20:14:06

BurntPizza (53 views)
2014-09-19 03:14:18
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!