| 7 |
| mavenCentral() |
| 8 | google() |
| 9 | jcenter() |
| 10 | } |
| 11 |
| 12 | configurations { |
| 13 | compile.exclude module: 'support-v4' |
| 14 | } |
| 15 |
| 16 | configurations.all { |
| 17 | exclude group: 'com.google.firebase', module: 'firebase-core' |
| 18 | } |
| 19 |
| 20 | dependencies { |
| 21 | implementation 'androidx.core:core:1.1.0-beta01' |
| 22 | implementation 'androidx.palette:palette:1.0.0' |
| 23 | implementation 'androidx.exifinterface:exifinterface:1.2.0' |
| 24 | implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0' |
| 25 | implementation 'com.android.support:multidex:1.0.3' |
| 26 |
| 27 | compileOnly 'org.checkerframework:checker-qual:2.5.2' |
| 28 | compileOnly 'org.checkerframework:checker-compat-qual:2.5.0' |
| 29 | implementation 'com.google.firebase:firebase-messaging:20.2.0' |
| 30 | implementation 'com.google.android.gms:play-services-maps:17.0.0' |
| 31 | implementation 'com.google.android.gms:play-services-auth:18.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.googlecode.mp4parser:isoparser:1.0.6' |
| 36 | implementation 'com.stripe:stripe-android:2.0.2' |
| 37 | implementation 'com.google.code.gson:gson:2.8.6' |
| 38 | implementation files('libs/libgsaverification-client.aar') |
| 39 | implementation "com.microsoft.appcenter:appcenter-analytics:3.1.0" |
| 40 | } |
| 41 |
| 42 | android { |
| 43 | compileSdkVersion 29 |
| 44 | buildToolsVersion '29.0.3' |
| 45 | ndkVersion "21.1.6352462" |
| 46 |
| 47 | defaultConfig.applicationId = "tw.nekomimi.nekogram" |
| 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 | def keystorePwd = null |
| 74 | def alias = null |
| 75 | def pwd = null |
| 76 | if (project.rootProject.file('local.properties').exists()) { |
| 77 | Properties properties = new Properties() |
| 78 | properties.load(project.rootProject.file('local.properties').newDataInputStream()) |
| 79 | keystorePwd = properties.getProperty("RELEASE_STORE_PASSWORD") |
| 80 | alias = properties.getProperty("RELEASE_KEY_ALIAS") |
| 81 | pwd = properties.getProperty("RELEASE_KEY_PASSWORD") |
| 82 | } |
| 83 | release { |
| 84 | storeFile file("config/release.keystore") |
| 85 | storePassword keystorePwd != null ? keystorePwd : System.getenv("KEYSTORE_PASS") |
| 86 | keyAlias alias != null ? alias : System.getenv("ALIAS_NAME") |
| 87 | keyPassword pwd != null ? pwd : System.getenv("ALIAS_PASS") |
| 88 | } |
| 89 | debug { |
| 90 | storeFile file("config/release.keystore") |
| 91 | storePassword keystorePwd != null ? keystorePwd : System.getenv("KEYSTORE_PASS") |
| 92 | keyAlias alias != null ? alias : System.getenv("ALIAS_NAME") |
| 93 | keyPassword pwd != null ? pwd : System.getenv("ALIAS_PASS") |
| 94 | } |
| 95 | } |
| 96 |
| 97 |
| 98 | buildTypes { |
| 99 | debug { |
| 100 | debuggable true |
| 101 | jniDebuggable true |
| 102 | signingConfig signingConfigs.debug |
| 103 | applicationIdSuffix ".beta" |
| 104 | minifyEnabled true |
| 105 | multiDexEnabled true |
| 106 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 107 | } |
| 108 |
| 109 | /*debugAsan { |
| 110 | debuggable true |
| 111 | jniDebuggable true |
| 112 | signingConfig signingConfigs.debug |
| 113 | applicationIdSuffix ".beta" |
| 114 | minifyEnabled true |
| 115 | multiDexEnabled true |
| 116 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 117 |
| 118 | packagingOptions { |
| 119 | doNotStrip "**.so" |
| 120 | } |
| 121 |
| 122 | sourceSets { |
| 123 | main { |
| 124 | jniLibs { |
| 125 | srcDir { |
| 126 | 'jniLibs' |
| 127 | } |
| 128 | } |
| 129 | resources { |
| 130 | srcDir { |
| 131 | 'jniRes' |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | } |
| 136 | }*/ |
| 137 |
| 138 | HA { |
| 139 | debuggable false |
| 140 | jniDebuggable false |
| 141 | signingConfig signingConfigs.debug |
| 142 | applicationIdSuffix ".beta" |
| 143 | minifyEnabled true |
| 144 | multiDexEnabled true |
| 145 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 146 | } |
| 147 |
| 148 | release { |
| 149 | debuggable false |
| 150 | jniDebuggable false |
| 151 | signingConfig signingConfigs.release |
| 152 | minifyEnabled true |
| 153 | shrinkResources false |
| 154 | multiDexEnabled true |
| 155 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 156 | } |
| 157 | } |
| 158 |
| 159 | sourceSets.debug { |
| 160 | manifest.srcFile 'config/debug/AndroidManifest.xml' |
| 161 | } |
| 162 |
| 163 | /*sourceSets.debugAsan { |
| 164 | manifest.srcFile 'config/debug/AndroidManifest.xml' |
| 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 = 10 * 1988 |
| 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 | if (OperatingSystem.current().isWindows()) { |
| 296 | dxUtilPath = "${sdkDirectory.path}\\build-tools\\${buildToolsVersion}\\dx.bat" |
| 297 | } |
| 298 |
| 299 | applicationVariants.all { variant -> |
| 300 | variant.outputs.all { output -> |
| 301 | outputFileName = "Nekogram-${defaultConfig.versionName}-${defaultConfig.versionCode / 10}-${variant.productFlavors.get(0).name}-${buildType.name}.apk" |
| 302 | output.getProcessManifestProvider().get().doLast { |
| 303 | def abiVersion = variant.productFlavors.get(0).abiVersionCode |
| 304 |
| 305 | def outputDir = manifestOutputDirectory |
| 306 | File directory |
| 307 | if (outputDir instanceof File) { |
| 308 | directory = outputDir |
| 309 | } else { |
| 310 | directory = outputDir.get().asFile |
| 311 | } |
| 312 |
| 313 | String manifestPath = directory.toString() + "/AndroidManifest.xml" |
| 314 | def manifestContent = file(manifestPath).getText() |
| 315 |
| 316 | manifestContent = manifestContent.replace(String.format('android:versionCode="%d"', defaultConfig.versionCode), String.format('android:versionCode="%s"', defaultConfig.versionCode + abiVersion)) |
| 317 | file(manifestPath).write(manifestContent) |
| 318 | } |
| 319 | } |
| 320 |
| 321 | def assembleTgVoipDexTaskName = "assemble${variant.name.capitalize()}TgVoipDex" |
| 322 |
| 323 | task "${assembleTgVoipDexTaskName}" { |
| 324 | doLast { |
| 325 | def sourceDir = (File) android.sourceSets.main.java.srcDirs[0] |
| 326 | def classesDir = "${buildDir}/intermediates/javac/${variant.name}/classes" |
| 327 | def javaDir = "${buildDir}/intermediates/java_tgvoip/${variant.name}/java" |
| 328 | def tgVoipDir = new File(classesDir, tgVoipDexClassesPath) |
| 329 | def javaVoipDirFile = new File(javaDir, tgVoipDexClassesPath) |
| 330 | def tgVoipDexJavaFile = new File(javaVoipDirFile, "TgVoipDex.java") |
| 331 | if (!javaVoipDirFile.exists()) { |
| 332 | javaVoipDirFile.mkdirs() |
| 333 | } |
| 334 | def assetsDirFile = new File(buildDir, "intermediates/merged_assets/${variant.name}/out") |
| 335 | if (!assetsDirFile.exists()) { |
| 336 | assetsDirFile.mkdirs() |
| 337 | } |
| 338 | def tgVoipDexFile = new File(assetsDirFile, tgVoipDexFileName) |
| 339 |
| 340 | def classes = tgVoipDir.list(new FilenameFilter() { |
| 341 | @Override |
| 342 | boolean accept(File dir, String name) { |
| 343 | // handle inner and anonymous classes |
| 344 | return tgVoipDexClasses.any { name == "${it}.class" || name.startsWith("${it}\$") && name.endsWith(".class") } |
| 345 | } |
| 346 | }).collect { "${tgVoipDexClassesPath}/${it}" } |
| 347 |
| 348 | // 1. create libtgvoip.dex |
| 349 | exec { |
| 350 | workingDir classesDir |
| 351 | commandLine([dxUtilPath, "--dex", "--output=${tgVoipDexFile}"] + classes) |
| 352 | } |
| 353 |
| 354 | // 2. remove classes from the main dex |
| 355 | project.delete classes.collect { "${classesDir}/${it}" } |
| 356 |
| 357 | // 3. insert checksum of libtgvoip.dex into TgVoipDex.java |
| 358 | def digest = MessageDigest.getInstance("SHA1") |
| 359 | def fileInputStream = tgVoipDexFile.newInputStream() |
| 360 | def buffer = new byte[4096] |
| 361 | def len |
| 362 | while ((len = fileInputStream.read(buffer)) > 0) { |
| 363 | digest.update(buffer, 0, len) |
| 364 | } |
| 365 | def dexChecksum = new String(Base64.getEncoder().encode(digest.digest())).trim() |
| 366 | tgVoipDexJavaFile.write(new String(new File(sourceDir, "${tgVoipDexClassesPath}/TgVoipDex.java").readBytes()).replace("\$CHECKSUM\$", dexChecksum)) |
| 367 | exec { |
| 368 | commandLine([findJavac(), "-d", classesDir, tgVoipDexJavaFile.absolutePath]) |
| 369 | } |
| 370 | } |
| 371 | } |
| 372 |
| 373 | tasks.findByName("compile${variant.name.capitalize()}JavaWithJavac").finalizedBy(assembleTgVoipDexTaskName) |
| 374 | tasks.findByName("${assembleTgVoipDexTaskName}").mustRunAfter tasks.findByName("merge${variant.name.capitalize()}Assets") |
| 375 | } |
| 376 |
| 377 | variantFilter { variant -> |
| 378 | def names = variant.flavors*.name |
| 379 | if (variant.buildType.name != "release" && !names.contains("afat")) { |
| 380 | setIgnore(true) |
| 381 | } |
| 382 | } |
| 383 |
| 384 | defaultConfig { |
| 385 | minSdkVersion 16 |
| 386 | targetSdkVersion 28 |
| 387 | versionName "6.2.0" |
| 388 |
| 389 | vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi'] |
| 390 |
| 391 | externalNativeBuild { |
| 392 | ndkBuild { |
| 393 | arguments "NDK_APPLICATION_MK:=jni/Application.mk", "APP_PLATFORM:=android-16", "--jobs=8", "LOCAL_ARM_NEON:=false" |
| 394 | abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64" |
| 395 | } |
| 396 | } |
| 397 | } |
| 398 |
| 399 | bundle { |
| 400 | language { |
| 401 | enableSplit = false |
| 402 | } |
| 403 | } |
| 404 | } |
| 405 |
| 406 | private static File findJavaHome() { |
| 407 | String javaPath = System.getProperty("java.home") |
| 408 | if (javaPath != null) { |
| 409 | File javaBase = new File(javaPath) |
| 410 | if (javaBase.exists()) { |
| 411 | if (javaBase.getName().equalsIgnoreCase("jre") && new File(javaBase.getParentFile(), "bin/java").exists()) { |
| 412 | return javaBase.getParentFile() |
| 413 | } else { |
| 414 | return javaBase |
| 415 | } |
| 416 | } else { |
| 417 | return null |
| 418 | } |
| 419 | } else { |
| 420 | return null |
| 421 | } |
| 422 | } |
| 423 |
| 424 | private static File findJavac() { |
| 425 | File javaHome = findJavaHome() |
| 426 | if (javaHome != null) { |
| 427 | if (OperatingSystem.current().isWindows()) { |
| 428 | return new File(javaHome.getParent(), "bin/javac.exe") |
| 429 | } else { |
| 430 | return new File(javaHome, "bin/javac") |
| 431 | } |
| 432 | } else { |
| 433 | return null |
| 434 | } |
| 435 | } |
| 436 |
| 437 | apply plugin: 'com.google.gms.google-services' |
| 438 |