5

I suddenly have a problem with my flutter app. For some reason, I can't run any of my flutter files. Every time I try to run any of my flutter projects it keeps giving me an error message.

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 the -the-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)

So, I made a new flutter app to test if it was just a problem in my project. But it gave me an error again.

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)

      

How can I fix this?

2
  • Can you run it on iOS simulator? Commented Jan 18, 2019 at 3:13
  • Yes, It's fine on my iOS simulator Commented Jan 18, 2019 at 5:19

5 Answers 5

8

It seems that necessary Android 27 API's are missing in your Android sdk directory. go to ~/library/android/sdk/tools/bin and run sdkmanager --list to check if you have platform-tools and platforms;android-27 installed. If not, then you can install them by running sdkmanager "platform-tools" "platforms;android-27"

If you have Android Studio, then you can install them via Android Studio's GUI, too.

Sign up to request clarification or add additional context in comments.

4 Comments

I appreciate your help a lot. But It's not working even after I have downloaded the API.
Could you please try again after running sdkmanager "build-tools;27.0.3" as well?
In my terminal?
Yes, in your terminal and by changing to same directory with cd ~/library/android/sdk/tools/bin
1

Try running this command:

flutter pub cache repair

Comments

0

open file menu---> project structure--->project settings--->project

check your project SDK

also check >>>project structure--->platform settings--->sdks

give same SDK and click ok

try to run project

Comments

0

No need to make changes except your main.dart page code on loading new project in android studio(If you configured properly) copy paste https://www.tutorialspoint.com/flutter/flutter_creating_simple_application_in_android_studio.htm from provided url and run main.dart all problem will be solved

Comments

-1

You should leave the default splash screen because it takes time to load the program !

<?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>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.