I want to build a ring topology using android emulators.
Currently my application has both client and server.
How can I run the same instance of my program on different emulators?
i.e. how to set the re directions on different emulators (redir add ?)?
Can anybody give me some pointers regarding this.
Assuming that you are running your app from Eclipse you can go to the menu "Run" > "RunConfigurations..." This will show a window with all the available configurations. Select the one from android that you want to run on different emulators and select the tab "Target".
Once in there select Manual instead of Automatic. This will prompt you where you want to deploy. You may have to create more than one AVD so you can launch more than one emulator.
It can be built by making connection to all emulators provided we redirected all the emulator port to same port.
for example :
if we want to connect 3 devices in ring passion
we have to set up one redirection to server port for each emulators
2.i.e redir add tcp 4444:8000 redir add tcp 4445:8000 redir add tcp 4446:8000 in 3 diff emulators.
2.create server on each emulator at 8000 port.
3.connect to port 8000 from all the emulators.
Related
I want to attach debugger to running android application on a physical device connected through USB.
The device is rooted using magisk. The ro.debuggable property also set to 1 using resetprop to make all apps debuggable.
For example, the app will be calculator (com.android.calculator2).
The exact steps I did:
adb kill-server
Make sure to restart the adb server.
adb devices Start the server again and make sure the device is authorized.
Run the app (calculator in my example).
adb shell ps | grep calculator Find the app ID.
u0_a88 4445 16282 4193244 133532 0 0 S com.android.calculator2
The app ID is 4445.
adb jdwp | grep 4445 Make sure the app id is in the debuggable applications list.
Output: 4445. So the app is debuggable.
adb forward tcp:7777 jdwp:4445 Forward 7777 local tcp port to jdwp.
jdb -attach localhost:7777 Connect JDB to the port.
And here is the problem. At the last step nothing happens. JDB doesn't exit nor connect, also it doesn't output anything on any input command.
I also tried Android Studio. I tried two options. Manually add configuration to connect to remote JVM and use Attach Debugger to Android Process option.
The first option (connect to remote JVM configuration) doesn't work. I used this command line flags: -agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=*:7777. Port forwarding is done the same way. Android Studio as well does not connect nor exit or print error. Just nothing.
But the Attach Debugger to Android Process option works great. It successfully connects to the app and I can debug it and set breakpoints as expected.
I also want to mention that I used am set-debug-app command before to make the app wait for the debugger to connect before start. When either jdb from command line or Android Studio remote connect to JVM option is used, the app doesn't resume, so it seems like Android doesn't see the debugger at all. But when I connect the debugger via Attach Debugger to Android Process, the app resumes after attaching the debugger as expected.
Why JDB does not attach to the app while Android Studio does via option Attach Debugger to Android Process?
What I do wrong?
This happens if you also have Android Studio running. Studio monitors all debuggable process via track-jdwp and redirect the jdwp traffic to itself to keep tabs on the app lifecycle (via DDMS).
Close Android Studio and try the same jdb command again.
I am trying to establish a connection between my client app running on my android mobile and a server running on my windows 7 PC.
I am new to android and so while looking for some client server tutorial, got the below 2 links.
http://www.compiletimeerror.com/2013/09/creating-java-web-service-using-axis-2.html
http://www.compiletimeerror.com/2013/09/accessing-web-service-from-android.html
Here, server is developed on java and published using axis2 webservice. I followed the tutorial and could develop the similar client and server which runs fine on the emulator. But if I try to access the same using my android mobile it is not working. My mobile is unable to speak to the localhost on my PC.
What I am doing here is,
1. Connected both my PC and mobile to same WIFI network.
2. Connected the mobile to PC using USB.
3. Started the Server on Tomcat
4. Running the Client Project from eclipse and selecting my mobile as target.
Below is my published webservice URL which I am calling from client code,
http://192.168.0.3:8080/MyWebService/services/WebService?wsdl
Here 192.168.0.3 is my PC IP
Please let me know what am I doing wrong here?
Windows 7 might block port 8080. You could test that your port is open from another pc using
telnet 192.168.0.3 8080
or from android using this code.
If 8080 is blocked, then you may want to open it using these steps:
Open Windows Firewall by clicking the Start button Picture of the Start button, and then clicking Control Panel. In the search box, type firewall, and then click Windows Firewall.
In the left pane, click Advanced settings. Administrator permission required If you're prompted for an administrator password or confirmation, type the password or provide confirmation.
In the Windows Firewall with Advanced Security dialog box, in the left pane, click Inbound Rules, and then, in the right pane, click New Rule.
Follow the instructions in the New Inbound Rule wizard.
Note: You must be sure beforehand that your android device is connected to the same local area network or wifi.
Try to access your URL
http://192.168.0.3:8080/MyWebService/services/WebService?wsdl
from your android browser. If you are getting an xml page, then it's not the network problem. If it's network problem, try restarting your local server and changing firewall and router configurations.
You have to provide more information to get a specific answer.
If everything is fine then u should check your Android App.
U have to add the following permission for Internet access.
<uses-permission android:name="android.permission.INTERNET"/>
I am trying to create a P2P network of android(V3.2) devices to share information like news,updates between them .
Been trying TomP2P, how ever am not able to find a solution of how to debug these . For example I would like to run two different instances either in emulator or AVD Manager and to get these messages shared in between them.
Have also tried port forwarding,how ever yet to see how to communicate between these two emulators.
Any suggestion will be much appreciated.
You need to setup port redirection as described here. Lets assume you have two emulators listening on the default port 5554 and 5556:
Since TomP2P uses UDP and TCP, you need to redirect both on both emulators:
telnet localhost 5554
redir add udp:5001:4001
redir add tcp:5001:4001
and
telnet localhost 5556
redir add udp:6001:4001
redir add tcp:6001:4001
This will redirect from your developer machine (10.0.2.2) port 6001 resp. 5001 to your Android device to port 4001. To connect from one Android device to an other Android device you have to use the IP 10.0.2.2! Further details with a working example can be found on the TomP2P documentation site.
So I wrote this jar that interacts with a database and also serves as a server. Problem is that I can only interact with that jar when I'm on the lan or run the jar from a different computer. The system with the problem is running windows xp with the firewall disabled and yes it is correctly set up with the router as I can launch a web server and view it remotely. I have no clue what the problem would be as the firewall is disabled and the jar works on other computers on the same network.
Note: I was noticing an exception "java.net.SocketException: Address family not supported by protocol family" earlier
1.Open Network Connections
2.Right-click any local area connection, and then click Properties.
3.Click Install.
4.In the Select Network Component Type dialog box, click Protocol, and then click Add.
5.In the Select Network Protocol dialog box, click Microsoft TCP/IP version 6, and then click OK
6.Click Close to save changes to your network connection.
Lastly Restart your application
See this: http://www.martinahrer.at/2009/04/16/javanetsocketexception-address-family-not-supported-by-protocol-family-bind/
Generally the problem is related to IPv6 support. Try to google your exception text and I am sure you will find an answer quickly.
My machine is running on window 7.
I want to communicate between two android emulator's running on same machine.
Emulator first is listening on some IP 10.0.2.15
When second emulator tries to create
Socket socket = new Socket ("10.0.2.15",8080);
It gives exception, unable to connect to 10.0.2.15
does any one know how to solve this problem?
EDIT: I've already read https://developer.android.com/studio/run/emulator-networking#connecting but it says
On B's console, issue redir add tcp:8080:80
What does it mean by B's console, or where is B's console??
What you need is to install TELNET on your Windows 7 machine. For that, Control Panel -> Programs and Features -> Turn Windows Features On or Off -> Telnet Client (must be ticked).
Then, in cmd (command prompt), you can say adb devices (if the Android SDK is on your PATH), which returns identifiers such as emulator-5554 and emulator-5556.
Now with telnet, you can access them with telnet localhost 5554 or telnet localhost 5556.
To get them to tell you which emulator it is, you can type avd name.
But more importantly, it tells you this:
Android Console: Authentication required
Android Console: type 'auth <auth_token>' to authenticate
Android Console: you can find your <auth_token> in
'C:\Users\[youruser]\.emulator_console_auth_token'
OK
Which is a text file that contains some random cryptic text.
You can copy paste that into the telnet like so:
auth cdPi82HewjZg
to which it will say OK, now you can actually run the command the documentation said.
Now you can say
redir add tcp:6000:4000
Which means: if the emulator would receive something to Port 6000 from LocalHost, then it should receive it as 4000
Which means your other emulator can connect to it through the 10.0.2.2 magic loopback IP by sending data to 6000, and it is the other emulator that will receive it, with port 4000.
It also works not just for tcp: but also for udp:.
You can list redir and even remove redirections with redir del.
There may be two reasons
As per my knowledge is concerned you have run is < 2.3 version
Add Internet permission
Try to run the server first say in emulator number 5554 and client (say) 5556
then type
telnet localhost 5554