Android debug build stopped running

Build not running

kailashuniyal@C02F5D1BMD6M cwings-delivery-app % yarn run android:cwings:dev
yarn run v1.22.19
$ react-native run-android --variant=cwingsdevelopmentdebug --port $npm_package_config_port
info JS server already running.
info Installing the app...

> Configure project :
VersionName is set to 0.0.1
VersionCode is set to 1

> Configure project :app
Reading env from: .env
Reading env from: .env.cwings.dev
[react-native-background-geolocation] Purging debug resources in release build
[react-native-background-geolocation] Purging debug resources in release build
[react-native-background-geolocation] Purging debug resources in release build
[react-native-background-geolocation] Purging debug resources in release build
[react-native-background-geolocation] Purging debug resources in release build
[react-native-background-geolocation] Purging debug resources in release build

> Configure project :expo-application
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :expo-av
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :expo-barcode-scanner
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :expo-battery
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :expo-camera
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :expo-constants
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :expo-error-recovery
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :expo-file-system
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :expo-font
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :expo-image-loader
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :expo-keep-awake
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :expo-location
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :expo-modules-core
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

> Configure project :expo
WARNING:Software Components will not be created automatically for Maven publishing from Android Gradle Plugin 8.0. To opt-in to the future behavior, set the Gradle property android.disableAutomaticComponentCreation=true in the `gradle.properties` file or use the new publishing DSL.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 8.0.

You can use '--warning-mode all' to show the individual deprecation warnings and determine if they come from your own scripts or plugins.

See https://docs.gradle.org/7.5.1/userguide/command_line_interface.html#sec:command_line_warnings
5 actionable tasks: 5 up-to-date

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file '/Users/kailashuniyal/Desktop/backup/cwings-delivery-app/node_modules/expo/android/build.gradle' line: 9

* What went wrong:
A problem occurred evaluating project ':expo'.
> Cannot invoke method multiply() on null object

* 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.
-----------
* Where:
Build file '/Users/kailashuniyal/Desktop/backup/cwings-delivery-app/node_modules/expo/android/build.gradle' line: 78

* What went wrong:
A problem occurred configuring project ':expo'.
> Could not get unknown property 'release' for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.

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

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:installCwingsdevelopmentdebug -PreactNativeDevServerPort=9000

FAILURE: Build completed with 2 failures.

1: Task failed with an exception.
-----------
* Where:
Build file '/Users/kailashuniyal/Desktop/backup/cwings-delivery-app/node_modules/expo/android/build.gradle' line: 9

* What went wrong:
A problem occurred evaluating project ':expo'.
> Cannot invoke method multiply() on null object

* 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.
-----------
* Where:
Build file '/Users/kailashuniyal/Desktop/backup/cwings-delivery-app/node_modules/expo/android/build.gradle' line: 78

* What went wrong:
A problem occurred configuring project ':expo'.
> Could not get unknown property 'release' for SoftwareComponentInternal set of type org.gradle.api.internal.component.DefaultSoftwareComponentContainer.

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

    at makeError (/Users/kailashuniyal/Desktop/backup/cwings-delivery-app/node_modules/execa/index.js:174:9)
    at /Users/kailashuniyal/Desktop/backup/cwings-delivery-app/node_modules/execa/index.js:278:16
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async runOnAllDevices (/Users/kailashuniyal/Desktop/backup/cwings-delivery-app/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/runOnAllDevices.js:109:5)
    at async Command.handleAction (/Users/kailashuniyal/Desktop/backup/cwings-delivery-app/node_modules/@react-native-community/cli/build/index.js:142:9)
info Run CLI with --verbose flag for more details.
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
kailashuniyal@C02F5D1BMD6M cwings-delivery-app % 

System Info

kailashuniyal@C02F5D1BMD6M android % npx expo-env-info

  expo-env-info 1.0.5 environment info:
    System:
      OS: macOS 13.4
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 20.2.0 - /usr/local/bin/node
      Yarn: 1.22.19 - /usr/local/bin/yarn
      npm: 9.6.6 - /usr/local/bin/npm
      Watchman: 2023.05.01.00 - /usr/local/bin/watchman
    Managers:
      CocoaPods: 1.12.1 - /Users/kailashuniyal/.rvm/gems/ruby-2.7.5/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
    IDEs:
      Android Studio: 2021.3 AI-213.7172.25.2113.9123335
      Xcode: 14.2/14C18 - /usr/bin/xcodebuild
kailashuniyal@C02F5D1BMD6M android % npx react-native info
info Fetching system and libraries information...
System:
    OS: macOS 13.4
    CPU: (12) x64 Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz
    Memory: 60.71 MB / 16.00 GB
    Shell: 5.9 - /bin/zsh
  Binaries:
    Node: 20.2.0 - /usr/local/bin/node
    Yarn: 1.22.19 - /usr/local/bin/yarn
    npm: 9.6.6 - /usr/local/bin/npm
    Watchman: 2023.05.01.00 - /usr/local/bin/watchman
  Managers:
    CocoaPods: 1.12.1 - /Users/kailashuniyal/.rvm/gems/ruby-2.7.5/bin/pod
  SDKs:
    iOS SDK:
      Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
    Android SDK: Not Found
  IDEs:
    Android Studio: 2021.3 AI-213.7172.25.2113.9123335
    Xcode: 14.2/14C18 - /usr/bin/xcodebuild
  Languages:
    Java: 11.0.19 - /usr/bin/javac
  npmPackages:
    @react-native-community/cli: Not Found
    react: Not Found
    react-native: Not Found
    react-native-macos: Not Found
  npmGlobalPackages:
    *react-native*: Not Found

I changed nothing suddenly debug build stopped running.
Please provide solution.

Hi @kailash23

Please try running those npx expo-env-info etc. in the root of your project instead of the android directory?

I see this is a Bare workflow project, right?

Based on the output it seems you are trying to make a debug build, but it seems to be compiling in release mode.

What’s around line 9 of that file?

In an Expo SDK 48 project I have this:

static def versionToNumber(major, minor, patch) {
  return patch * 100 + minor * 10000 + major * 1000000
}

Assuming it’s the same in your project, it seems that for some reason either patch, minor or major are null in your case.

What’s around line 78?

In an Expo SDK 48 app I have the following:

afterEvaluate {
  publishing {
    publications {
      release(MavenPublication) {
        from components.release
        // Add additional sourcesJar to artifacts
        artifact(androidSourcesJar)
      }
    }
    repositories {
      maven {
        url = mavenLocal().url
      }
    }
  }
}

Line 78 is the one with from components.release. Assuming you have the same thing then it seems that in your case components doesn’t have a release property. This seems related to the discrepancy with you trying to build in debug mode, but the log mentioning release mode.

 expo-env-info 1.0.5 environment info:
    System:
      OS: macOS 13.4
      Shell: 5.9 - /bin/zsh
    Binaries:
      Node: 19.2.0 - /usr/local/bin/node
      Yarn: 1.22.19 - /usr/local/bin/yarn
      npm: 8.19.3 - /usr/local/bin/npm
      Watchman: 2023.05.15.00 - /usr/local/bin/watchman
    Managers:
      CocoaPods: 1.12.1 - /Users/kailashuniyal/.rvm/gems/ruby-2.7.5/bin/pod
    SDKs:
      iOS SDK:
        Platforms: DriverKit 22.2, iOS 16.2, macOS 13.1, tvOS 16.1, watchOS 9.1
    IDEs:
      Android Studio: 2021.3 AI-213.7172.25.2113.9123335
      Xcode: 14.2/14C18 - /usr/bin/xcodebuild
    npmPackages:
      expo: ^46.0.16 => 46.0.21 
      react: 18.1.0 => 18.1.0 
      react-native: 0.70.9 => 0.70.9 
    Expo Workflow: bare

My bad

android/build.gradle

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

buildscript {

    def getMyVersionName = { ->
        def name = project.hasProperty('versionName') ? versionName : "0.0.1"
        println "VersionName is set to $name"
        return name
    }

    def getMyVersionCode = { ->
        def code = project.hasProperty('versionCode') ? versionCode.replace(".", "").toInteger() : 1
        println "VersionCode is set to $code"
        return code
    }


    ext {
        googlePlayServicesLocationVersion = "17.0.0"  // Or higher.
        buildToolsVersion = "33.0.0"
        minSdkVersion = 23
        compileSdkVersion = 33
        targetSdkVersion = 33 
        androidXCore = "1.6.0"

        if (System.properties['os.arch'] == "aarch64") {
            // For M1 Users we need to use the NDK 24 which added support for aarch64
            ndkVersion = "24.0.8215888"
        } else {
            // Otherwise we default to the side-by-side NDK version from AGP.
            ndkVersion = "21.4.7075529"
        }

        appCompatVersion = "1.1.0"      // Or higher.  Required for new AndroidX compatibility.  
        versionName = getMyVersionName()
        versionCode = getMyVersionCode()
    }
    repositories {
        google()
        mavenCentral()
    }
    dependencies {
        classpath 'com.google.gms:google-services:4.3.10'
        
        classpath("com.android.tools.build:gradle:7.2.1")
        classpath("com.facebook.react:react-native-gradle-plugin")
        classpath("de.undercouch:gradle-download-task:5.0.1")

        classpath 'com.google.firebase:perf-plugin:1.4.1'
        classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
        
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.0"
    }
}

allprojects {
    repositories {
        maven { url "https://appboy.github.io/appboy-android-sdk/sdk" }
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url("$rootDir/../node_modules/react-native/android")
        }
        maven {
            // Android JSC is installed from npm
            url("$rootDir/../node_modules/jsc-android/dist")
        }
        maven {
            // Required for react-native-background-geolocation
            url("${project(':react-native-background-geolocation-android').projectDir}/libs")
        }
        maven {
            // react-native-background-fetch
            url("${project(':react-native-background-fetch').projectDir}/libs")
        }
        // * Add a new maven block after other repositories / blocks *
        maven {
            // expo-camera bundles a custom com.google.android:cameraview
            url "$rootDir/../node_modules/expo-camera/android/maven"
        }
        mavenCentral {
            // We don't want to fetch react-native from Maven Central as there are
            // older versions over there.
            content {
                excludeGroup "com.facebook.react"
            }
        }
        google()
        jcenter()
        mavenCentral()
        mavenLocal()
        maven { url 'https://www.jitpack.io' }  
    }
}

It was working earlier without any issue
Today I opened the project I started getting this error

This is the command

"android:cwings:stg": "react-native run-android --variant=cwingsstagingdebug --port $npm_package_config_port",

Thanks, that confirms that it’s a bare app and I see it’s using Expo SDK 46.

This looks like your app’s build.gradle. I was asking about node_modules/expo/android/build.gradle, but I suspect it’s the same as the Expo SDK 48 version that I was looking at anyway.

I’m not sure what’s going on, but I suspect there’s some or other Android Studio or gradle cache you can clear to sort this out.

Does a release build work?

Thanks for your valuable time

Release build works

apply plugin: 'com.android.library'
apply plugin: 'kotlin-android'
apply plugin: 'maven-publish'

// Import autolinking script
apply from: "../scripts/autolinking.gradle"

static def versionToNumber(major, minor, patch) {
  return patch * 100 + minor * 10000 + major * 1000000
}

def getRNVersion() {
  def nodeModulesVersion = [
      "node",
      "-e",
      "console.log(require('react-native/package.json').version);"
  ]
      .execute([], projectDir)
      .text
      .trim()

  def version = safeExtGet("reactNativeVersion", nodeModulesVersion)
  def coreVersion = version.split("-")[0]
  def (major, minor, patch) = coreVersion.tokenize('.').collect { it.toInteger() }

  return versionToNumber(
      major,
      minor,
      patch
  )
}

ensureDependeciesWereEvaluated(project)

group = 'host.exp.exponent'
version = '46.0.21'

buildscript {
  def expoModulesCorePlugin = new File(project(":expo-modules-core").projectDir.absolutePath, "ExpoModulesCorePlugin.gradle")
  if (expoModulesCorePlugin.exists()) {
    apply from: expoModulesCorePlugin
    applyKotlinExpoModulesCorePlugin()
  }

  // Simple helper that allows the root project to override versions declared by this library.
  ext.safeExtGet = { prop, fallback ->
    rootProject.ext.has(prop) ? rootProject.ext.get(prop) : fallback
  }

  // Ensures backward compatibility
  ext.getKotlinVersion = {
    if (ext.has("kotlinVersion")) {
      ext.kotlinVersion()
    } else {
      ext.safeExtGet("kotlinVersion", "1.6.10")
    }
  }

  repositories {
    mavenCentral()
  }

  dependencies {
    classpath("org.jetbrains.kotlin:kotlin-gradle-plugin:${getKotlinVersion()}")
  }
}

// Creating sources with comments
task androidSourcesJar(type: Jar) {
  classifier = 'sources'
  from android.sourceSets.main.java.srcDirs
}

afterEvaluate {
  publishing {
    publications {
      release(MavenPublication) {
        from components.release
        // Add additional sourcesJar to artifacts
        artifact(androidSourcesJar)
      }
    }
    repositories {
      maven {
        url = mavenLocal().url
      }
    }
  }
}

android {
  compileSdkVersion safeExtGet("compileSdkVersion", 31)

  compileOptions {
    sourceCompatibility JavaVersion.VERSION_11
    targetCompatibility JavaVersion.VERSION_11
  }

  kotlinOptions {
    jvmTarget = JavaVersion.VERSION_11.majorVersion
  }

  defaultConfig {
    minSdkVersion safeExtGet("minSdkVersion", 21)
    targetSdkVersion safeExtGet("targetSdkVersion", 31)
    versionCode 1
    versionName "46.0.21"
    consumerProguardFiles("proguard-rules.pro")
  }
  lintOptions {
    abortOnError false
  }
  testOptions {
    unitTests.includeAndroidResources = true
  }

  sourceSets {
    main {
      java {
        srcDirs += new File(project.buildDir, generatedFilesSrcDir)

        def rnVersion = getRNVersion()
        if (rnVersion >= versionToNumber(0, 69, 0)) {
          srcDirs += "src/reactNativeHostWrapper"
        } else if (rnVersion >= versionToNumber(0, 67, 0)) {
          srcDirs += "src/reactNativeHostWrapper68"
        } else {
          srcDirs += "src/reactNativeHostWrapper64"
        }
      }
    }
  }
}

dependencies { dependencyHandler ->
  //noinspection GradleDynamicVersion
  implementation 'com.facebook.react:react-native:+'

  testImplementation 'junit:junit:4.13.1'
  testImplementation 'androidx.test:core:1.4.0'
  testImplementation "com.google.truth:truth:1.1.2"
  testImplementation 'io.mockk:mockk:1.12.0'

  // Link expo modules as dependencies of the adapter. It uses `api` configuration so they all will be visible for the app as well.
  // A collection of the dependencies depends on the options passed to `useExpoModules` in your project's `settings.gradle`.
  addExpoModulesDependencies(dependencyHandler, project)
}

// A task generating a package list of expo modules.
task generateExpoModulesPackageList {
  doLast {
    generateExpoModulesPackageList()
  }
}

// Run that task during prebuilding phase.
preBuild.dependsOn "generateExpoModulesPackageList"

Let me check
There may some permission issue. I mean sudo thing.
I will get back to you.

Thanks again

It’s best not to run any of this stuff using sudo. If you did that in the past then maybe something is owned by root and therefore later builds are unable to delete/modify files. So you might want to do something like this:

sudo chown -R kailashuniyal /Users/kailashuniyal/Desktop/backup/cwings-delivery-app

As you earlier mention about cleaning gradle.
I did that and it asked for system password. After that everything worked fine.
I did some setting change regarding terminal full disk access that caused the above issue.

Please mark this as fixed.

Thanks a lot wodin.

1 Like

This topic was automatically closed 20 days after the last reply. New replies are no longer allowed.