GvSharma
GvSharma

Reputation: 2670

How to change the default port number in android studio while running backend code?

i need help, currently am going to develop an android app, and am using cloud tools(google app engine) using android studio.I have setup the environment correctly and when i run my backend code..the following error showing.

/usr/lib/jvm/java-1.7.0-openjdk-i386/bin/java -javaagent:/home/sharma/.gradle/appengine-sdk/appengine-java-sdk-1.9.14/lib/agent/appengine-agent.jar -Xbootclasspath/p:/home/sharma/.gradle/appengine-sdk/appengine-java-sdk-1.9.14/lib/override/appengine-dev-jdk-overrides.jar -Didea.launcher.port=7532 -Didea.launcher.bin.path=/home/sharma/Desktop/android-studio/bin -Dfile.encoding=UTF-8 -classpath /home/sharma/.gradle/appengine-sdk/appengine-java-sdk-1.9.14/lib/appengine-tools-api.jar:/home/sharma/Desktop/android-studio/lib/idea_rt.jar com.intellij.rt.execution.application.AppMain com.google.appengine.tools.development.DevAppServerMain --address=localhost --port=8080 /home/sharma/AndroidstudioProjects/SampleApp7/ServierSide/build/exploded-app

Feb 06, 2015 6:17:30 PM com.google.apphosting.utils.config.AppEngineWebXmlReader readAppEngineWebXml INFO: Successfully processed /home/sharma/AndroidstudioProjects/SampleApp7/ServierSide/build/exploded-app/WEB-INF/appengine-web.xml Feb 06, 2015 6:17:30 PM com.google.apphosting.utils.config.AbstractConfigXmlReader readConfigXml

INFO: Successfully processed /home/sharma/AndroidstudioProjects/SampleApp7/ServierSide/build/exploded-app/WEB-INF/web.xml Feb 06, 2015 6:17:30 PM com.google.appengine.tools.development.SystemPropertiesManager setSystemProperties

INFO: Overwriting system property key 'java.util.logging.config.file', value '/home/sharma/.gradle/appengine-sdk/appengine-java-sdk-1.9.14/config/sdk/logging.properties' with value 'WEB-INF/logging.properties' from '/home/sharma/AndroidstudioProjects/SampleApp7/ServierSide/build/exploded-app/WEB-INF/appengine-web.xml'


Could not open the requested socket: Address already in use Try overriding --address and/or --port.

I understand that, port number i should change, but i don't know much about android studio. So please guide me about.

Upvotes: 1

Views: 13630

Answers (3)

Godinho
Godinho

Reputation: 1

I faced the same issue: no matter where I configure port number (build.gradle, command line and so on), my development server was always running in a random port. After some investigation, I discovered that it happens when I configure my app to use manual scaling.

After removing the following tag from my appengine-web.xml file, my server started to run on port I configure in build.gradle.

  <manual-scaling>
    <instances>1</instances>
  </manual-scaling>

And adding this to my build.gradle:

appengine {
    httpPort = 8081
}

More info about how manual-scaling affect developer server ports can be found here: https://cloud.google.com/appengine/docs/python/how-requests-are-routed (section Routing in the development server)

Upvotes: 0

nurp
nurp

Reputation: 1275

"Edit Configurations" is under Android Studio's Run menu.

There is also a setting under the server's iml file, such as backend.iml.

But they both didn't work for me, instead this worked: Change your build.gradle file under the backend project so that it has httpPort parameter

Appengine {
    downloadSdk = true
    httpPort = 8085
    appcfg {
        oauth2 = true
    }
....

Upvotes: 3

wlm
wlm

Reputation: 29

You can change the port using the "Edit Configurations..." UI. There is a "Server Port" field. The default value is 8080.

Upvotes: 1

Related Questions