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