smali icon indicating copy to clipboard operation
smali copied to clipboard

Android Studio Unable to open debugger port (localhost:8700): java.net.SocketException "Connection reset"

Open guitar9 opened this issue 6 years ago • 14 comments

Unable to open debugger port (localhost:8700): java.net.SocketException "Connection reset" I get this error when i try it with android studio? Should i paste the whole folder or just the smali folder in the project?

guitar9 avatar May 17 '18 21:05 guitar9

I'm afraid this problem has nothing to do with smalidea :). This is related to IDEA's generic java debugging functionality.

Did you open ddms/android monitor and select the process to debug?

JesusFreke avatar May 17 '18 22:05 JesusFreke

no. but i dont know what i did wrong

i did the steps like in this instruction

https://crosp.net/blog/android/android-reverse-engineering-debugging-smali-using-smalidea/

image

guitar9 avatar May 17 '18 22:05 guitar9

In order to debug a process, either the device must be debuggable (ro.debuggable=true), or the app itself must be debuggable (<application ... android:debuggable="true"> in the application's manifest)

JesusFreke avatar May 17 '18 22:05 JesusFreke

Also, If you don't have a debuggable device handy, you can use the Android emulator instead.

JesusFreke avatar May 17 '18 22:05 JesusFreke

i have a device. I think i have done something wrong at the begining. When i just import the folder without creating a new project, i have no gradle. So i am not able to run the application

image

guitar9 avatar May 17 '18 22:05 guitar9

You don't need to be able to run the application. In fact, I don't know of a way to set things up that allows you to run it from android studio, because the smalidea plugin doesn't currently support building/running applications. You have to start the process on the device yourself, and then use ddms to select that process, and then attach android studio's debugger to it

JesusFreke avatar May 17 '18 22:05 JesusFreke

yes but to start the process i have to run or debug the app? And this is what it dont undestand.

I think i will install IntelliJ IDEA on linux and try it with that. With android studio i dont get it done

guitar9 avatar May 17 '18 23:05 guitar9

Just run the app. open the app drawer and tap on the app icon, or whatever :)

JesusFreke avatar May 17 '18 23:05 JesusFreke

ok if i run the application i dont see the processess. Somebody know why? I added android:debuggable="true" to manifest

guitar9 avatar May 18 '18 15:05 guitar9

How did you add the debuggable attribute to the manifest? By disassembling and reassembling with apktool?

JesusFreke avatar May 18 '18 19:05 JesusFreke

ah that was the problem. I changed it in the folder which i imported.

So right way was

decompile with apktool build with apktool sign the apk install apk

Now i see the process but how can i debug now? When i place breakpoint it does not stop

Should i click on the the run/debug button in android studio?

guitar9 avatar May 20 '18 00:05 guitar9

I solved it. But my solution is simple, I do not know why yet.

computer reboot....

Probably because the port connected to the device does not close properly.


ADD. Later I found the exact method but I did not confirm it.

https://stackoverflow.com/questions/21766228/unable-to-open-debugger-port-java-net-socketexception-socket-closed

aqoong avatar Jan 16 '19 10:01 aqoong

I had to change the debug port to 8600, but you can Run -> Attach Debugger to Android Process instead of using a "Remote debug configuration".

maiermic avatar Aug 21 '19 21:08 maiermic

I had to change the debug port to 8600, but you can Run -> Attach Debugger to Android Process instead of using a "Remote debug configuration".

It works well for me.

tanliner avatar Nov 18 '20 16:11 tanliner