swpalmer
(Scott Palmer)
February 21, 2019, 9:07pm
1
I have a custom gradle-script plugin that applies the cpp-library plugin, adds a bunch custom tasks and does a bunch of configuration.
One of those tasks needs to depend on ‘assembleDebug’ or ‘assembleRelease’ based on other config. When I try that I get:
Task with path ‘assembleRelease’ not found in project ‘:Native’.
If I depend on ‘assemble’ it works fine. Specifying either assembleDebug or assembleRelease on the command line works fine.
What is the solution to having my custom task depend on one of these ‘hidden’ tasks?
$ gradle ':Native:subBuildLibraries'
...
FAILURE: Build failed with an exception.
* What went wrong:
Could not determine the dependencies of task ':Native:subBuildLibraries'.
> Task with path 'assembleRelease' not found in project ':Native'.
* 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 0s
However…
$ gradle ':Native:assembleRelease'
> Configure project :Native
...
BUILD SUCCESSFUL in 0s
laht
(Lars Ivar Hatledal)
March 11, 2019, 6:57pm
2
I have the same issue. Trying to migrate from the cpp plugin, but I can’t figure out how to build in release mode. I had the same idea about depending on assembleRelease*, but gradle cannot find it inside the script…
Edit: Think I found a solution:
def assembleAllRelease = []
tasks.all {
if (it.name.contains("assembleRelease")) {
assembleAllRelease.add(it)
}
}
tasks.register("assembleAllRelease") {
dependsOn assembleAllRelease
}
1 Like
prosofsky
(Renato Prosofsky)
November 29, 2020, 2:21pm
3
I have the same issue, in my project I have 2 build.gradle
1 inside the root folder named “android” and the other inside in a folder “android/app”
the build.gradle configuration inside the android folder (my root) is:
buildscript {
ext {
buildToolsVersion = "29.0.2"
minSdkVersion = 21
compileSdkVersion = 29
targetSdkVersion = 29
}
repositories {
google()
jcenter()
}
dependencies {
classpath("com.android.tools.build:gradle:3.5.3")
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
mavenLocal()
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")
}
google()
jcenter()
maven { url 'https://www.jitpack.io' }
}
}
and in the app folder is:
android {
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultConfig {
applicationId "com.evmdsfaapp"
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 1
versionName "1.0"
}
signingConfigs {
release {
if (project.hasProperty('MYAPP_UPLOAD_STORE_FILE')) {
storeFile file(MYAPP_UPLOAD_STORE_FILE)
storePassword MYAPP_UPLOAD_STORE_PASSWORD
keyAlias MYAPP_UPLOAD_KEY_ALIAS
keyPassword MYAPP_UPLOAD_KEY_PASSWORD
}
}
}
splits {
abi {
reset()
enable enableSeparateBuildPerCPUArchitecture
universalApk false // If true, also generate a universal APK
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
}
}
signingConfigs {
debug {
storeFile file('debug.keystore')
storePassword 'android'
keyAlias 'androiddebugkey'
keyPassword 'android'
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
}
release {
// Caution! In production, you need to generate your own keystore file.
// see https://reactnative.dev/docs/signed-apk-android.
signingConfig signingConfigs.debug
minifyEnabled enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
signingConfig signingConfigs.release
}
}
// applicationVariants are e.g. debug, release
applicationVariants.all { variant ->
variant.outputs.each { output ->
// For each separate APK per architecture, set a unique version code as described here:
// https://developer.android.com/studio/build/configure-apk-splits.html
def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
def abi = output.getFilter(OutputFile.ABI)
if (abi != null) { // null for the universal-debug, universal-release variants
output.versionCodeOverride =
versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
}
}
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
exclude group:'com.facebook.fbjni'
}
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
exclude group:'com.squareup.okhttp3', module:'okhttp'
}
debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
exclude group:'com.facebook.flipper'
}
addUnimodulesDependencies()
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
// Run this once to be able to run the application with BUCK
// puts all compile dependencies into folder libs for BUCK to use
task copyDownloadableDepsToLibs(type: Copy) {
from configurations.compile
into 'libs'
}
task wrapper(type: Wrapper) {
gradleVersion = '7.0'
}
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
but when I try the gradlew assembleRelease, returns me the message:
Task 'assembleRelease' not found in root project 'MY-PROJECT'.
Can someone help me?
Tks!!