diff --git a/platform/android/MapLibreAndroidTestApp/build.gradle.kts b/platform/android/MapLibreAndroidTestApp/build.gradle.kts index 3dd5c6723..bbe1ac04d 100644 --- a/platform/android/MapLibreAndroidTestApp/build.gradle.kts +++ b/platform/android/MapLibreAndroidTestApp/build.gradle.kts @@ -27,10 +27,12 @@ android { minSdk = 21 targetSdk = 33 versionCode = 14 - versionName = "6.0.1" testInstrumentationRunner = "org.maplibre.android.InstrumentationRunner" multiDexEnabled = true + versionName = file("../VERSION").readText().trim() + manifestPlaceholders["SENTRY_DSN"] = "" + manifestPlaceholders["SENTRY_ENV"] = "" } nativeBuild(listOf("example-custom-layer")) @@ -53,9 +55,11 @@ android { keepDebugSymbols += "**/*.so" } } + buildConfigField("String", "SENTRY_DSN", "\"" + (System.getenv("SENTRY_DSN") ?: "") + "\"") manifestPlaceholders["SENTRY_DSN"] = System.getenv("SENTRY_DSN") ?: "" } + getByName("release") { isMinifyEnabled = true isShrinkResources = true diff --git a/platform/android/MapLibreAndroidTestApp/src/main/AndroidManifest.xml b/platform/android/MapLibreAndroidTestApp/src/main/AndroidManifest.xml index 9cd89082e..0a27a1cc3 100644 --- a/platform/android/MapLibreAndroidTestApp/src/main/AndroidManifest.xml +++ b/platform/android/MapLibreAndroidTestApp/src/main/AndroidManifest.xml @@ -1317,6 +1317,11 @@ android:value="${SENTRY_DSN}" /> + + { } } + val androidExtension = project.extensions.getByType(AppExtension::class.java) + val propertiesToSet = mapOf( "getDebug" to true, "getOrg" to System.getenv("SENTRY_ORG"), "getProjectName" to System.getenv("SENTRY_PROJECT"), "getAuthToken" to System.getenv("SENTRY_AUTH_TOKEN"), + "getRelease" to androidExtension.defaultConfig.versionName, "getIncludeProguardMapping" to true, "getAutoUploadProguardMapping" to true, "getDexguardEnabled" to false, @@ -58,5 +63,20 @@ class SentryConditionalPlugin : Plugin { propertiesToSet.forEach { (getterName, value) -> setProperty(sentryExt, getterName, value) } + + project.afterEvaluate { + val commitHash = ByteArrayOutputStream() + + project.exec { + commandLine("git", "rev-parse", "HEAD") + standardOutput = commitHash + workingDir = project.rootDir + isIgnoreExitValue = true + } + + androidExtension.applicationVariants.forEach { variant -> + variant.mergedFlavor.manifestPlaceholders["SENTRY_ENV"] = "${variant.name}-$commitHash" + } + } } } diff --git a/platform/android/src/example_custom_layer.cpp b/platform/android/src/example_custom_layer.cpp index 4ac033308..7e1b3b198 100644 --- a/platform/android/src/example_custom_layer.cpp +++ b/platform/android/src/example_custom_layer.cpp @@ -106,11 +106,15 @@ void checkCompileStatus(GLuint shader) { GLint maxLength = 0; glGetShaderiv(shader, GL_INFO_LOG_LENGTH, &maxLength); - // The maxLength includes the NULL character - std::vector errorLog(maxLength); - glGetShaderInfoLog(shader, maxLength, &maxLength, errorLog.data()); - __android_log_write(ANDROID_LOG_ERROR, LOG_TAG, errorLog.data()); - throw Error(std::string(errorLog.begin(), errorLog.end())); + if (maxLength > 0) { + // The maxLength includes the NULL character + std::vector errorLog(maxLength + 1); + glGetShaderInfoLog(shader, maxLength, &maxLength, errorLog.data()); + __android_log_write(ANDROID_LOG_ERROR, LOG_TAG, errorLog.data()); + throw Error(std::string(errorLog.begin(), errorLog.end())); + } else { + throw Error("checkCompileStatus failed to get error string"); + } } }