Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Error on running Couldn't find "Debug" build variant. #36561

Closed
pipo151086 opened this issue Mar 21, 2023 · 22 comments · Fixed by react-native-community/cli#1933
Closed

Error on running Couldn't find "Debug" build variant. #36561

pipo151086 opened this issue Mar 21, 2023 · 22 comments · Fixed by react-native-community/cli#1933
Labels
💻CLI Needs: Triage 🔍 Platform: Windows Building on Windows. Type: Upgrade Issue Issues reported from upgrade issue form

Comments

@pipo151086
Copy link

New Version

0.72.0-rc.0

Old Version

0.71.3

Build Target(s)

Android

Output of react-native info

info Fetching system and libraries information...
System:
OS: Windows 10 10.0.19045
CPU: (8) x64 Intel(R) Core(TM) i7-4770S CPU @ 3.10GHz
Memory: 1.49 GB / 11.91 GB
Binaries:
Node: 16.13.2 - C:\Program Files\nodejs\node.EXE
Yarn: 1.22.19 - ~\AppData\Roaming\npm\yarn.CMD
npm: 9.6.2 - C:\Program Files\nodejs\npm.CMD
Watchman: 20210110.135312.0 - C:\ProgramData\chocolatey\bin\watchman.EXE
Managers:
RubyGems: Not Found
SDKs:
Android SDK:
API Levels: 23, 26, 28, 29, 30, 31, 33
Build Tools: 28.0.3, 30.0.2, 30.0.3, 31.0.0, 33.0.1, 33.0.2
System Images: android-29 | Google APIs Intel x86 Atom, android-29 | Google Play Intel x86 Atom, android-30 | Google
APIs Intel x86 Atom, android-30 | Google Play Intel x86 Atom, android-33 | Google APIs Intel x86 Atom_64, android-33 | Google Play Intel x86 Atom_64
Android NDK: Not Found
Windows SDK: Not Found
IDEs:
Android Studio: AI-221.6008.13.2211.9619390
Visual Studio: 17.5.33424.131 (Visual Studio Professional 2022)
Languages:
Java: 11.0.2 - C:\Users\Miguel.Altamirano\AppData\Local\jdk-11.0.2\bin\javac.EXE
npmPackages:
@react-native-community/cli: Not Found
react: 18.2.0 => 18.2.0
react-native: 0.72.0-rc.0 => 0.72.0-rc.0
react-native-windows: Not Found
npmGlobalPackages:
react-native: Not Found

Issue and Reproduction Steps

just create a new project

react-native init AwesomeProject --version 0.72.0-rc.0

cd AwesomeProject

npx react-native run-android

RESULT>>>>>>>

error Failed to install the app. Couldn't find "Debug" build variant. Available variants are: .
info Run CLI with --verbose flag for more details.

@pipo151086 pipo151086 added Needs: Triage 🔍 Type: Upgrade Issue Issues reported from upgrade issue form labels Mar 21, 2023
@kelset
Copy link
Contributor

kelset commented Mar 22, 2023

I can't reproduce your issue.

can you try again with:

  1. using npx react-native@latest init RN0720RC0 --version 0.72.0-rc.0 instead
  2. using yarn android instead of npx react-native run-android?

@pipo151086
Copy link
Author

nothing
image

@kelset kelset added the Platform: Windows Building on Windows. label Mar 24, 2023
@cortinico
Copy link
Contributor

This could also be CLI related 🤔

@mengtaoxin
Copy link

The same problem occurs

@pipo151086
Copy link
Author

still stuck here

@kelset
Copy link
Contributor

kelset commented May 4, 2023

please try with 0.72 RC2, we just released it and contains a bunch of improvements for CLI

@pipo151086
Copy link
Author

please try with 0.72 RC2, we just released it and contains a bunch of improvements for CLI

Noup....

cant make it work

image

@cortinico
Copy link
Contributor

This is definitely CLI related. @thymikee can we get someone to look into this?

@thymikee
Copy link
Contributor

thymikee commented May 5, 2023

@pipo151086 can you run gradlew.bat tasks in android directory locally and pass the output?

@pipo151086
Copy link
Author

@thymikee
sure:
image

@szymonrybczak
Copy link
Contributor

Hey, since this issue was fixed last week in react-native-community/cli#1933 - we can close this issue. cc. @cortinico

@pipo151086
Copy link
Author

@szymonrybczak

Not yet....

just about an hour ago they released the new version (11.3.0) that contains the fix of the whitespaces....

react-native-community/cli@v11.2.3...v11.3.0

please update the inner dependecy of cli from 11.2.3 to 11.3.0

@cortinico
Copy link
Contributor

I'm closing this as it's effectively fixed on our end. We're going to bump the CLI and you'll get the fix automatically. Please comment further if the issue is unsolved.

@robprado-dev
Copy link

@cortinico I updated react-native-community/cli and I keep getting this error

@mordechaim
Copy link

Use this patch:

@react-native-community+cli-platform-android+11.2.3.patch

diff --git a/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/listAndroidTasks.js b/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/listAndroidTasks.js
index 59fe1e2..89a0e54 100644
--- a/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/listAndroidTasks.js
+++ b/node_modules/@react-native-community/cli-platform-android/build/commands/runAndroid/listAndroidTasks.js
@@ -37,7 +37,7 @@ const parseTasksFromGradleFile = (taskType, text) => {
   const instalTasks = [];
   const taskRegex = new RegExp(taskType === 'build' ? '^assemble|^bundle' : '^install');
   text.split('\n').forEach(line => {
-    if (taskRegex.test(line) && /(?!.*?Test)^.*$/.test(line)) {
+    if (taskRegex.test(line.trim()) && /(?!.*?Test)^.*$/.test(line.trim())) {
       const metadata = line.split(' - ');
       instalTasks.push({
         task: metadata[0],

@robprado-dev
Copy link

Great! It works. Thank you.

image

@kelset
Copy link
Contributor

kelset commented Jun 5, 2023

@mordechaim can you submit that as a PR to the CLI repo? or is a fix on their end already out?

@szymonrybczak
Copy link
Contributor

@kelset The fix is already merged in CLI, and it is released in v11.3.0

@JoyCood
Copy link

JoyCood commented Aug 8, 2023

i upgrade from 0.70.6 to 0.72.3, and the eact-native-community/cli version is 11.3.5, when run: yarn android, the error occur:

knight@192 awasome % yarn android
yarn run v1.22.19
$ react-native run-android
info Starting JS server...

info 💡 Tip: Make sure that you have set up your development environment correctly, by running react-native doctor. To read more about doctor command visit: https://github.com/react-native-community/cli/blob/main/packages/cli-doctor/README.md#doctor 


error Failed to install the app. Couldn't find "Debug" build variant. Available variants are: .
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

@dowon938
Copy link

dowon938 commented Aug 9, 2023

The same problem occurs

I add this code in build.gradle
subprojects { subproject -> afterEvaluate{ if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) { android { compileSdkVersion rootProject.ext.compileSdkVersion buildToolsVersion rootProject.ext.buildToolsVersion } } } }

Is it related to find build variant?

@lauhon
Copy link

lauhon commented Aug 10, 2023

@cortinico this issue still persists on my end.

I am working on a mac m1, maybe that makes a difference for some reason?

I tested the fix locally, my gradlew build is a success, but the new regex is not resulting in true for any of the lines.

@szymonrybczak
Copy link
Contributor

@lauhon please open new issue in https://github.com/react-native-community/cli and provide your setup.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
💻CLI Needs: Triage 🔍 Platform: Windows Building on Windows. Type: Upgrade Issue Issues reported from upgrade issue form
Projects
None yet
Development

Successfully merging a pull request may close this issue.