| 7 | apply plugin: "io.objectbox" |
| 8 |
| 9 | def verName = APP_VERSION_NAME |
| 10 | def verCode = 1220 |
| 11 |
| 12 |
| 13 | def officialVer = APP_VERSION_NAME |
| 14 | def officialCode = APP_VERSION_CODE |
| 15 |
| 16 | def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json") |
| 17 |
| 18 | def beta = verName.contains("preview") |
| 19 |
| 20 | if (serviceAccountCredentialsFile.isFile()) { |
| 21 | setupPlay(beta) |
| 22 | play.serviceAccountCredentials = serviceAccountCredentialsFile |
| 23 | } else if (System.getenv().containsKey("ANDROID_PUBLISHER_CREDENTIALS")) { |
| 24 | setupPlay(beta) |
| 25 | } |
| 26 |
| 27 | void setupPlay(boolean beta) { |
| 28 | apply plugin: "com.github.triplet.play" |
| 29 | play { |
| 30 | track = beta ? "beta" : "production" |
| 31 | defaultToAppBundles = true |
| 32 | } |
| 33 | } |
| 34 |
| 35 | configurations { |
| 36 | compile.exclude module: "support-v4" |
| 37 | } |
| 38 |
| 39 | def keystorePwd = null |
| 40 | def alias = null |
| 41 | def pwd = null |
| 42 | def sentry_token = System.getenv("SENTRY_AUTH_TOKEN") |
| 43 | def nagram_build_args = System.getenv("NAGRAM_BUILD_ARGS") |
| 44 | def sentry_upload = project.rootProject.file("sentry.properties").exists() |
| 45 | def disableCMakeRelWithDebInfo = System.getenv("COMPILE_NATIVE") == null |
| 46 |
| 47 | Properties properties |
| 48 | def base64 = System.getenv("LOCAL_PROPERTIES") |
| 49 | if (base64 != null && !base64.isBlank()) { |
| 50 | properties = new Properties() |
| 51 | properties.load(new ByteArrayInputStream(Base64.decoder.decode(base64))) |
| 52 | } else if (project.rootProject.file("local.properties").exists()) { |
| 53 | properties = new Properties() |
| 54 | properties.load(project.rootProject.file("local.properties").newDataInputStream()) |
| 55 | } |
| 56 |
| 57 | if (properties != null) { |
| 58 | keystorePwd = properties.getProperty("KEYSTORE_PASS") |
| 59 | alias = properties.getProperty("ALIAS_NAME") |
| 60 | pwd = properties.getProperty("ALIAS_PASS") |
| 61 | sentry_token = properties.getProperty("SENTRY_AUTH_TOKEN", sentry_token) |
| 62 | nagram_build_args = properties.getProperty("NAGRAM_BUILD_ARGS", nagram_build_args) |
| 63 | } |
| 64 |
| 65 | keystorePwd = keystorePwd ?: System.getenv("KEYSTORE_PASS") |
| 66 | alias = alias ?: System.getenv("ALIAS_NAME") |
| 67 | pwd = pwd ?: System.getenv("ALIAS_PASS") |
| 68 |
| 69 | def targetTask = "" |
| 70 | if (!gradle.startParameter.taskNames.isEmpty()) { |
| 71 | if (gradle.startParameter.taskNames.size == 1) { |
| 72 | targetTask = gradle.startParameter.taskNames[0].toLowerCase() |
| 73 | } |
| 74 | } |
| 75 |
| 76 | def nativeTarget = System.getenv("NATIVE_TARGET") |
| 77 | if (nativeTarget == null) nativeTarget = "" |
| 78 |
| 79 | android { |
| 80 | compileSdkVersion 34 |
| 81 | ndkVersion rootProject.ext.ndkVersion |
| 82 |
| 83 | defaultConfig.applicationId = "xyz.nextalone.nagram" |
| 84 |
| 85 | splits { |
| 86 |
| 87 | abi { |
| 88 | if (targetTask.contains("fdroid")) { |
| 89 | enable false |
| 90 | universalApk true |
| 91 | } else { |
| 92 | enable true |
| 93 | reset() |
| 94 | universalApk false |
| 95 | if (!nativeTarget.isBlank()) { |
| 96 | include nativeTarget |
| 97 | } else { |
| 98 | include 'armeabi-v7a', 'arm64-v8a' |
| 99 | } |
| 100 | } |
| 101 | } |
| 102 |
| 103 | } |
| 104 |
| 105 | defaultConfig { |
| 106 | minSdkVersion 21 |
| 107 | //noinspection ExpiredTargetSdkVersion,OldTargetApi |
| 108 | targetSdkVersion 34 |
| 109 |
| 110 | versionName verName |
| 111 | versionCode verCode |
| 112 |
| 113 | def appId = "11535358" |
| 114 | def appHash = "33d372962fadb01df47e6ceed4e33cd6" |
| 115 |
| 116 | //obtain your own keys at https://core.telegram.org/api/obtaining_api_id |
| 117 |
| 118 | if (properties != null) { |
| 119 | appId = properties.getProperty("TELEGRAM_APP_ID") ?: System.getenv("TELEGRAM_APP_ID") ?: appId |
| 120 | appHash = properties.getProperty("TELEGRAM_APP_HASH") ?: System.getenv("TELEGRAM_APP_HASH") ?: appHash |
| 121 | } |
| 122 |
| 123 | buildConfigField "String", "BUILD_VERSION_STRING", "\"" + verName + "\"" |
| 124 | buildConfigField "String", "OFFICIAL_VERSION", "\"" + officialVer + "\"" |
| 125 | buildConfigField "int", "OFFICIAL_VERSION_CODE", officialCode + "" |
| 126 | buildConfigField "int", "APP_ID", appId |
| 127 | buildConfigField "String", "APP_HASH", "\"" + appHash + "\"" |
| 128 |
| 129 | externalNativeBuild { |
| 130 | cmake { |
| 131 | arguments '-DANDROID_STL=c++_static', '-DANDROID_PLATFORM=android-21' //, '-DANDROID_SUPPORT_FLEXIBLE_PAGE_SIZES=ON' |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 |
| 136 | bundle { |
| 137 | language { |
| 138 | enableSplit = false |
| 139 | } |
| 140 | } |
| 141 |
| 142 | externalNativeBuild { |
| 143 | cmake { |
| 144 | path "jni/CMakeLists.txt" |
| 145 | } |
| 146 | } |
| 147 |
| 148 |
| 149 | compileOptions { |
| 150 | sourceCompatibility JavaVersion.VERSION_11 |
| 151 | targetCompatibility JavaVersion.VERSION_11 |
| 152 |
| 153 | coreLibraryDesugaringEnabled true |
| 154 | } |
| 155 |
| 156 | kotlinOptions { |
| 157 | jvmTarget = JavaVersion.VERSION_11.toString() |
| 158 | } |
| 159 |
| 160 | testOptions { |
| 161 | unitTests.includeAndroidResources = true |
| 162 | } |
| 163 |
| 164 | signingConfigs { |
| 165 | release { |
| 166 | storeFile project.file("release.keystore") |
| 167 | storePassword keystorePwd |
| 168 | keyAlias alias |
| 169 | keyPassword pwd |
| 170 | } |
| 171 | } |
| 172 |
| 173 | buildTypes { |
| 174 | debug { |
| 175 | isDefault true |
| 176 | debuggable true |
| 177 | jniDebuggable true |
| 178 | multiDexEnabled true |
| 179 | zipAlignEnabled true |
| 180 | signingConfig signingConfigs.release |
| 181 | } |
| 182 |
| 183 | release { |
| 184 | debuggable false |
| 185 | jniDebuggable false |
| 186 | minifyEnabled true |
| 187 | shrinkResources true |
| 188 | multiDexEnabled true |
| 189 | zipAlignEnabled true |
| 190 | proguardFiles getDefaultProguardFile("proguard-android-optimize.txt"), "proguard-rules.pro" |
| 191 | matchingFallbacks = ["release", "debug"] |
| 192 | signingConfig signingConfigs.release |
| 193 | } |
| 194 | } |
| 195 |
| 196 | sourceSets { |
| 197 |
| 198 | main { |
| 199 | assets.srcDirs = ["src/main/assets"] |
| 200 | } |
| 201 |
| 202 | debug { |
| 203 | java { |
| 204 | srcDirs "src/main/java" |
| 205 | } |
| 206 | jniLibs { |
| 207 | srcDir "src/main/libs" |
| 208 | } |
| 209 | } |
| 210 |
| 211 | release { |
| 212 | java { |
| 213 | srcDirs "src/main/java" |
| 214 | } |
| 215 | jniLibs { |
| 216 | srcDir "src/main/libs" |
| 217 | } |
| 218 | } |
| 219 | } |
| 220 |
| 221 | flavorDimensions "version" |
| 222 |
| 223 | tasks.configureEach { task -> |
| 224 | if (((task.name.endsWith("Ndk") || task.name.startsWith("generateJsonModel") || task.name.startsWith("externalNativeBuild"))) && !task.name.contains("Debug")) { |
| 225 | task.enabled = false |
| 226 | } |
| 227 | if (task.name.contains("uploadCrashlyticsMappingFile")) { |
| 228 | enabled = false |
| 229 | } |
| 230 | if (disableCMakeRelWithDebInfo && task.name.contains("CMakeRelWithDebInfo")) { |
| 231 | enabled = false |
| 232 | } |
| 233 | } |
| 234 |
| 235 | applicationVariants.configureEach { variant -> |
| 236 | variant.outputs.configureEach { output -> |
| 237 | String gramName = "Nagram" |
| 238 | String first = String.format("%s-v%s(%s)", gramName, versionName, versionCode) |
| 239 | String name = outputFileName.replace("TMessagesProj", first) |
| 240 | name = name.replace("-release", "") |
| 241 | outputFileName = name |
| 242 | } |
| 243 | } |
| 244 |
| 245 | } |
| 246 |
| 247 | def fcmVersion = "23.4.1" |
| 248 | def crashlyticsVersion = "18.6.2" |
| 249 | def playCoreVersion = "1.10.3" |
| 250 |
| 251 | dependencies { |
| 252 | implementation 'androidx.fragment:fragment:1.2.0' |
| 253 | implementation "androidx.core:core-ktx:1.10.1" |
| 254 | implementation "androidx.palette:palette-ktx:1.0.0" |
| 255 | implementation "androidx.exifinterface:exifinterface:1.3.7" |
| 256 | implementation "androidx.dynamicanimation:dynamicanimation:1.0.0" |
| 257 | implementation "androidx.multidex:multidex:2.0.1" |
| 258 | implementation "androidx.sharetarget:sharetarget:1.2.0" |
| 259 | implementation "androidx.interpolator:interpolator:1.0.0" |
| 260 | implementation 'androidx.biometric:biometric:1.1.0' |
| 261 |
| 262 | implementation ('com.google.android.gms:play-services-cast-framework:21.4.0') { |
| 263 | exclude group: 'androidx.recyclerview', module: "recyclerview" |
| 264 | } |
| 265 | implementation ("androidx.mediarouter:mediarouter:1.7.0") { |
| 266 | exclude group: 'androidx.recyclerview', module: "recyclerview" |
| 267 | } |
| 268 | implementation 'org.nanohttpd:nanohttpd:2.3.1' |
| 269 |
| 270 | compileOnly 'org.checkerframework:checker-qual:2.5.2' |
| 271 | compileOnly 'org.checkerframework:checker-compat-qual:2.5.0' |
| 272 | implementation "com.google.firebase:firebase-messaging:$fcmVersion" |
| 273 | implementation "com.google.firebase:firebase-crashlytics:$crashlyticsVersion" |
| 274 | implementation 'com.google.android.gms:play-services-vision:20.1.3' |
| 275 | implementation 'com.google.android.gms:play-services-maps:18.1.0' |
| 276 | implementation 'com.google.android.gms:play-services-auth:20.4.0' |
| 277 | implementation 'com.google.android.gms:play-services-vision:20.1.3' |
| 278 | implementation 'com.google.android.gms:play-services-wearable:18.0.0' |
| 279 | implementation 'com.google.android.gms:play-services-location:21.0.1' |
| 280 | implementation 'com.google.android.gms:play-services-wallet:19.1.0' |
| 281 | implementation "com.googlecode.mp4parser:isoparser:1.0.6" |
| 282 | implementation 'com.stripe:stripe-android:2.0.2' |
| 283 | // add for auto translate |
| 284 | implementation 'com.google.mlkit:language-id:17.0.6' |
| 285 | implementation 'com.android.billingclient:billing:7.1.1' |
| 286 | implementation 'com.google.code.gson:gson:2.11.0' |
| 287 | implementation 'com.google.guava:guava:31.1-android' |
| 288 | implementation 'com.google.android.play:integrity:1.3.0' |
| 289 | implementation 'com.google.android.gms:play-services-safetynet:18.0.1' |
| 290 |
| 291 | implementation 'com.google.android.gms:play-services-mlkit-subject-segmentation:16.0.0-beta1' |
| 292 | implementation 'com.google.android.gms:play-services-mlkit-image-labeling:16.0.8' |
| 293 |
| 294 | // constraints { |
| 295 | // implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") { |
| 296 | // because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib") |
| 297 | // } |
| 298 | implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") { |
| 299 | because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib") |
| 300 | } |
| 301 | // } |
| 302 | implementation 'com.google.android.recaptcha:recaptcha:18.4.0' |
| 303 |
| 304 | testImplementation "junit:junit:4.13.2" |
| 305 | testImplementation "androidx.test:core:1.5.0" |
| 306 | testImplementation "org.robolectric:robolectric:4.5.1" |
| 307 |
| 308 | coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:2.1.5' |
| 309 | } |
| 310 | dependencies { |
| 311 | implementation "androidx.browser:browser:1.8.0" |
| 312 | implementation "androidx.viewpager:viewpager:1.0.0" |
| 313 | implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.8.0" |
| 314 | // OSM |
| 315 | implementation "org.osmdroid:osmdroid-android:6.1.10" |
| 316 | // okhttp |
| 317 | implementation "com.squareup.okhttp3:okhttp:5.0.0-alpha.10" |
| 318 | implementation 'com.neovisionaries:nv-websocket-client:2.14' |
| 319 | implementation 'dnsjava:dnsjava:3.4.1' |
| 320 |
| 321 | implementation "cn.hutool:hutool-core:5.7.13" |
| 322 | implementation "cn.hutool:hutool-crypto:5.7.13" |
| 323 | implementation 'cn.hutool:hutool-http:5.7.5' |
| 324 | implementation "com.jakewharton:process-phoenix:2.1.2" |
| 325 | // openpgp |
| 326 | implementation project(":openpgp-api") |
| 327 |
| 328 | compileOnly fileTree("libs") |
| 329 |
| 330 | compileOnly "com.google.android.play:core:$playCoreVersion" |
| 331 | // add for undo and redo |
| 332 | implementation 'org.lsposed.hiddenapibypass:hiddenapibypass:5.1' |
| 333 | // add splash screen |
| 334 | implementation("androidx.core:core-splashscreen:1.0.1") |
| 335 | // add for emoji |
| 336 | implementation 'com.jaredrummler:truetypeparser-light:1.0.0' |
| 337 | // add for up |
| 338 | implementation 'org.unifiedpush.android:connector:2.5.0' |
| 339 | } |
| 340 |
| 341 | apply plugin: "com.google.gms.google-services" |
| 342 | apply plugin: "com.google.firebase.crashlytics" |
| 343 |
| 344 | android { |
| 345 | compileSdkVersion 35 |
| 346 | buildToolsVersion '35.0.0' |
| 347 | ndkVersion "21.4.7075529" // 26.3.11579264 |
| 348 |
| 349 |
| 350 | packagingOptions { |
| 351 | jniLibs { |
| 352 | excludes += ['/fabric/**', '/META-INF/native-image/**'] |
| 353 | useLegacyPackaging true |
| 354 | } |
| 355 | resources { |
| 356 | excludes += ['/fabric/**', '/META-INF/*.version', '/META-INF/*.kotlin_module', '/META-INF/native-image/**', '/builddef.lst', '/*.txt', '/DebugProbesKt.bin', '/okhttp3/internal/publicsuffix/NOTICE'] |
| 357 | } |
| 358 |
| 359 | def lib = "libtmessages.*.so" |
| 360 | pickFirst "lib/armeabi-v7a/$lib" |
| 361 | pickFirst "lib/arm64-v8a/$lib" |
| 362 | } |
| 363 | namespace "org.telegram.messenger" |
| 364 | lint { |
| 365 | disable 'MissingTranslation', 'ExtraTranslation', 'BlockedPrivateApi' |
| 366 | } |
| 367 | buildFeatures { |
| 368 | buildConfig true |
| 369 | } |
| 370 |
| 371 | tasks.configureEach { task -> |
| 372 | if (task.name.startsWith("uploadCrashlyticsMappingFile")) { |
| 373 | task.enabled = false |
| 374 | } else if (task.name.contains("Crashlytics") && task.name.contains("NoGcm")) { |
| 375 | task.enabled = false |
| 376 | } else if (task.name.endsWith("GoogleServices") && task.name.contains("NoGcm")) { |
| 377 | task.enabled = false |
| 378 | } else if (task.name.contains("buildCMakeDebug") && nagram_build_args != null && nagram_build_args.contains("skip_buildCMakeDebug")) { |
| 379 | task.enabled = false |
| 380 | } |
| 381 | } |
| 382 |
| 383 | } |
| 384 |
| 385 | sentry { |
| 386 | // Disables or enables debug log output, e.g. for for sentry-cli. |
| 387 | // Default is disabled. |
| 388 | debug = false |
| 389 |
| 390 | // The slug of the Sentry organization to use for uploading proguard mappings/source contexts. |
| 391 | org = "pagermaid" |
| 392 |
| 393 | // The slug of the Sentry project to use for uploading proguard mappings/source contexts. |
| 394 | projectName = "nagram" |
| 395 |
| 396 | // The authentication token to use for uploading proguard mappings/source contexts. |
| 397 | // WARNING: Do not expose this token in your build.gradle files, but rather set an environment |
| 398 | // variable and read it into this property. |
| 399 | authToken = sentry_token |
| 400 |
| 401 | // The url of your Sentry instance. If you're using SAAS (not self hosting) you do not have to |
| 402 | // set this. If you are self hosting you can set your URL here |
| 403 | url = null |
| 404 |
| 405 | // Disables or enables the handling of Proguard mapping for Sentry. |
| 406 | // If enabled the plugin will generate a UUID and will take care of |
| 407 | // uploading the mapping to Sentry. If disabled, all the logic |
| 408 | // related to proguard mapping will be excluded. |
| 409 | // Default is enabled. |
| 410 | includeProguardMapping = sentry_upload |
| 411 |
| 412 | // Whether the plugin should attempt to auto-upload the mapping file to Sentry or not. |
| 413 | // If disabled the plugin will run a dry-run and just generate a UUID. |
| 414 | // The mapping file has to be uploaded manually via sentry-cli in this case. |
| 415 | // Default is enabled. |
| 416 | autoUploadProguardMapping = sentry_upload |
| 417 |
| 418 | // Experimental flag to turn on support for GuardSquare's tools integration (Dexguard and External Proguard). |
| 419 | // If enabled, the plugin will try to consume and upload the mapping file produced by Dexguard and External Proguard. |
| 420 | // Default is disabled. |
| 421 | dexguardEnabled = false |
| 422 |
| 423 | // Disables or enables the automatic configuration of Native Symbols |
| 424 | // for Sentry. This executes sentry-cli automatically so |
| 425 | // you don't need to do it manually. |
| 426 | // Default is disabled. |
| 427 | uploadNativeSymbols = sentry_upload |
| 428 |
| 429 | // Whether the plugin should attempt to auto-upload the native debug symbols to Sentry or not. |
| 430 | // If disabled the plugin will run a dry-run. |
| 431 | // Default is enabled. |
| 432 | autoUploadNativeSymbols = sentry_upload |
| 433 |
| 434 | // Does or doesn't include the source code of native code for Sentry. |
| 435 | // This executes sentry-cli with the --include-sources param. automatically so |
| 436 | // you don't need to do it manually. |
| 437 | // This option has an effect only when [uploadNativeSymbols] is enabled. |
| 438 | // Default is disabled. |
| 439 | includeNativeSources = false |
| 440 |
| 441 | // Generates a JVM (Java, Kotlin, etc.) source bundle and uploads your source code to Sentry. |
| 442 | // This enables source context, allowing you to see your source |
| 443 | // code as part of your stack traces in Sentry. |
| 444 | includeSourceContext = sentry_upload |
| 445 |
| 446 | // Configure additional directories to be included in the source bundle which is used for |
| 447 | // source context. The directories should be specified relative to the Gradle module/project's |
| 448 | // root. For example, if you have a custom source set alongside 'main', the parameter would be |
| 449 | // 'src/custom/java'. |
| 450 | additionalSourceDirsForSourceContext = [] |
| 451 |
| 452 | // Enable or disable the tracing instrumentation. |
| 453 | // Does auto instrumentation for specified features through bytecode manipulation. |
| 454 | // Default is enabled. |
| 455 | tracingInstrumentation { |
| 456 | enabled = true |
| 457 |
| 458 | // Specifies a set of instrumentation features that are eligible for bytecode manipulation. |
| 459 | // Defaults to all available values of InstrumentationFeature enum class. |
| 460 | features = [InstrumentationFeature.DATABASE, InstrumentationFeature.FILE_IO, InstrumentationFeature.OKHTTP, InstrumentationFeature.COMPOSE] |
| 461 |
| 462 | // Enable or disable logcat instrumentation through bytecode manipulation. |
| 463 | // Default is enabled. |
| 464 | logcat { |
| 465 | enabled = true |
| 466 |
| 467 | // Specifies a minimum log level for the logcat breadcrumb logging. |
| 468 | // Defaults to LogcatLevel.WARNING. |
| 469 | minLevel = LogcatLevel.WARNING |
| 470 | } |
| 471 |
| 472 | // The set of glob patterns to exclude from instrumentation. Classes matching any of these |
| 473 | // patterns in the project's sources and dependencies JARs won't be instrumented by the Sentry |
| 474 | // Gradle plugin. |
| 475 | // |
| 476 | // Don't include the file extension. Filtering is done on compiled classes and |
| 477 | // the .class suffix isn't included in the pattern matching. |
| 478 | // |
| 479 | // Example usage: |
| 480 | // ``` |
| 481 | // excludes = ['com/example/donotinstrument/**', '**/*Test'] |
| 482 | // ``` |
| 483 | // |
| 484 | // Only supported when using Android Gradle plugin (AGP) version 7.4.0 and above. |
| 485 | excludes = [] |
| 486 | } |
| 487 |
| 488 | // Enable auto-installation of Sentry components (sentry-android SDK and okhttp, timber and fragment integrations). |
| 489 | // Default is enabled. |
| 490 | // Only available v3.1.0 and above. |
| 491 | autoInstallation { |
| 492 | enabled = true |
| 493 |
| 494 | // Specifies a version of the sentry-android SDK and fragment, timber and okhttp integrations. |
| 495 | // |
| 496 | // This is also useful, when you have the sentry-android SDK already included into a transitive dependency/module and want to |
| 497 | // align integration versions with it (if it's a direct dependency, the version will be inferred). |
| 498 | // |
| 499 | // NOTE: if you have a higher version of the sentry-android SDK or integrations on the classpath, this setting will have no effect |
| 500 | // as Gradle will resolve it to the latest version. |
| 501 | // |
| 502 | // Defaults to the latest published Sentry version. |
| 503 | sentryVersion = '7.8.0' |
| 504 | } |
| 505 |
| 506 | // Disables or enables dependencies metadata reporting for Sentry. |
| 507 | // If enabled, the plugin will collect external dependencies and |
| 508 | // upload them to Sentry as part of events. If disabled, all the logic |
| 509 | // related to the dependencies metadata report will be excluded. |
| 510 | // |
| 511 | // Default is enabled. |
| 512 | includeDependenciesReport = true |
| 513 |
| 514 | // Whether the plugin should send telemetry data to Sentry. |
| 515 | // If disabled the plugin won't send telemetry data. |
| 516 | // This is auto disabled if running against a self hosted instance of Sentry. |
| 517 | // Default is enabled. |
| 518 | telemetry = true |
| 519 | } |
| 520 |