简体   繁体   中英

Test drive on flutter: android.jar file not found

I'm just trying to run the first app and this is what happens:

FAILURE: Build failed with an exception.

  • What went wrong: A problem was found with the configuration of task ':app:processDebugResources'.

    File 'C:\Users\XXXX\Appdata\Local\Android\sdk\platforms\android-28\android.jar' specified for property 'androidJar' does not exist.

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

The file is on the android-29 folder? what should I do?

Image Please update your android sdk.

You don't have install api 28. Please open your android sdk and install android sdk 28.

This error might occur because of android.jar is in another folder

Try opening

C:\\Users\\XXXX\\Appdata\\Local\\Android\\sdk\\platforms

and then look for a folder named android-29 or android-27 and you should be able to find android.jar in that folder just copy that file and paste it into to android-28

It worked for me too to fix the specified for property 'androidJarInput.androidJar' does not exist.

I Copied the android.jar from android-32 into android-31

Not only android.jar is missing from my android-xx folder, then copy android.jar from other folder could solve this problem but I still have another problems when combine.
So I do a workaround

  • First, I delete this android-xx folder from Android\sdk\platforms
  • Then, I create a new empty project
  • Next, inside app\build.gradle of new project, I set both compileSdk and targetSdk to xx
  • Sync and run new project
  • Finally, android-xx will contains all the files

I dont know if delete the old android-xx before create new project is required or not. but I deleted it to make sure their is no other problem when replacing file

For some reason, android.jar is't automatically downloaded or built when installing specific Android SDK versions. This oversight means Flutter cannot find the android.jar , since it doesn't exist.

One solution, after installing the SDK version, is to manually download the android.jar for your desired SDK version from the following GitHub repository:

https://github.com/Sable/android-platforms

Make sure to put the android.jar file in the correct location, replacing XX with your version number:

Windows

C:\Users\XXXX\Appdata\Local\Android\sdk\platforms\android-XX\android.jar

OS X

Users/<username>/Library/Android/sdk/platforms/android-XX/android.jar

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM