由于套接字超时错误,应用程序将无法安装在物理智能手机或模拟器上
App will not install on physical smartphone or on emulator due to socket timeout error
我正在尝试使用 nativescript cli 运行 我的物理设备上的应用程序以及使用 tns run android
命令的 android 模拟。
当我这样做时,出现以下错误。
我刚刚尝试将我的应用程序文件添加到新的 'test' 应用程序中,看看是否能解决问题。
我在github上看了很多类似的问题,但与我的问题不符,所以没有提供解决方案。
我也在两台不同的 windows 10 台计算机上尝试 运行ning 这个。
显示错误
Installing on device ce04171461a2d0fc0d...
Successfully installed on device with identifier 'ce04171461a2d0fc0d'.
Unable to apply changes on device: ce04171461a2d0fc0d. Error is: Socket connection timed out..
我的 package.json 文件如下:
{
"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"
}
这是我的 app.gradle 文件以允许 multidex 支持
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'
}
}
这是我的 build.gradle 代码
// 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
}
这是我的 androidmanifest.xml 文件
<?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>
我希望该应用能够正确安装,然后该应用会 运行 在设备上。
事实证明这是我尝试在我的应用程序中实现 multidex 支持的方式的问题。
根据 multidex 的 Android 说明,您需要更改“
但是 NativeScript 不支持此更改,这导致了此套接字超时问题。
我正在尝试使用 nativescript cli 运行 我的物理设备上的应用程序以及使用 tns run android
命令的 android 模拟。
当我这样做时,出现以下错误。
我刚刚尝试将我的应用程序文件添加到新的 'test' 应用程序中,看看是否能解决问题。
我在github上看了很多类似的问题,但与我的问题不符,所以没有提供解决方案。 我也在两台不同的 windows 10 台计算机上尝试 运行ning 这个。
显示错误
Installing on device ce04171461a2d0fc0d...
Successfully installed on device with identifier 'ce04171461a2d0fc0d'.
Unable to apply changes on device: ce04171461a2d0fc0d. Error is: Socket connection timed out..
我的 package.json 文件如下:
{
"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"
}
这是我的 app.gradle 文件以允许 multidex 支持
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'
}
}
这是我的 build.gradle 代码
// 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
}
这是我的 androidmanifest.xml 文件
<?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>
我希望该应用能够正确安装,然后该应用会 运行 在设备上。
事实证明这是我尝试在我的应用程序中实现 multidex 支持的方式的问题。
根据 multidex 的 Android 说明,您需要更改“
但是 NativeScript 不支持此更改,这导致了此套接字超时问题。