I am trying to use the nativescript cli to run my app on my physical device and on an android simulation using the tns run android
command.
When I do this i get the error below.
I've just tried adding my app files into a new 'test' app to see if that will solve the problem.
I have read a number of similar issues on github that did not match my problem and so did not provide a solution. I have also tried running this on two different windows 10 computers.
Error shown
Installing on device ce04171461a2d0fc0d...
Successfully installed on device with identifier 'ce04171461a2d0fc0d'.
Unable to apply changes on device: ce04171461a2d0fc0d. Error is: Socket connection timed out..
My package.json file is below:
{
"nativescript": {
"id": "org.nativescript.PrototypeAssetSurveyAppDrawer",
"tns-android": {
"version": "6.0.0"
},
"tns-ios": {
"version": "6.0.1"
}
},
"description": "NativeScript Application",
"license": "SEE LICENSE IN <your-license-filename>",
"repository": "<fill-your-repository-here>",
"scripts": {
"lint": "tslint \"src/**/*.ts\""
},
"dependencies": {
"@angular/animations": "~8.0.0",
"@angular/common": "~8.0.0",
"@angular/compiler": "~8.0.0",
"@angular/core": "~8.0.0",
"@angular/forms": "~8.0.0",
"@angular/http": "~8.0.0-beta.10",
"@angular/platform-browser": "~8.0.0",
"@angular/platform-browser-dynamic": "~8.0.0",
"@angular/router": "~8.0.0",
"email-validator": "2.0.4",
"nativescript": "^6.0.3",
"nativescript-angular": "~8.0.0",
"nativescript-plugin-firebase": "^9.1.0",
"nativescript-theme-core": "~1.0.6",
"nativescript-ui-listview": "7.0.2",
"nativescript-ui-sidedrawer": "~7.0.0",
"reflect-metadata": "~0.1.12",
"rxjs": "~6.5.0",
"tns-core-modules": "~6.0.0",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular/compiler-cli": "~8.0.0",
"@ngtools/webpack": "~8.0.0",
"codelyzer": "~4.5.0",
"nativescript-dev-webpack": "~1.0.0",
"node-sass": "^4.7.1",
"tslint": "~5.11.0",
"typescript": "~3.4.0"
},
"gitHead": "f28dbc60d74dd2cef4b645afd8fdd63bbb12c73e",
"readme": "NativeScript Application"
}
Here is my app.gradle file to allow multidex support
def settingsGradlePath
if(project.hasProperty("appResourcesPath")){
settingsGradlePath = "$project.appResourcesPath/Android/settings.gradle";
} else {
settingsGradlePath = "$rootDir/../../app/App_Resources/Android/settings.gradle";
}
def settingsGradleFile = new File(settingsGradlePath);
if(settingsGradleFile.exists())
{
apply from: settingsGradleFile;
}
android {
defaultConfig {
minSdkVersion 17
generatedDensities = []
multiDexEnabled = true
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
}
Here is my build.gradle code
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
maven { url "https://maven.fabric.io/public" }
maven { url "https://dl.bintray.com/android/android-tools" }
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.1'
classpath "com.google.gms:google-services:4.3.0"
classpath "io.fabric.tools:gradle:1.26.1"
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is my androidmanifest.xml file
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="org.nativescript.PrototypeAssetSurveyAppDrawer"
android:versionCode="10000"
android:versionName="1.0">
<supports-screens
android:smallScreens="true"
android:normalScreens="true"
android:largeScreens="true"
android:xlargeScreens="true"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme">
<activity
android:name="com.tns.NativeScriptActivity"
android:label="@string/title_activity_kimera"
android:configChanges="keyboard|keyboardHidden|orientation|screenSize|smallestScreenSize|screenLayout|locale|uiMode"
android:theme="@style/LaunchScreenTheme">
<meta-data android:name="SET_THEME_ON_LAUNCH" android:resource="@style/AppTheme" />
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity android:name="com.tns.ErrorReportActivity"/>
</application>
</manifest>
I expected the app to be installed correctly and for the app to then run on the device.
This turned out to be an issue with how I tried to implement multidex support in my app.
According to the Android instructions for multidex you need to change the "android:name" field in the "
However NativeScript does not support this change and that was causing this socket timeout problem.