Closed muhamedzeema closed 2 years ago
Hi, did you enable minification/obfuscation for the Prod / Release variant?
Can you run the following command to see if there are any tasks named uploadMapping*
created?
./gradlew tasks
@xgouchet yes proguard is enabled for both. and after run ./gradlew tasks couldn't find any task with this naming
Is there any error or warning printed in the gradle output when running the previous command?
@xgouchet no, just got the list of tasks but didn't find uploadMapping task
Can you share your full Gradle scripts please?
@xgouchet HYG
EDITED
Hi @muhamedzeema , I was talking about your Gradle script, not the output of the ./gradlew task
command.
@xgouchet which script, is there any script to get all gradle scripts ?
Mostly, your application's and project's build.gradle
scripts
project gradle
buildscript {
ext {
buildToolsVersion = "29.0.3"
minSdkVersion = 23
compileSdkVersion = 31
targetSdkVersion = 30
kotlinVersion = '1.4.10' // (check what the latest version is)
ndkVersion = "20.1.5948944"
}
repositories {
google()
jcenter()
maven {
url 'https://maven.fabric.io/public'
}
maven { url 'https://developer.huawei.com/repo/' }
}
dependencies {
classpath("com.android.tools.build:gradle:4.1.0")
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
classpath 'com.google.gms:google-services:4.0.1'
classpath 'io.fabric.tools:gradle:1.28.1'
classpath 'com.huawei.agconnect:agcp:1.6.0.300'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
plugins {
id("com.datadoghq.dd-sdk-android-gradle-plugin") version "1.4.0"
}
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
if (details.getRequested().getGroup() == 'com.google.android.gms') {
// If different projects require different versions of
// Google Play Services it causes a crash on run.
// Fix by overriding version for all projects.
details.useVersion('17.0.0')
}
}
}
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()
mavenCentral()
maven { url 'https://www.jitpack.io' }
maven {url 'https://developer.huawei.com/repo/'}
maven {
url "$rootDir/../node_modules/@notifee/react-native/android/libs"
}
}
}
datadog {
site = "EU" // Optional, can be "US", "EU" or "GOV". Default is "US"
checkProjectDependencies = "warn" // Optional, can be "warn", "fail" or "none". Default is "fail". Will check if Datadog SDK is in the project dependencies.
}
app gradle
` implementation fileTree(dir: "libs", include: ["*.jar"]) //noinspection GradleDynamicVersion implementation "com.facebook.react:react-native:+" // From node_modules implementation project(':react-native-config')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.android.gms:play-services-ads:+'
implementation 'com.github.freshdesk:freshchat-android:5.0.0'
implementation "com.google.firebase:firebase-messaging:17.0.0"
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.appboy:android-sdk-ui:18.0.+'
implementation 'com.huawei.agconnect:agconnect-core:1.5.2.300'
implementation 'com.huawei.hms:ads-identifier:3.4.28.305'
implementation 'com.huawei.hms:push:6.3.0.304'
implementation project(':react-native-hms-push')
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'
}`
Hello @muhamedzeema. Tasks are created in the project where Datadog Gradle Plugin is applied, so considering if you've applied it in the app
project, you need to run :app:uploadMappingProdRelease
instead.
Hi @0xfaust got the same error
* What went wrong:
Task 'uploadMappingProdRelease' not found in project ':app'.
Hi @muhamedzeema your application's Gradle script seems incomplete, it doesn't have any android
block of datadog
block like you mentioned earlier
@xgouchet oh, so after adding it to app gradle got this error
only buildscript {} and other plugins {} script blocks are allowed before plugins {} blocks, no other statements are allowed
is there any example for this please ?
Here's a sample build.gradle.kts
script for an application:
plugins {
// build
id("com.android.application")
kotlin("android")
id("kotlin-parcelize")
// analysis
id("com.github.ben-manes.versions")
id("io.gitlab.arturbosch.detekt")
id("org.jlleitschuh.gradle.ktlint")
jacoco
id("com.datadoghq.dd-sdk-android-gradle-plugin")
}
val envName: String by project
android {
compileSdk = 31
defaultConfig {
minSdk = 19
targetSdk = 31
versionCode = AndroidConfig.VERSION.code
versionName = AndroidConfig.VERSION.name
applicationId = "com.example.android"
multiDexEnabled = true
vectorDrawables.useSupportLibrary = true
testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
getByName("release") {
isMinifyEnabled = true
proguardFiles(
getDefaultProguardFile("proguard-android-optimize.txt"),
"proguard-rules.pro"
)
}
}
}
repositories {
google()
mavenCentral()
}
dependencies {
// …
}
But again can you send us your full app/build.gradle
script so that we can help you?
@xgouchet thanks for your efforts really appreciate it, here is my app/build.gradle file
apply plugin: "com.android.application"
apply plugin: 'com.google.firebase.firebase-perf'
project.ext.envConfigFiles = [
stagingDebug: ".env.staging",
stagingRelease: ".env.staging",
prodDebug: ".env.production",
prodRelease: ".env.production",
internalDebug: ".env.internal",
internalRelease: ".env.internal"
]
apply from: project(':react-native-config').projectDir.getPath() + "/dotenv.gradle"
import com.android.build.OutputFile
project.ext.react = [
enableHermes: true, // clean and rebuild if changing
bundleInDebug: true,
bundleInStaging: true,
bundleInInternal: true,
bundleInRelease: true,
bundleInProd: true,
// devDisabledInStaging: true,
// devDisabledInInternal: true,
// devDisabledInRelease: true,
// devDisabledInProd: true,
// extraPackagerArgs: ["--sourcemap-output", "$buildDir/generated/sourcemaps/android-embrace.bundle.map"]
]
apply from: "../../node_modules/react-native/react.gradle"
apply from: "../../node_modules/@sentry/react-native/sentry.gradle"
apply from: "../../node_modules/react-native-code-push/android/codepush.gradle"
/**
* Set this to true to create two separate APKs instead of one:
* - An APK that only works on ARM devices
* - An APK that only works on x86 devices
* The advantage is the size of the APK is reduced by about 4MB.
* Upload all the APKs to the Play Store and people will download
* the correct one based on the CPU architecture of their device.
*/
def enableSeparateBuildPerCPUArchitecture = false
/**
* Run Proguard to shrink the Java bytecode in release builds.
*/
def enableProguardInReleaseBuilds = true
/**
* The preferred build flavor of JavaScriptCore.
*
* For example, to use the international variant, you can use:
* `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
*
* The international variant includes ICU i18n library and necessary data
* allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
* give correct results when using with locales other than en-US. Note that
* this variant is about 6MiB larger per architecture than default.
*/
def jscFlavor = 'org.webkit:android-jsc:+'
/**
* Whether to enable the Hermes VM.
*
* This should be set on project.ext.react and mirrored here. If it is not set
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
* and the benefits of using Hermes will therefore be sharply reduced.
*/
def enableHermes = project.ext.react.get("enableHermes", true);
android {
ndkVersion rootProject.ext.ndkVersion
compileSdkVersion rootProject.ext.compileSdkVersion
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
flavorDimensions "default"
productFlavors { //add this object
prod {
dimension "default"
}
internal {
applicationIdSuffix '.internal'
dimension "default"
}
staging {
applicationIdSuffix '.staging'
dimension "default"
}
}
defaultConfig {
applicationId '*****'
minSdkVersion rootProject.ext.minSdkVersion
targetSdkVersion rootProject.ext.targetSdkVersion
versionCode 3145997
versionName "6.2.1"
testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
missingDimensionStrategy 'react-native-camera', 'general'
missingDimensionStrategy 'store', 'play'
resValue "string", "build_config_package", "********"
resValue 'string', "CODE_PUSH_APK_BUILD_TIME", String.format("\"%d\"", System.currentTimeMillis())
vectorDrawables {
useSupportLibrary true
}
multiDexEnabled true
}
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'
}
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
}
}
}
buildTypes {
debug {
signingConfig signingConfigs.debug
resValue "string", "CodePushDeploymentKey", '""'
}
release {
debuggable false
signingConfig signingConfigs.debug
zipAlignEnabled enableProguardInReleaseBuilds
minifyEnabled enableProguardInReleaseBuilds
shrinkResources false
useProguard enableProguardInReleaseBuilds
proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
// Detox-specific additions to pro-guard
proguardFile "${rootProject.projectDir}/../node_modules/detox/android/detox/proguard-rules-app.pro"
}
}
// 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
// Example: versionCode 1 will generate 1001 for armeabi-v7a, 1002 for x86, etc.
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 =
defaultConfig.versionCode * 1000 + versionCodes.get(abi)
}
}
}
dexOptions {
incremental true
javaMaxHeapSize "4g"
}
}
dependencies {
implementation fileTree(dir: "libs", include: ["*.jar"])
//noinspection GradleDynamicVersion
implementation "com.facebook.react:react-native:+" // From node_modules
implementation project(':react-native-config')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.android.gms:play-services-ads:+'
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'com.appboy:android-sdk-ui:18.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'
}
if (enableHermes) {
def hermesPath = "../../node_modules/hermes-engine/android/";
debugImplementation files(hermesPath + "hermes-debug.aar")
releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
}
plugins {
id("com.datadoghq.dd-sdk-android-gradle-plugin") version "1.4.0"
}
// 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'
}
apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
apply plugin: 'com.google.gms.google-services'
googleServices { disableVersionCheck = true }
datadog {
site = "EU" // Optional, can be "US", "EU" or "GOV". Default is "US"
checkProjectDependencies = "warn" // Optional, can be "warn", "fail" or "none". Default is "fail". Will check if Datadog SDK is in the project dependencies.
}
the plugin block need to be put at the top of the file, like explained by the error message you shared
@xgouchet @0xnm thanks guys for your help
Describe what happened issue when running upload map task on android
Steps to reproduce the issue: this is my implementation on android/build.gradle i added plugins { id("com.datadoghq.dd-sdk-android-gradle-plugin") version "1.4.0" } after buildscript {}
and added this to the end of file
datadog { site = "EU" // Optional, can be "US", "EU" or "GOV". Default is "US" checkProjectDependencies = "warn" // Optional, can be "warn", "fail" or "none". Default is "fail". Will check if Datadog SDK is in the project dependencies. }
i have 3 variants (prod,staging,internal)
i tried to run ./gradlew uploadMappingProdRelease got this error Task 'uploadMappingProdRelease' not found in root project '***'.
Describe what you expected: shoud able to upload mappers from prod variant.
so do i miss somehting ?
Additional context