| 7 |
| google() |
| 8 | jcenter() |
| 9 | } |
| 10 |
| 11 | configurations { |
| 12 | compile.exclude module: 'support-v4' |
| 13 | } |
| 14 |
| 15 | configurations.all { |
| 16 | exclude group: 'com.google.firebase', module: 'firebase-core' |
| 17 | } |
| 18 |
| 19 | dependencies { |
| 20 | implementation 'androidx.core:core:1.1.0-beta01' |
| 21 | implementation 'androidx.palette:palette:1.0.0' |
| 22 | implementation 'androidx.exifinterface:exifinterface:1.2.0' |
| 23 | implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0' |
| 24 | implementation 'com.android.support:multidex:1.0.3' |
| 25 |
| 26 | compileOnly 'org.checkerframework:checker-qual:2.5.2' |
| 27 | compileOnly 'org.checkerframework:checker-compat-qual:2.5.0' |
| 28 | implementation 'com.google.firebase:firebase-messaging:20.1.6' |
| 29 | implementation 'com.google.firebase:firebase-config:19.1.4' |
| 30 | implementation 'com.google.android.gms:play-services-maps:17.0.0' |
| 31 | implementation 'com.google.android.gms:play-services-auth:17.0.0' |
| 32 | implementation 'com.google.android.gms:play-services-vision:16.2.0' |
| 33 | implementation 'com.google.android.gms:play-services-wearable:17.0.0' |
| 34 | implementation 'com.google.android.gms:play-services-location:17.0.0' |
| 35 | implementation "com.microsoft.appcenter:appcenter-distribute:3.1.0" |
| 36 | implementation "com.microsoft.appcenter:appcenter-crashes:3.1.0" |
| 37 | implementation 'com.googlecode.mp4parser:isoparser:1.0.6' |
| 38 | implementation 'com.stripe:stripe-android:2.0.2' |
| 39 | implementation files('libs/libgsaverification-client.aar') |
| 40 | } |
| 41 |
| 42 | android { |
| 43 | compileSdkVersion 29 |
| 44 | buildToolsVersion '29.0.3' |
| 45 | ndkVersion "20.0.5594570" |
| 46 |
| 47 | defaultConfig.applicationId = "org.telegram.messenger" |
| 48 |
| 49 | sourceSets.main.jniLibs.srcDirs = ['./jni/'] |
| 50 |
| 51 | externalNativeBuild { |
| 52 | ndkBuild { |
| 53 | path "jni/Android.mk" |
| 54 | } |
| 55 | } |
| 56 |
| 57 | lintOptions { |
| 58 | disable 'MissingTranslation' |
| 59 | disable 'ExtraTranslation' |
| 60 | disable 'BlockedPrivateApi' |
| 61 | } |
| 62 |
| 63 | dexOptions { |
| 64 | jumboMode = true |
| 65 | } |
| 66 |
| 67 | compileOptions { |
| 68 | sourceCompatibility JavaVersion.VERSION_1_8 |
| 69 | targetCompatibility JavaVersion.VERSION_1_8 |
| 70 | } |
| 71 |
| 72 | signingConfigs { |
| 73 | debug { |
| 74 | storeFile file("config/release.keystore") |
| 75 | storePassword RELEASE_STORE_PASSWORD |
| 76 | keyAlias RELEASE_KEY_ALIAS |
| 77 | keyPassword RELEASE_KEY_PASSWORD |
| 78 | } |
| 79 |
| 80 | release { |
| 81 | storeFile file("config/release.keystore") |
| 82 | storePassword RELEASE_STORE_PASSWORD |
| 83 | keyAlias RELEASE_KEY_ALIAS |
| 84 | keyPassword RELEASE_KEY_PASSWORD |
| 85 | } |
| 86 | } |
| 87 |
| 88 | buildTypes { |
| 89 | debug { |
| 90 | debuggable true |
| 91 | jniDebuggable true |
| 92 | signingConfig signingConfigs.debug |
| 93 | applicationIdSuffix ".beta" |
| 94 | minifyEnabled true |
| 95 | multiDexEnabled true |
| 96 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 97 | } |
| 98 |
| 99 | /*debugAsan { |
| 100 | debuggable true |
| 101 | jniDebuggable true |
| 102 | signingConfig signingConfigs.debug |
| 103 | applicationIdSuffix ".beta" |
| 104 | minifyEnabled true |
| 105 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 106 |
| 107 | packagingOptions { |
| 108 | doNotStrip "**.so" |
| 109 | } |
| 110 |
| 111 | sourceSets { |
| 112 | main { |
| 113 | jniLibs { |
| 114 | srcDir { |
| 115 | 'jniLibs' |
| 116 | } |
| 117 | } |
| 118 | resources { |
| 119 | srcDir { |
| 120 | 'jniRes' |
| 121 | } |
| 122 | } |
| 123 | } |
| 124 | } |
| 125 | }*/ |
| 126 |
| 127 | debugMultidex { |
| 128 | initWith debug |
| 129 | minifyEnabled false |
| 130 | multiDexEnabled true |
| 131 | } |
| 132 |
| 133 | HA { |
| 134 | debuggable false |
| 135 | jniDebuggable false |
| 136 | signingConfig signingConfigs.debug |
| 137 | applicationIdSuffix ".beta" |
| 138 | minifyEnabled true |
| 139 | multiDexEnabled true |
| 140 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 141 | } |
| 142 |
| 143 | release { |
| 144 | debuggable false |
| 145 | jniDebuggable false |
| 146 | signingConfig signingConfigs.release |
| 147 | minifyEnabled true |
| 148 | shrinkResources false |
| 149 | multiDexEnabled true |
| 150 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 151 | } |
| 152 | } |
| 153 |
| 154 | sourceSets.debug { |
| 155 | manifest.srcFile 'config/debug/AndroidManifest.xml' |
| 156 | } |
| 157 |
| 158 | /*sourceSets.debugAsan { |
| 159 | manifest.srcFile 'config/debug/AndroidManifest.xml' |
| 160 | }*/ |
| 161 |
| 162 | sourceSets.debugMultidex { |
| 163 | manifest.srcFile 'config/debug/AndroidManifest.xml' |
| 164 | java.srcDirs = ['src/multidex/java'] |
| 165 | } |
| 166 |
| 167 | sourceSets.HA { |
| 168 | manifest.srcFile 'config/debug/AndroidManifest.xml' |
| 169 | } |
| 170 |
| 171 | sourceSets.release { |
| 172 | manifest.srcFile 'config/release/AndroidManifest.xml' |
| 173 | } |
| 174 |
| 175 | flavorDimensions "minApi" |
| 176 |
| 177 | productFlavors { |
| 178 | armv7 { |
| 179 | ndk { |
| 180 | abiFilters "armeabi-v7a" |
| 181 | } |
| 182 | ext { |
| 183 | abiVersionCode = 1 |
| 184 | } |
| 185 | } |
| 186 | x86 { |
| 187 | ndk { |
| 188 | abiFilters "x86" |
| 189 | } |
| 190 | ext { |
| 191 | abiVersionCode = 2 |
| 192 | } |
| 193 | } |
| 194 | armv7_SDK23 { |
| 195 | ndk { |
| 196 | abiFilters "armeabi-v7a" |
| 197 | } |
| 198 | sourceSets.debug { |
| 199 | manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml' |
| 200 | } |
| 201 | sourceSets.release { |
| 202 | manifest.srcFile 'config/release/AndroidManifest_SDK23.xml' |
| 203 | } |
| 204 | minSdkVersion 23 |
| 205 | ext { |
| 206 | abiVersionCode = 3 |
| 207 | } |
| 208 | } |
| 209 | x86_SDK23 { |
| 210 | ndk { |
| 211 | abiFilters "x86" |
| 212 | } |
| 213 | sourceSets.debug { |
| 214 | manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml' |
| 215 | } |
| 216 | sourceSets.release { |
| 217 | manifest.srcFile 'config/release/AndroidManifest_SDK23.xml' |
| 218 | } |
| 219 | minSdkVersion 23 |
| 220 | ext { |
| 221 | abiVersionCode = 4 |
| 222 | } |
| 223 | } |
| 224 | arm64 { |
| 225 | ndk { |
| 226 | abiFilters "arm64-v8a" |
| 227 | } |
| 228 | ext { |
| 229 | abiVersionCode = 5 |
| 230 | } |
| 231 | } |
| 232 | x64 { |
| 233 | ndk { |
| 234 | abiFilters "x86_64" |
| 235 | } |
| 236 | ext { |
| 237 | abiVersionCode = 6 |
| 238 | } |
| 239 | } |
| 240 | arm64_SDK23 { |
| 241 | ndk { |
| 242 | abiFilters "arm64-v8a" |
| 243 | } |
| 244 | sourceSets.debug { |
| 245 | manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml' |
| 246 | } |
| 247 | /*sourceSets.debugAsan { |
| 248 | manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml' |
| 249 | }*/ |
| 250 | sourceSets.release { |
| 251 | manifest.srcFile 'config/release/AndroidManifest_SDK23.xml' |
| 252 | } |
| 253 | minSdkVersion 23 |
| 254 | ext { |
| 255 | abiVersionCode = 7 |
| 256 | } |
| 257 | } |
| 258 | x64_SDK23 { |
| 259 | ndk { |
| 260 | abiFilters "x86_64" |
| 261 | } |
| 262 | sourceSets.debug { |
| 263 | manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml' |
| 264 | } |
| 265 | sourceSets.release { |
| 266 | manifest.srcFile 'config/release/AndroidManifest_SDK23.xml' |
| 267 | } |
| 268 | minSdkVersion 23 |
| 269 | ext { |
| 270 | abiVersionCode = 8 |
| 271 | } |
| 272 | } |
| 273 | afat { |
| 274 | sourceSets.debug { |
| 275 | manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml' |
| 276 | } |
| 277 | /*sourceSets.debugAsan { |
| 278 | manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml' |
| 279 | }*/ |
| 280 | sourceSets.release { |
| 281 | manifest.srcFile 'config/release/AndroidManifest_SDK23.xml' |
| 282 | } |
| 283 | ext { |
| 284 | abiVersionCode = 9 |
| 285 | } |
| 286 | } |
| 287 | } |
| 288 |
| 289 | defaultConfig.versionCode = 1947 |
| 290 |
| 291 | def tgVoipDexFileName = "libtgvoip.dex" |
| 292 | def tgVoipDexClasses = ["AudioRecordJNI", "AudioTrackJNI", "NativeTgVoipDelegate", "NativeTgVoipInstance", "TgVoipNativeLoader", "Resampler", "VLog"] |
| 293 | def tgVoipDexClassesPath = "org/telegram/messenger/voip" |
| 294 | def dxUtilPath = "${sdkDirectory.path}/build-tools/${buildToolsVersion}/dx" |
| 295 |
| 296 | applicationVariants.all { variant -> |
| 297 | variant.outputs.all { output -> |
| 298 | outputFileName = "app.apk" |
| 299 | output.getProcessManifestProvider().get().doLast { |
| 300 | def abiVersion = variant.productFlavors.get(0).abiVersionCode |
| 301 |
| 302 | def outputDir = manifestOutputDirectory |
| 303 | File directory |
| 304 | if (outputDir instanceof File) { |
| 305 | directory = outputDir |
| 306 | } else { |
| 307 | directory = outputDir.get().asFile |
| 308 | } |
| 309 |
| 310 | String manifestPath = directory.toString() + "/AndroidManifest.xml" |
| 311 | def manifestContent = file(manifestPath).getText() |
| 312 |
| 313 | manifestContent = manifestContent.replace(String.format('android:versionCode="%d"', defaultConfig.versionCode), String.format('android:versionCode="%s"', defaultConfig.versionCode * 10 + abiVersion)) |
| 314 | file(manifestPath).write(manifestContent) |
| 315 | } |
| 316 | } |
| 317 |
| 318 | def assembleTgVoipDexTaskName = "assemble${variant.name.capitalize()}TgVoipDex" |
| 319 |
| 320 | task "${assembleTgVoipDexTaskName}" { |
| 321 | doLast { |
| 322 | def sourceDir = (File) android.sourceSets.main.java.srcDirs[0] |
| 323 | def classesDir = "${buildDir}/intermediates/javac/${variant.name}/classes" |
| 324 | def javaDir = "${buildDir}/intermediates/java_tgvoip/${variant.name}/java" |
| 325 | def tgVoipDir = new File(classesDir, tgVoipDexClassesPath) |
| 326 | def javaVoipDirFile = new File(javaDir, tgVoipDexClassesPath) |
| 327 | def tgVoipDexJavaFile = new File(javaVoipDirFile, "TgVoipDex.java") |
| 328 | if (!javaVoipDirFile.exists()) { |
| 329 | javaVoipDirFile.mkdirs() |
| 330 | } |
| 331 | def assetsDirFile = new File(buildDir, "intermediates/merged_assets/${variant.name}/out") |
| 332 | if (!assetsDirFile.exists()) { |
| 333 | assetsDirFile.mkdirs() |
| 334 | } |
| 335 | def tgVoipDexFile = new File(assetsDirFile, tgVoipDexFileName) |
| 336 |
| 337 | def classes = tgVoipDir.list(new FilenameFilter() { |
| 338 | @Override |
| 339 | boolean accept(File dir, String name) { |
| 340 | // handle inner and anonymous classes |
| 341 | return tgVoipDexClasses.any { name == "${it}.class" || name.startsWith("${it}\$") && name.endsWith(".class") } |
| 342 | } |
| 343 | }).collect { "${tgVoipDexClassesPath}/${it}" } |
| 344 |
| 345 | // 1. create libtgvoip.dex |
| 346 | exec { |
| 347 | workingDir classesDir |
| 348 | commandLine([dxUtilPath, "--dex", "--output=${tgVoipDexFile}"] + classes) |
| 349 | } |
| 350 |
| 351 | // 2. remove classes from the main dex |
| 352 | project.delete classes.collect { "${classesDir}/${it}" } |
| 353 |
| 354 | // 3. insert checksum of libtgvoip.dex into TgVoipDex.java |
| 355 | def digest = MessageDigest.getInstance("SHA1") |
| 356 | def fileInputStream = tgVoipDexFile.newInputStream() |
| 357 | def buffer = new byte[4096] |
| 358 | def len |
| 359 | while ((len = fileInputStream.read(buffer)) > 0) { |
| 360 | digest.update(buffer, 0, len) |
| 361 | } |
| 362 | def dexChecksum = new String(Base64.getEncoder().encode(digest.digest())).trim() |
| 363 | tgVoipDexJavaFile.write(new String(new File(sourceDir, "${tgVoipDexClassesPath}/TgVoipDex.java").readBytes()).replace("\$CHECKSUM\$", dexChecksum)) |
| 364 | exec { |
| 365 | commandLine([findJavac(), "-d", classesDir, tgVoipDexJavaFile.absolutePath]) |
| 366 | } |
| 367 | } |
| 368 | } |
| 369 |
| 370 | tasks.findByName("compile${variant.name.capitalize()}JavaWithJavac").finalizedBy(assembleTgVoipDexTaskName) |
| 371 | tasks.findByName("${assembleTgVoipDexTaskName}").mustRunAfter tasks.findByName("merge${variant.name.capitalize()}Assets") |
| 372 | } |
| 373 |
| 374 | variantFilter { variant -> |
| 375 | def names = variant.flavors*.name |
| 376 | if (variant.buildType.name != "release" && !names.contains("afat")) { |
| 377 | setIgnore(true) |
| 378 | } |
| 379 | } |
| 380 |
| 381 | defaultConfig { |
| 382 | minSdkVersion 16 |
| 383 | targetSdkVersion 28 |
| 384 | versionName "6.1.1" |
| 385 |
| 386 | vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi'] |
| 387 |
| 388 | externalNativeBuild { |
| 389 | ndkBuild { |
| 390 | arguments "NDK_APPLICATION_MK:=jni/Application.mk", "APP_PLATFORM:=android-16", "--jobs=8" |
| 391 | abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64" |
| 392 | } |
| 393 | } |
| 394 | } |
| 395 | } |
| 396 |
| 397 | private static File findJavaHome() { |
| 398 | String javaPath = System.getProperty("java.home") |
| 399 | if (javaPath != null) { |
| 400 | File javaBase = new File(javaPath) |
| 401 | if (javaBase.exists()) { |
| 402 | if (javaBase.getName().equalsIgnoreCase("jre") && new File(javaBase.getParentFile(), "bin/java").exists()) { |
| 403 | return javaBase.getParentFile() |
| 404 | } else { |
| 405 | return javaBase |
| 406 | } |
| 407 | } else { |
| 408 | return null |
| 409 | } |
| 410 | } else { |
| 411 | return null |
| 412 | } |
| 413 | } |
| 414 |
| 415 | private static File findJavac() { |
| 416 | File javaHome = findJavaHome() |
| 417 | if (javaHome != null) { |
| 418 | return new File(javaHome, "bin/javac") |
| 419 | } else { |
| 420 | return null |
| 421 | } |
| 422 | } |
| 423 |
| 424 | apply plugin: 'com.google.gms.google-services' |
| 425 |