我昨天开始了有关NativeScript的课程,并且刚刚完成了所有内容的安装(本地脚本,打字稿,android studio,android sdk,android模拟器)。
我创建了一个空项目并运行
tns build android --bundle
(也尝试了不使用--bundle
标志,但也没有起作用)
我在建筑物的50%处出现错误,经过数小时的研究,我找不到解决方案。
这是输出:
Copying template files...
Platform android successfully added. v5.3.1
Hook skipped because either bundling or livesync is in progress.
Preparing project...
Running webpack for android...
clean-webpack-plugin: /home/user/Desktop/coding/project-name/platforms/android/app/src/main/assets/app/**/* has been removed.
Hash: 3e08d144c4208c0b1de0
Version: webpack 4.23.1
Time: 13040ms
Built at: 04/08/2019 9:18:05 PM
Asset Size Chunks Chunk Names
App_Resources/Android/AndroidManifest.xml 1.36 KiB [emitted]
App_Resources/Android/app.gradle 486 bytes [emitted]
App_Resources/Android/drawable-hdpi/background.png 3.42 KiB [emitted]
App_Resources/Android/drawable-hdpi/icon.png 6.8 KiB [emitted]
App_Resources/Android/drawable-hdpi/logo.png 32.4 KiB [emitted]
App_Resources/Android/drawable-ldpi/background.png 1.31 KiB [emitted]
App_Resources/Android/drawable-ldpi/icon.png 3.23 KiB [emitted]
App_Resources/Android/drawable-ldpi/logo.png 9.95 KiB [emitted]
App_Resources/Android/drawable-mdpi/background.png 1.89 KiB [emitted]
App_Resources/Android/drawable-mdpi/icon.png 3.42 KiB [emitted]
App_Resources/Android/drawable-mdpi/logo.png 15.8 KiB [emitted]
App_Resources/Android/drawable-nodpi/splash_screen.xml 304 bytes [emitted]
App_Resources/Android/drawable-xhdpi/background.png 5.26 KiB [emitted]
App_Resources/Android/drawable-xhdpi/icon.png 10.4 KiB [emitted]
App_Resources/Android/drawable-xhdpi/logo.png 54 KiB [emitted]
App_Resources/Android/drawable-xxhdpi/background.png 10.3 KiB [emitted]
App_Resources/Android/drawable-xxhdpi/icon.png 20.3 KiB [emitted]
App_Resources/Android/drawable-xxhdpi/logo.png 116 KiB [emitted]
App_Resources/Android/drawable-xxxhdpi/background.png 3.87 KiB [emitted]
App_Resources/Android/drawable-xxxhdpi/icon.png 73.8 KiB [emitted] App_Resources/Android/drawable-xxxhdpi/logo.png 193 KiB [emitted]
App_Resources/Android/values-v21/colors.xml 104 bytes [emitted]
App_Resources/Android/values-v21/styles.xml 902 bytes [emitted]
App_Resources/Android/values/colors.xml 237 bytes [emitted]
App_Resources/Android/values/styles.xml 1.68 KiB [emitted]
bundle.js 18.9 KiB bundle [emitted] bundle
package.json 134 bytes [emitted]
starter.js 39 bytes [emitted]
tns-java-classes.js 0 bytes [emitted]
vendor.js 4.99 MiB vendor [emitted] vendor
Entrypoint bundle = vendor.js bundle.js
[../$$_lazy_route_resource lazy recursive] ../$$_lazy_route_resource lazy namespace object 160 bytes {bundle} [built]
[./app.css] 452 bytes {bundle} [built]
[./app/app-routing.module.ts] 1.06 KiB {bundle} [built]
[./app/app.component.css] 19 bytes {bundle} [built]
[./app/app.component.html] 64 bytes {bundle} [built]
[./app/app.component.ts] 982 bytes {bundle} [built]
[./app/app.module.ts] 1.67 KiB {bundle} [built]
[./app/app.routes.ts] 236 bytes {bundle} [built]
[./app/home/home.component.css] 19 bytes {bundle} [built]
[./app/home/home.component.html] 273 bytes {bundle} [built]
[./app/home/home.component.ts] 1.28 KiB {bundle} [built]
[./main.ts] 1.95 KiB {bundle} [built]
[./package.json] 121 bytes {bundle} [optional] [built]
+ 404 hidden modules
Webpack compilation complete.
Project successfully prepared (android)
Building project...
Gradle build...
+ setting applicationId
+ applying user-defined configuration from /home/user/Desktop/coding/project-name/App_Resources/Android/app.
gradle
+ using support library version 28.0.0
+ adding nativescript runtime package dependency: nativescript-optimized-with-inspector
+ adding aar plugin dependency: /home/user/Desktop/coding/project-name/node_modules/tns-core-modules-widgets/platforms/android/widgets-release.aar
FAILURE: Build failed with an exception.
* Where:
Build file '/home/user/Desktop/coding/project-name/platforms/android/app/build.gradle' line: 505
* What went wrong:
A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:debugRuntimeClasspath'.
> Could not load module metadata from /home/user/.gradle/caches/modules-2/metadata-2.63/descriptors/com.android.support/transition/28.0.0/6740fe48b44caed96d7f50b66ff7b0b5/descriptor.bin
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
* Get more help at https://help.gradle.org
BUILD FAILED in 2s
Command ./gradlew failed with exit code 1
有什么想法吗?
答案 0 :(得分:0)
最后,我使用Android Stuio解决了该问题。
File -> Invalidate caches / Restart
.gradle
文件夹,该文件夹在Ubuntu中位于主目录中然后,我成功地构建了NativeScript项目。