我试图使用nativescript cli使用tns run android
命令在我的物理设备和android模拟上运行我的应用程序。
当我这样做时,我得到下面的错误。
我刚刚尝试将我的应用文件添加到新的“测试”应用中,以查看是否可以解决问题。
我在github上阅读了许多与我的问题不匹配的类似问题,因此没有提供解决方案。 我还尝试在两台不同的Windows 10计算机上运行此程序。
显示错误
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>
我希望该应用能够正确安装,然后才能在设备上运行。
答案 0 :(得分:0)
事实证明,这是我尝试在我的应用中实现Multidex支持的方式。
根据针对multidex的Android说明,您需要在“
但是NativeScript不支持此更改,这导致了此套接字超时问题。