Judy
Judy

Reputation: 434

React-Native Build Failed app:mergeDebugAssets

I completed a react-native app for Android, and now when I try to

run npm android, I get this error:

 FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:mergeDebugAssets'.
> Error: java.lang.RuntimeException: java.lang.RuntimeException: java.nio.file.AccessDeniedException:
C:\Users\SONY\AwesomeProject\android\app\build\intermediates\merged_assets\debug\mergeDebugAssets\out\fonts

Please can you help me?

Many Thanks

React-native

Caused by: java.nio.file.AccessDeniedException: C:\Users\SONY\AwesomeProject\android\app\build\intermediates\merged_assets\debug\mergeDebugAssets\out\fonts at com.android.ide.common.resources.MergedAssetWriter$AssetWorkAction.run(MergedAssetWriter.java:84) ... 1 more

FAILURE: Build failed with an exception.

I want to successfully build the android app

Upvotes: 23

Views: 41070

Answers (9)

3iL
3iL

Reputation: 2176

Try running this inside your project directory:

  1. cd android
  2. gradlew clean or ./gradlew clean
  3. cd ..
  4. react-native run-android

Upvotes: 33

devjs1000
devjs1000

Reputation: 31

do ./gradlew clean then rm -rf android/app/src/main/assets

Upvotes: 0

sanister
sanister

Reputation: 430

I had this issue when I upgraded the react-native-vector-icons package.

Here's what I did:

  1. Go to android/app/src/main/assets/fonts/*
  2. Delete only files that are related to the library for example - Entypo.ttf, EvilIcons.ttf, MaterialIcons.ttf etc. *For backup purposes you can copy the resources in some other directory.
  3. Build again.

Upvotes: 0

Raouf Mourtada
Raouf Mourtada

Reputation: 79

If you have installed react-native-vector-icons, try to unlink it by using this command

react-native unlink react-native-vector-icons

Upvotes: 4

Udbhav Vikram Singh
Udbhav Vikram Singh

Reputation: 41

In my case, files that were present in android\app\scr\main\assets\fonts folder were causing error after deleting them error goes away and app is also working fine.

Upvotes: 1

Neeleshwar Kumar
Neeleshwar Kumar

Reputation: 375

Nothing worked for me, just created a new project and copied all of my work to it, and finally it worked.

Upvotes: 1

Sumj25
Sumj25

Reputation: 129

For Linux / MacOS- ./gradlew clean

Windows PowerShell- .\gradlew clean

Windows cmd- gradlew clean

Upvotes: 4

Vivek S
Vivek S

Reputation: 325

Go to android/app/build.gradle, add the following lines of codes:

dependencies {
   implementation 'com.android.support:multidex:1.0.3' //enter the latest version 
}
android {
  defaultConfig {
    multiDexEnabled true // This code line
  }
}

Then run again, it'll work. I tried and it worked for me.

Upvotes: 1

Bjørnar Hvidsten
Bjørnar Hvidsten

Reputation: 1014

I had this issue and for me ./gradlew clean didn't help.

But I found a file called assets in android/app/src/main that git showed as untracked. When I removed the assets file I could build the project without problems again.

I use Android Studio for debugging java code and I would guess that is why the assets file was created.

Upvotes: 12

Related Questions