Merge pull request #270 from realm/sk-port-forward

Automatically forward port 8082 for Android
This commit is contained in:
Scott Kyle 2016-02-21 18:05:09 -08:00
commit ab94f5f314
4 changed files with 24 additions and 3 deletions

View File

@ -8,6 +8,5 @@ PATH="/opt/android-sdk-linux/platform-tools:$PATH"
npm install realm
adb reverse tcp:8081 tcp:8081
adb forward tcp:8082 tcp:8082
react-native run-android

View File

@ -8,6 +8,5 @@ PATH="/opt/android-sdk-linux/platform-tools:$PATH"
npm install realm
adb reverse tcp:8081 tcp:8081
adb forward tcp:8082 tcp:8082
react-native run-android

View File

@ -16,6 +16,24 @@ allprojects {
apply plugin: 'com.android.library'
task forwardDebugPort(type: Exec) {
commandLine 'adb', 'forward', 'tcp:8082', 'tcp:8082'
ignoreExitValue true
doLast {
if (execResult.getExitValue() != 0) {
logger.error(
'===========================================================================\n' +
'WARNING: Failed to automatically forward port 8082.\n' +
'In order to use Realm in Chrome debugging mode, port 8082 must be forwarded\n' +
'from localhost to the device or emulator being used to run the application.\n' +
'You may need to add the appropriate flags to the command that failed:\n' +
' adb forward tcp:8082 tcp:8082\n' +
'===========================================================================\n'
)
}
}
}
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
@ -24,6 +42,10 @@ android {
minSdkVersion 16
targetSdkVersion 22
}
tasks.withType(JavaCompile) {
compileTask -> compileTask.dependsOn forwardDebugPort
}
}
dependencies {

View File

@ -11,7 +11,8 @@ cp ../../src/object-store/parser/queryTests.json node_modules/realm-tests/query-
echo "Reversing port for physical device"
adb reverse tcp:8081 tcp:8081
adb forward tcp:8082 tcp:8082
react-native run-android
echo "Unlocking device"
adb shell input keyevent 82