react-native: Task failed with an exception.(A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction)

Description

BUILD FAILED in 19s

error Failed to install the app. Make sure you have the Android development environment set up: https://reactnative.dev/docs/environment-setup.
Error: Command failed: ./gradlew app:installDebug -PreactNativeDevServerPort=8081

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction
   > Android resource linking failed
     error: resource android:style/TextAppearance.Material not found.
     error: resource android:style/TextAppearance.Material.Body1 not found.
     error: resource android:style/TextAppearance.Material.Body2 not found.
     error: resource android:style/TextAppearance.Material.Button not found.
     error: resource android:style/TextAppearance.Material.Caption not found.
     error: resource android:style/TextAppearance.Material.Display1 not found.
     error: resource android:style/TextAppearance.Material.Display2 not found.
     error: resource android:style/TextAppearance.Material.Display3 not found.
     error: resource android:style/TextAppearance.Material.Display4 not found.
     error: resource android:style/TextAppearance.Material.Headline not found.
     error: resource android:style/TextAppearance.Material.Inverse not found.
     error: resource android:style/TextAppearance.Material.Large not found.
     error: resource android:style/TextAppearance.Material.Large.Inverse not found.
     error: resource android:style/TextAppearance.Material.Widget.PopupMenu.Large not found.
     error: resource android:style/TextAppearance.Material.Widget.PopupMenu.Small not found.
     error: resource android:style/TextAppearance.Material.Medium not found.
     error: resource android:style/TextAppearance.Material.Medium.Inverse not found.
     error: resource android:style/TextAppearance.Material.Menu not found.
     error: resource android:style/TextAppearance.Material.SearchResult.Subtitle not found.
     error: resource android:style/TextAppearance.Material.SearchResult.Title not found.


* 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:
java.lang.StackOverflowError (no error message)

* 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 19s

    at makeError (/Users/inshadansari/Desktop/inshad/AwesomeProject/node_modules/execa/index.js:174:9)
    at /Users/inshadansari/Desktop/inshad/AwesomeProject/node_modules/execa/index.js:278:16
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async runOnAllDevices (/Users/inshadansari/Desktop/inshad/AwesomeProject/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
    at async Command.handleAction (/Users/inshadansari/Desktop/inshad/AwesomeProject/node_modules/@react-native-community/cli/build/index.js:142:9)
info Run CLI with --verbose flag for more details.

Version

0.70.6

Output of npx react-native info

inshadansari@192 AwesomeProject % npx react-native info info Fetching system and libraries information… System: OS: macOS 13.0.1 CPU: (8) arm64 Apple M1 Pro Memory: 156.63 MB / 16.00 GB Shell: 5.8.1 - /bin/zsh Binaries: Node: 19.1.0 - /opt/homebrew/bin/node Yarn: 1.22.19 - /opt/homebrew/bin/yarn npm: 8.19.3 - /opt/homebrew/bin/npm Watchman: 2022.11.14.00 - /opt/homebrew/bin/watchman Managers: CocoaPods: 1.11.3 - /opt/homebrew/bin/pod SDKs: iOS SDK: Platforms: DriverKit 22.1, iOS 16.1, macOS 13.0, tvOS 16.1, watchOS 9.1 Android SDK: Not Found IDEs: Android Studio: 2021.3 AI-213.7172.25.2113.9123335 Xcode: 14.1/14B47b - /usr/bin/xcodebuild Languages: Java: 11.0.17 - /usr/bin/javac npmPackages: @react-native-community/cli: Not Found react: 18.1.0 => 18.1.0 react-native: 0.70.6 => 0.70.6 react-native-macos: Not Found npmGlobalPackages: react-native: Not Found

Steps to reproduce

Create new project(Macbook Pro M1) 1:npx react-native init AwesomeProject

Run project using command 1:npx react-native run-android

Note Also try to run via android studio same error and same code is working fine for ios

Snack, code example, screenshot, or link to a repository

Screenshot 2022-11-26 at 12 55 55 AM

About this issue

  • Original URL
  • State: closed
  • Created 2 years ago
  • Reactions: 1
  • Comments: 17 (3 by maintainers)

Most upvoted comments

Also getting this issue since updating to React Native 0.71.2.

// android/build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "33.0.0"
        minSdkVersion = 23
        compileSdkVersion = 33
        targetSdkVersion = 33
        kotlinVersion = "1.6.20"

        // We use NDK 23 which has both M1 support and is the side-by-side NDK version from AGP.
        ndkVersion = "23.1.7779620"
    }
    repositories {
        google()
        mavenCentral()
        // App Lovin
        maven { url 'https://artifacts.applovin.com/android' }
    }
    dependencies {
        classpath("com.android.tools.build:gradle:7.3.1")
        classpath("com.facebook.react:react-native-gradle-plugin")

        // Firebase dependencies
        classpath 'com.google.gms:google-services:4.3.14'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.9.2'
        classpath 'com.google.firebase:perf-plugin:1.4.2'

        // App Lovin
        classpath "com.applovin.quality:AppLovinQualityServiceGradlePlugin:+"

        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}