我正在尝试使用 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>
我希望该应用程序能够正确安装,然后该应用程序可以在设备上运行。