Task 'assembleRelease' not found in root project 'android'

点点圈 提交于 2019-12-23 07:49:46

问题


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


回答1:


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.




回答2:


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




回答3:


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




回答4:


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



来源:https://stackoverflow.com/questions/51397363/task-assemblerelease-not-found-in-root-project-android

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!