Task 'assembleRelease' not found in root project 'android'
Asked Answered
U

11

19

I'm using Reactnative 0.54.0 and react-native-cli 2.0.1 along side gradle 4.8.1

I have created a react-native project using create-react-native-app myProjectName

When I created the project, it doesn't include android and ios folders, so I added them manually.

I also installed gradle using choco and then created a wrapper for it using gradle wrapper --gradle-version 4.8.1 --distribution-type all

so I am developing react-native using microsoft vsCode and then see my application in action using Genymotion emulator, everything is fine

now, I want to generate the final Signed APK for play store, I'm using this guide provided by react-native

https://facebook.github.io/react-native/docs/signed-apk-android.html

When I want to run gradlew assembleRelease I get this error

C:\myApp\android>gradlew assembleRelease

FAILURE: Build failed with an exception.

* What went wrong:
Task 'assembleRelease' not found in root project 'android'.

* Try:
Run gradlew tasks to get a list of available tasks. 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 4s

what's wrong with assembleRelease? what should I do?

to add more info, I have to say that when I want to build this project in VSTS (TFS Online) I get this error

2018-07-17T16:20:14.9268702Z ##[error]Error: Not found wrapperScript: D:\a\1\s\gradlew

Any clue is appriciated Thanks

Update: as @philipp asked, this is the list of tasks that gradlew have listed and assembleRelease is not one one them!!!! what's the reason?

C:\myApp\Android>gradlew tasks

> Task :tasks

------------------------------------------------------------
All tasks runnable from root project
------------------------------------------------------------

Build Setup tasks
-----------------
init - Initializes a new Gradle build.
wrapper - Generates Gradle wrapper files.

Help tasks
----------
buildEnvironment - Displays all buildscript dependencies declared in root project 'android'.
components - Displays the components produced by root project 'android'. [incubating]
dependencies - Displays all dependencies declared in root project 'android'.
dependencyInsight - Displays the insight into a specific dependency in root project 'android'.
dependentComponents - Displays the dependent components of components in root project 'android'. [incubating]
help - Displays a help message.
model - Displays the configuration model of root project 'android'. [incubating]
projects - Displays the sub-projects of root project 'android'.
properties - Displays the properties of root project 'android'.
tasks - Displays the tasks runnable from root project 'android'.

To see all tasks and more detail, run gradlew tasks --all

To see more detail about a task, run gradlew help --task <task>

BUILD SUCCESSFUL in 1s
1 actionable task: 1 executed

and this is myApp\android**build.gradle**

project.ext.react = [
    bundleInStaging: true 
]
task wrapper(type: Wrapper) {
    gradleVersion = '4.8.1'
}
android {
    defaultConfig {
        applicationId "com.sunkime.client"
    }
    signingConfigs {
        staging {
            keyAlias = "staging"
            storeFile = file("my-release-key.keystore")
            keyPassword = "qwert%$#@!"
            storePassword = "qwert%$#@!"
        }
        release {
            if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                storeFile file(MYAPP_RELEASE_STORE_FILE)
                storePassword qwert%$#@!
                keyAlias qwert%$#@!
                keyPassword qwert%$#@!
            }
        }
    }
    buildTypes {
        debug {
            applicationIdSuffix ".debug"
        }
        staging {
            applicationIdSuffix ".staging"
            signingConfig signingConfigs.staging
            minifyEnabled true
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }

        release {
            applicationIdSuffix ".release"
            signingConfig signingConfigs.release
            minifyEnabled true
            proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
        }
    }
}

I also used gradlew clean and no difference

Ulrich answered 18/7, 2018 at 8:41 Comment(0)
F
11

Is it specific for assembleRelease or is gradlew assembleDebug working?

Maybe try cd android && ./gradlew clean && ./gradlew assembleRelease

Posting your apps build.gradle could also help.

As a first task I would recommend to run ./gradlew tasks to check if gradle is set up correctly and the task assembleRelease is listed.

Following answered 18/7, 2018 at 9:7 Comment(3)
I updated the question, and added build.gradle and a list of available gradlew tasks, assembleRelease is not listed!!!! I also used gradlew clean and no difference. do you have any idea, why assembleRelese is not listed?Ulrich
Maybe you are running gradlew from the wrong directory. You can also try using the gradlew.bat for WindowsFollowing
yes i wanna integrate it with bitrise as CI CD can anyone help on thisLurk
G
4

You need a settings.gradle file into your Android folder.

Grandpa answered 6/9, 2018 at 15:50 Comment(0)
B
4

If assembleRelease and assembleDebug tasks don't working, you can try gradlew assemble

Bedfellow answered 8/4, 2019 at 10:7 Comment(1)
As of 22nd November 2019, this is actually what works! gradlew assembleKalynkam
A
3

That error can occur after upgrading versions of IntelliJ IDEA or Android Studio, or after Generating a new APK, you may need to refresh the IDE's cache. It can also be due to updating the location of SDK. Just a simple hack will do, Invalidate cache

File -> Invalidate Caches / Restart.
Attend answered 29/4, 2020 at 11:27 Comment(0)
D
1

I have finally solve this error:

You have to check, one by one each versions of your dependencies in your pubspec.yaml. During one week I got stuck bcs my version of path_provider package wasn't the latest.

Detribalize answered 29/6, 2020 at 12:29 Comment(0)
J
0

For me works setting the ANDROID_HOME and delete file local.properties with "sdk.dir=C:\Users\Me\AppData\Local\Android\Sdk". When gradle does not find the local properties It search in ANDROID_HOME

Jeaninejeanlouis answered 18/11, 2019 at 18:30 Comment(0)
B
0

Make sure you are not finding the android environment variables

Run the command on the mac like this to load the variables

source ~/.bash_profile
Blockish answered 31/5, 2020 at 21:27 Comment(0)
D
-1

I encountered this error when I accidentally deleted app build.gradle file.

Dorseydorsiferous answered 16/11, 2020 at 10:41 Comment(0)
C
-1

File -> Invalidate Caches / Restart... does magic

Cobia answered 8/12, 2021 at 21:51 Comment(0)
T
-1
"createAndroidBuild" : "cd android && ./gradlew clean && ./gradlew assembleRelease"

In terminal run this script using below command

yarn createAndroidBuild

enter image description here

Telluric answered 10/12, 2021 at 7:57 Comment(0)
B
-1

for me I remove : before assemble
this throw error

./gradlew clean :assembleRelease

solved by

./gradlew clean assembleRelease
Bobbysoxer answered 14/10, 2022 at 13:35 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.