diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugServerException.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugServerException.java
index 59f80aba4..1cf1ff387 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugServerException.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DebugServerException.java
@@ -22,24 +22,16 @@ import org.json.JSONException;
import org.json.JSONObject;
/**
+ * Tracks errors connecting to or received from the debug derver.
* The debug server returns errors as json objects. This exception represents that error.
*/
public class DebugServerException extends IOException {
-
- public final String description;
- public final String fileName;
- public final int lineNumber;
- public final int column;
-
private DebugServerException(String description, String fileName, int lineNumber, int column) {
- this.description = description;
- this.fileName = fileName;
- this.lineNumber = lineNumber;
- this.column = column;
+ super(description + "\n at " + fileName + ":" + lineNumber + ":" + column);
}
- public String toReadableMessage() {
- return description + "\n at " + fileName + ":" + lineNumber + ":" + column;
+ public DebugServerException(String description) {
+ super(description);
}
/**
diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java
index 79a71b242..d8d802320 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevServerHelper.java
@@ -13,6 +13,7 @@ import javax.annotation.Nullable;
import java.io.File;
import java.io.IOException;
+import java.net.URL;
import java.util.Locale;
import java.util.concurrent.TimeUnit;
@@ -177,7 +178,7 @@ public class DevServerHelper {
final String jsModulePath,
final File outputFile) {
final String bundleURL = createBundleURL(getDebugServerHost(), jsModulePath, getDevMode(), getHMR());
- Request request = new Request.Builder()
+ final Request request = new Request.Builder()
.url(bundleURL)
.build();
mDownloadBundleFromURLCall = Assertions.assertNotNull(mClient.newCall(request));
@@ -191,7 +192,15 @@ public class DevServerHelper {
}
mDownloadBundleFromURLCall = null;
- callback.onFailure(e);
+ StringBuilder sb = new StringBuilder();
+ sb.append("Could not connect to development server.\n\n")
+ .append("URL: ").append(request.urlString()).append("\n\n")
+ .append("Try the following to fix the issue:\n")
+ .append("\u2022 Ensure that the packager server is running\n")
+ .append("\u2022 Ensure that your device/emulator is connected to your machine and has USB debugging enabled - run 'adb devices' to see a list of connected devices\n")
+ .append("\u2022 If you're on a physical device connected to the same machine, run 'adb reverse tcp:8081 tcp:8081' to forward requests from your device\n")
+ .append("\u2022 If your device is on the same Wi-Fi network, set 'Debug server host & port for device' in 'Dev settings' to your machine's IP address and the port of the local dev server - e.g. 10.0.1.1:8081");
+ callback.onFailure(new DebugServerException(sb.toString()));
}
@Override
@@ -210,7 +219,12 @@ public class DevServerHelper {
if (debugServerException != null) {
callback.onFailure(debugServerException);
} else {
- callback.onFailure(new IOException("Unexpected response code: " + response.code()));
+ StringBuilder sb = new StringBuilder();
+ sb.append("The development server returned response error code: ").append(response.code()).append("\n\n")
+ .append("URL: ").append(request.urlString()).append("\n\n")
+ .append("Body:\n")
+ .append(body);
+ callback.onFailure(new DebugServerException(sb.toString()));
}
return;
}
diff --git a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java
index 7bdeea2d7..120443eca 100644
--- a/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java
+++ b/ReactAndroid/src/main/java/com/facebook/react/devsupport/DevSupportManagerImpl.java
@@ -633,7 +633,7 @@ public class DevSupportManagerImpl implements DevSupportManager {
public void run() {
if (cause instanceof DebugServerException) {
DebugServerException debugServerException = (DebugServerException) cause;
- showNewJavaError(debugServerException.description, cause);
+ showNewJavaError(debugServerException.getMessage(), cause);
} else {
showNewJavaError(
mApplicationContext.getString(R.string.catalyst_jsload_error),
diff --git a/ReactAndroid/src/main/res/devsupport/values/strings.xml b/ReactAndroid/src/main/res/devsupport/values/strings.xml
index 0107c3689..d56ca71d1 100644
--- a/ReactAndroid/src/main/res/devsupport/values/strings.xml
+++ b/ReactAndroid/src/main/res/devsupport/values/strings.xml
@@ -13,7 +13,7 @@
Catalyst Dev Settings
Please wait…
Fetching JS bundle
- Unable to download JS bundle from the dev server.\n\nTry the following to fix the issue:\n• Ensure that the packager server is running\n• Ensure that your device/emulator is connected to your machine and has USB debugging enabled - run \'adb devices\' to see a list of connected devices\n• If you\'re on a physical device connected to the same machine, run \'adb reverse tcp:8081 tcp:8081\' to forward requests from your device\n• If your device is on the same Wi-Fi network, set \'Debug server host & port for device\' in \'Dev settings\' to your machine\'s IP address and the port of the local dev server - e.g. 10.0.1.1:8081
+ Unable to download JS bundle. Did you forget to start the development server or connect your device?
Connecting to remote debugger
Unable to connect with remote debugger
Show Inspector