尝试在Android上构建/运行我的NativeScript应用时,我不断收到错误消息。我已经尝试删除平台并读取它,并删除所有node_modules并再次添加它们。 iOS版本运行得很好,只是Android版本有麻烦。
我的App.gradle:
android {
defaultConfig {
generatedDensities = []
applicationId = %my_projectname%
}
aaptOptions {
additionalParameters "--no-version-vectors"
}
dependencies {
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == 'com.android.support') {
details.useVersion '26.0.+'
}
}
}
}
}
来自我的package.json:
"nativescript": {
"id": %my_projectname%,
"tns-ios": {
"version": "3.1.0"
},
"tns-android": {
"version": "3.0.0"
}
}
错误:
14:04:01.299 [QUIET] [system.out] Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
14:04:01.301 [DEBUG] [org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter] Removed task artifact state for {} from context.
14:04:01.302 [DEBUG] [org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter] Finished executing task ':mergeF0F1F2F3DebugResources'
14:04:01.302 [LIFECYCLE] [class org.gradle.internal.buildevents.TaskExecutionLogger] :mergeF0F1F2F3DebugResources FAILED
14:04:01.302 [INFO] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] :mergeF0F1F2F3DebugResources (Thread[Daemon worker,5,main]) completed. Took 5.389 secs.
14:04:01.302 [DEBUG] [org.gradle.internal.operations.DefaultBuildOperationWorkerRegistry] Worker root.45 completed (0 in use)
14:04:01.303 [DEBUG] [org.gradle.execution.taskgraph.AbstractTaskPlanExecutor] Task worker [Thread[Daemon worker,5,main]] finished, busy: 32.075 secs, idle: 0.116 secs
14:04:01.304 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:04:01.304 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] FAILURE: Build failed with an exception.
14:04:01.304 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:04:01.304 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * What went wrong:
14:04:01.304 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] Execution failed for task ':mergeF0F1F2F3DebugResources'.
14:04:01.304 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] > Error: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException:
14:04:01.304 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:04:01.304 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] * Exception is:
14:04:01.305 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':mergeF0F1F2F3DebugResources'.
14:04:01.305 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:84)
14:04:01.305 [ERROR]
....
14:04:01.319 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.builder.png.AaptProcess$ProcessOutputFacade.out(AaptProcess.java:215)
14:04:01.319 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter] at com.android.utils.GrabProcessOutput$2.run(GrabProcessOutput.java:143)
14:04:01.319 [ERROR] [org.gradle.internal.buildevents.BuildExceptionReporter]
14:04:01.319 [LIFECYCLE] [org.gradle.internal.buildevents.BuildResultLogger]
14:04:01.319 [LIFECYCLE] [org.gradle.internal.buildevents.BuildResultLogger] BUILD FAILED
14:04:01.319 [LIFECYCLE] [org.gradle.internal.buildevents.BuildResultLogger]
14:04:01.320 [LIFECYCLE] [org.gradle.internal.buildevents.BuildResultLogger] Total time: 57.585 secs
14:04:01.333 [DEBUG] [org.gradle.cache.internal.LockOnDemandCrossProcessCacheAccess] Releasing file lock for task history cache (C:\Dev\biff\HandyApp\platforms\android\.gradle\3.3\taskArtifacts)
14:04:01.334 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache taskArtifacts.bin (C:\Dev\biff\HandyApp\platforms\android\.gradle\3.3\taskArtifacts\taskArtifacts.bin)
14:04:01.335 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache fileHashes.bin (C:\Dev\biff\HandyApp\platforms\android\.gradle\3.3\taskArtifacts\fileHashes.bin)
14:04:01.335 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache fileSnapshots.bin (C:\Dev\biff\HandyApp\platforms\android\.gradle\3.3\taskArtifacts\fileSnapshots.bin)
14:04:01.335 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on task history cache (C:\Dev\biff\HandyApp\platforms\android\.gradle\3.3\taskArtifacts).
14:04:01.336 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.CachedStoreFactory] Resolution result cache closed. Cache reads: 0, disk reads: 0 (avg: 0.0 secs, total: 0.0 secs)
14:04:01.337 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.CachedStoreFactory] Resolution result cache closed. Cache reads: 0, disk reads: 4 (avg: 0.017 secs, total: 0.071 secs)
14:04:01.337 [DEBUG] [org.gradle.api.internal.artifacts.ivyservice.resolveengine.store.ResolutionResultsStoreFactory] Deleted 2 resolution results binary files in 0.002 secs
14:04:01.337 [DEBUG] [org.gradle.cache.internal.DefaultCacheAccess] Cache Plugin Resolution Cache (C:\Users\frr\.gradle\caches\3.3\plugin-resolution) was closed 0 times.
14:04:01.338 [DEBUG] [org.gradle.process.internal.daemon.WorkerDaemonManager] Stopping 0 worker daemon(s).
14:04:01.338 [INFO] [org.gradle.process.internal.daemon.WorkerDaemonManager] Stopped 0 worker daemon(s).
14:04:01.338 [DEBUG] [org.gradle.cache.internal.DefaultCacheAccess] Cache Generated Gradle JARs cache (C:\Users\frr\.gradle\caches\3.3\generated-gradle-jars) was closed 0 times.
14:04:01.338 [DEBUG] [org.gradle.cache.internal.LockOnDemandCrossProcessCacheAccess] Releasing file lock for artifact cache (C:\Users\frr\.gradle\caches\modules-2)
14:04:01.338 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache artifact-at-repository.bin (C:\Users\frr\.gradle\caches\modules-2\metadata-2.23\artifact-at-repository.bin)
14:04:01.338 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache module-metadata.bin (C:\Users\frr\.gradle\caches\modules-2\metadata-2.23\module-metadata.bin)
14:04:01.338 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache module-artifacts.bin (C:\Users\frr\.gradle\caches\modules-2\metadata-2.23\module-artifacts.bin)
14:04:01.338 [DEBUG] [org.gradle.cache.internal.btree.BTreePersistentIndexedCache] Closing cache module-versions.bin (C:\Users\frr\.gradle\caches\modules-2\metadata-2.23\module-versions.bin)
14:04:01.338 [DEBUG] [org.gradle.cache.internal.DefaultFileLockManager] Releasing lock on artifact cache (C:\Users\frr\.gradle\caches\modules-2).
14:04:01.339 [DEBUG] [org.gradle.launcher.daemon.server.exec.ExecuteBuild] The daemon has finished executing the build.
14:04:11.602 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientInputForwarder] Dispatching close input message: org.gradle.launcher.daemon.protocol.CloseInput@2e425d92
14:04:18.343 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 14: dispatching class org.gradle.launcher.daemon.protocol.CloseInput
14:04:18.346 [INFO] [org.gradle.launcher.daemon.client.DaemonClient] Received result Failure[value=org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: Execution failed for task ':mergeF0F1F2F3DebugResources'.] from daemon DaemonInfo{pid=6744, address=[c1153b93-8604-4b5b-acb4-2dd6530b37a1 port:49887, addresses:[/127.0.0.1, /0:0:0:0:0:0:0:1]], state=Idle, lastBusy=1504872097503, context=DefaultDaemonContext[uid=5919326b-2ad7-481d-93a3-189f8cd671ee,javaHome=C:\Program Files\Java\jdk1.8.0_144,daemonRegistryDir=C:\Users\frr\.gradle\daemon,pid=6744,idleTimeout=10800000,daemonOpts=-Xmx16384M,-Dfile.encoding=windows-1252,-Duser.country=DE,-Duser.language=de,-Duser.variant]} (build should be done).
14:04:18.346 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 1: dispatching class org.gradle.launcher.daemon.protocol.Finished
14:04:18.349 [DEBUG] [org.gradle.launcher.daemon.client.DaemonClientConnection] thread 1: connection stop
Error: Command gradlew.bat failed with exit code 1
at ChildProcess.childProcess.on
更新:--------------------------------------------- -------
从我的Manifest.xml:
<uses-sdk
android:minSdkVersion="17"
android:targetSdkVersion="__APILEVEL__"/>
<application
android:name="com.tns.NativeScriptApplication"
android:allowBackup="true"
android:icon="@drawable/icon"
android:label="@string/app_name"
android:theme="@style/AppTheme"
>
我将启动画面用作splash_screen.png。
从我的styles.xml:
<style name="LaunchScreenThemeBase" parent="Theme.AppCompat.Light.NoActionBar">
<item name="toolbarStyle">@style/NativeScriptToolbarStyle</item>
<item name="colorPrimary">@color/ns_primary</item>
<item name="colorPrimaryDark">@color/ns_primaryDark</item>
<item name="colorAccent">@color/ns_accent</item>
<item name="android:windowBackground">@drawable/splash_screen</item>
<item name="android:windowNoTitle">true</item>
<item name="android:windowActionBarOverlay">true</item>
<item name="android:windowTranslucentStatus">true</item>
<item name="android:windowFullscreen">true</item>
</style>
当我交换splash_screen.png
时,错误才会发生。我插入了旧版本中使用的那个并且它工作得非常好。在我的drawable-folders
中,我证明了splash_screen.png
和icon.png
(应用图标)。当我更改icon.png
时没有问题,只是splash_screen似乎产生了问题,我无法理解为什么。
答案 0 :(得分:3)
找到了解决这个问题的方法:
gradle assemble -info给了我一个提示,即Manifest有不同的SDK版本,不能合并。
我需要编辑我的Manifest和build.gradle文件,一切都恢复了。
要清楚,您需要编辑AndroidManifest.xml中的uses-sdk
<uses-sdk android:minSdkVersion="14" android:targetSdkVersion="16" />
和android部分,特别是build.gradle文件中的minSdkVersion和targetSdkVersion
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 14
targetSdkVersion 16
}
}
请检查您是否已关闭应用程序标签。这也是导致此错误的可能原因:如果不是,请使用此:
</application>
我看过你的最新帖子。这似乎是一个命名约定问题。请重命名所有可绘制文件夹的图像,并检查所有可绘制文件夹中的图像是否为png。感谢
答案 1 :(得分:0)
我的问题是我使用了9补丁作为Android的启动屏幕,没有正确创建/格式化为一个。使用Android Studio创建一个解决了这个问题。