Snivio
Snivio

Reputation: 1864

Flutter failed for task app:mergeDebugNativeLibs and app:mergeDebugJavaResource

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > File 'com.android.builder.files.ZipCentralDirectory@6f58452a' was deleted, but previous version not found in cache

* 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.
==============================================================================

2: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:mergeDebugJavaResource'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > File 'com.android.builder.files.ZipCentralDirectory@48b70346' was deleted, but previous version not found in cache

* 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 23s
Running Gradle task 'assembleDebug'...
Running Gradle task 'assembleDebug'... Done                        23.9s
Exception: Gradle task assembleDebug failed with exit code 1

Upvotes: 8

Views: 17977

Answers (11)

Mauro Soto
Mauro Soto

Reputation: 21

For this issue, I followed the steps above,

Invalidate Caches/Restart, I restarted and then error:

Flutter failed to delete a directory at "build\flutter_assets". The flutter tool cannot access the file or directory. Please ensure that the SDK and/or project is installed in a location that has read/write permissions for the current user.

Appeared, but just deleted the build I run "flutter run" on terminal and it worked.

Upvotes: 1

Mustafa Tameemi
Mustafa Tameemi

Reputation: 1176

Let's make it easier:-

Please take this as a rule: Never edit your gradles and build files manually especially when you're working on cross-platform development.

You can solve this issue by:-

Step 1:-

enter image description here

Step 2:-

enter image description here

Step 3:-

enter image description here

That's it. fingers crossed.

Upvotes: 3

ALNAJJAR
ALNAJJAR

Reputation: 483

android {  

    packagingOptions {
        pickFirst 'lib/x86/libc++_shared.so'
        pickFirst 'lib/x86_64/libc++_shared.so'
        pickFirst 'lib/armeabi-v7a/libc++_shared.so'
        pickFirst 'lib/arm64-v8a/libc++_shared.so'
    }
}

Add this in :

android/app --> build.gradle

Upvotes: 0

sudesh bandara
sudesh bandara

Reputation: 61

In my case it was enough to exclude only path 'META-INF/DEPENDENCIES' on android/app/build.gradle

android {
  ......
  defaultConfig
  {
   ......
   multiDexEnabled true
  }
  packagingOptions 
  {
    exclude 'META-INF/DEPENDENCIES'
    exclude("META-INF/*") 
  }
 dependencies {
  .......
  implementation 'com.android.support:multidex:2.0.1' 
 }          
}
AndroidManifest.xml
<application
    .......
    android:name="androidx.multidex.MultiDexApplication" >

Now

  • run flutter clean
  • run flutter get

It's worked for me.

Upvotes: 2

Jakob E. Bardram
Jakob E. Bardram

Reputation: 83

As far as I can see, this happens when the build cache gets out of sync. To fix:

  • run flutter clean
  • delete the build folder
  • run flutter get

If this doesn't do the trick, try running flutter pub cache clean before the steps above.

Upvotes: 0

SSolheim
SSolheim

Reputation: 85

I had a similar issue.

I had to go into my project folder and I renamed the "build" folder to "build.old" and the ".dart_tool" to ".dart_tool.old".

I was then able to run the command "flutter clean" from a command prompt at the root of my project folder.

Upvotes: 0

Yuri
Yuri

Reputation: 277

  1. Open your terminal
  2. Go to your project directory
  3. Type the commands flutter clean then flutter run

Upvotes: 0

Devyank Shaw
Devyank Shaw

Reputation: 189

Try any one of the following steps:

  1. Goto Files > Click Invalidate Caches/Restart

  2. Restart your machine

  3. On terminal write flutter clean and then flutter run

Upvotes: 16

I had the same issue after setting up my flutter project to run on iOS. When I tried to run it back on Android, this error was thrown.

This worked for me (on Windows):

  1. Close your project and close your code editor

  2. Open Task Manager

  3. Finish all vscode-related tasks you see (or related to the IDE you are using)

  4. Finish all Java-related tasks, inclidung OpenJDK Platform binary (there are usually two of these; finish both)

  5. Go to your project's root folder and delete the build folder

  6. Open your project again and run

Good luck!

Upvotes: 5

Javad.rajabi
Javad.rajabi

Reputation: 217

The problem is one of the plugins.Usually related to contacts. Flutter has a problem with this package. If you are using the latest version, try the previous versions

Upvotes: 0

Hakeem Al-Fareed
Hakeem Al-Fareed

Reputation: 21

It happened to me before i solved it by the following steps:

1- Updating the program
2- Updating flutter
3- Copying the files from old project to a new one

Upvotes: 0

Related Questions