Open Wanyor opened 4 years ago
Having the same issue. Any progress on this?
In case anyone faces this issue: the problem is that you exit main thread just after starting the server. Solution for console apps is classic - wait for user input or make an infinite loop.
public static void main(String[] args) {
System.out.println("Hellow from server");
try {
new Server();
BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
String name = reader.readLine();
} catch (IOException ioe) {
System.err.println("Couldn't start server:\n" + ioe);
}
}
I run nanohttpd on android 9.0, but show some exception.
Exception:
Exception in thread "NanoHttpd Main Listener" java.lang.InternalError: Thread starting during runtime shutdown at java.lang.Thread.nativeCreate(Native Method) at java.lang.Thread.start(Thread.java:753) at fi.iki.elonen.NanoHTTPD$DefaultAsyncRunner.exec(NanoHTTPD.java:376) at fi.iki.elonen.NanoHTTPD$ServerRunnable.run(NanoHTTPD.java:1774) at java.lang.Thread.run(Thread.java:784)
Code: ` import fi.iki.elonen.NanoHTTPD;
import java.io.IOException;
public class TestServer extends NanoHTTPD {
} `