失败:构建失败,抖动异常

时间:2019-01-17 22:06:09

标签: android dart flutter

我的Flutter应用突然出现问题。由于某种原因,我无法运行任何flutter文件。每次我尝试运行任何flutter项目时,都会不断显示错误消息。

FAILURE: Build failed with an exception.

* What went wrong:
Could not resolve all files for configuration ':flutter_appavailability:androidApis'.
> Failed to transform file 'android.jar' to match attributes {artifactType=android-platform-attr} using transform PlatformAttrTransform
   > java.io.FileNotFoundException: /Users/wooyoung/Library/Android/sdk/platforms/android-27/android.jar (No such file or directory)

* 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 3s
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

因此,我制作了一个新的flutter应用程序来测试它是否只是我的项目中的问题。但这又给了我一个错误。

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> Android resource linking failed
 Output:  W/ziparchive(29306): Unable to open '/Users/wooyoung/Library/Android/sdk/platforms/android-27/android.jar': No such file or directory
 error: failed to open APK: I/O error.

 Command:
/Users/wooyoung/.gradle/caches/transforms-1/files-1.1/aapt2-3.2.1-4818971-osx.jar/7624077eb86a2607fdc7dac1f332a5dd/aapt2-3.2.1-4818971-osx/aapt2 link -I\
         /Users/wooyoung/Library/Android/sdk/platforms/android-27/android.jar\
         --manifest\
         /Users/wooyoung/Flutter/FlutterProjects/Experiment/j/build/app/intermediates/merged_manifests/debug/processDebugManifest/merged/AndroidManifest.xml\
  -o\
         /Users/wooyoung/Flutter/FlutterProjects/Experiment/j/build/app/intermediates/processed_res/debug/processDebugResources/out/resources-debug.ap_\
         -R\
         @/Users/wooyoung/Flutter/FlutterProjects/Experiment/j/build/app/intermediates/incremental/processDebugResources/resources-list-for-resources-debug.ap_.txt\
         --auto-add-overlay\
         --java\
         /Users/wooyoung/Flutter/FlutterProjects/Experiment/j/build/app/generated/not_namespaced_r_class_sources/debug/processDebugResources/r\
         --custom-package\
         com.example.j\
         -0\
         apk\
         --no-version-vectors
    Daemon:  AAPT2 aapt2-3.2.1-4818971-osx Daemon #0

* 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
Gradle task assembleDebug failed with exit code 1
Exited (sigterm)

我该如何解决?

4 个答案:

答案 0 :(得分:1)

Android sdk目录中似乎缺少必要的Android 27 API。请转到~/library/android/sdk/tools/bin并运行sdkmanager --list,以检查是否已安装platform-toolsplatforms;android-27。如果没有,那么您可以通过运行sdkmanager "platform-tools" "platforms;android-27"

来安装它们

如果您拥有Android Studio,则也可以通过Android Studio的GUI安装它们。

答案 1 :(得分:0)

您应该离开默认的初始屏幕,因为加载程序需要时间!

<?xml version="1.0" encoding="utf-8"?>
<!-- Modify this file to customize your launch splash screen -->
<layer-list xmlns:android="http://schemas.android.com/apk/res/android">
   <item android:drawable="@android:color/black"/>

   <!-- You can insert your own image assets here -->
<!--     <item>
       <bitmap
           android:gravity="center"
           android:src="@mipmap/launch_image"/>
   </item> -->
</layer-list>

答案 2 :(得分:0)

打开文件菜单--->项目结构--->项目设置--->项目

检查您的项目 SDK

还要检查>>>项目结构--->平台设置--->sdks

提供相同的SDK并点击确定

尝试运行项目

答案 3 :(得分:0)

尝试运行此命令:

flutter pub cache repair