| 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.1.7' |
| 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.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-optimize.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 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 116 |
| 117 | packagingOptions { |
| 118 | doNotStrip "**.so" |
| 119 | } |
| 120 |
| 121 | sourceSets { |
| 122 | main { |
| 123 | jniLibs { |
| 124 | srcDir { |
| 125 | 'jniLibs' |
| 126 | } |
| 127 | } |
| 128 | resources { |
| 129 | srcDir { |
| 130 | 'jniRes' |
| 131 | } |
| 132 | } |
| 133 | } |
| 134 | } |
| 135 | }*/ |
| 136 |
| 137 | debugMultidex { |
| 138 | initWith debug |
| 139 | minifyEnabled false |
| 140 | multiDexEnabled true |
| 141 | } |
| 142 |
| 143 | HA { |
| 144 | debuggable false |
| 145 | jniDebuggable false |
| 146 | signingConfig signingConfigs.debug |
| 147 | applicationIdSuffix ".beta" |
| 148 | minifyEnabled true |
| 149 | multiDexEnabled true |
| 150 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 151 | } |
| 152 |
| 153 | release { |
| 154 | debuggable false |
| 155 | jniDebuggable false |
| 156 | signingConfig signingConfigs.release |
| 157 | minifyEnabled true |
| 158 | shrinkResources true |
| 159 | multiDexEnabled true |
| 160 | proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' |
| 161 | } |
| 162 | } |
| 163 |
| 164 | sourceSets.debug { |
| 165 | manifest.srcFile 'config/debug/AndroidManifest.xml' |
| 166 | } |
| 167 |
| 168 | /*sourceSets.debugAsan { |
| 169 | manifest.srcFile 'config/debug/AndroidManifest.xml' |
| 170 | }*/ |
| 171 |
| 172 | sourceSets.debugMultidex { |
| 173 | manifest.srcFile 'config/debug/AndroidManifest.xml' |
| 174 | java.srcDirs = ['src/multidex/java'] |
| 175 | } |
| 176 |
| 177 | sourceSets.HA { |
| 178 | manifest.srcFile 'config/debug/AndroidManifest.xml' |
| 179 | } |
| 180 |
| 181 | sourceSets.release { |
| 182 | manifest.srcFile 'config/release/AndroidManifest.xml' |
| 183 | } |
| 184 |
| 185 | flavorDimensions "minApi" |
| 186 |
| 187 | productFlavors { |
| 188 | armv7 { |
| 189 | ndk { |
| 190 | abiFilters "armeabi-v7a" |
| 191 | } |
| 192 | ext { |
| 193 | abiVersionCode = 1 |
| 194 | } |
| 195 | } |
| 196 | x86 { |
| 197 | ndk { |
| 198 | abiFilters "x86" |
| 199 | } |
| 200 | ext { |
| 201 | abiVersionCode = 2 |
| 202 | } |
| 203 | } |
| 204 | armv7_SDK23 { |
| 205 | ndk { |
| 206 | abiFilters "armeabi-v7a" |
| 207 | } |
| 208 | sourceSets.debug { |
| 209 | manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml' |
| 210 | } |
| 211 | sourceSets.release { |
| 212 | manifest.srcFile 'config/release/AndroidManifest_SDK23.xml' |
| 213 | } |
| 214 | minSdkVersion 23 |
| 215 | ext { |
| 216 | abiVersionCode = 3 |
| 217 | } |
| 218 | } |
| 219 | x86_SDK23 { |
| 220 | ndk { |
| 221 | abiFilters "x86" |
| 222 | } |
| 223 | sourceSets.debug { |
| 224 | manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml' |
| 225 | } |
| 226 | sourceSets.release { |
| 227 | manifest.srcFile 'config/release/AndroidManifest_SDK23.xml' |
| 228 | } |
| 229 | minSdkVersion 23 |
| 230 | ext { |
| 231 | abiVersionCode = 4 |
| 232 | } |
| 233 | } |
| 234 | arm64 { |
| 235 | ndk { |
| 236 | abiFilters "arm64-v8a" |
| 237 | } |
| 238 | ext { |
| 239 | abiVersionCode = 5 |
| 240 | } |
| 241 | } |
| 242 | x64 { |
| 243 | ndk { |
| 244 | abiFilters "x86_64" |
| 245 | } |
| 246 | ext { |
| 247 | abiVersionCode = 6 |
| 248 | } |
| 249 | } |
| 250 | arm64_SDK23 { |
| 251 | ndk { |
| 252 | abiFilters "arm64-v8a" |
| 253 | } |
| 254 | sourceSets.debug { |
| 255 | manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml' |
| 256 | } |
| 257 | /*sourceSets.debugAsan { |
| 258 | manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml' |
| 259 | }*/ |
| 260 | sourceSets.release { |
| 261 | manifest.srcFile 'config/release/AndroidManifest_SDK23.xml' |
| 262 | } |
| 263 | minSdkVersion 23 |
| 264 | ext { |
| 265 | abiVersionCode = 7 |
| 266 | } |
| 267 | } |
| 268 | x64_SDK23 { |
| 269 | ndk { |
| 270 | abiFilters "x86_64" |
| 271 | } |
| 272 | sourceSets.debug { |
| 273 | manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml' |
| 274 | } |
| 275 | sourceSets.release { |
| 276 | manifest.srcFile 'config/release/AndroidManifest_SDK23.xml' |
| 277 | } |
| 278 | minSdkVersion 23 |
| 279 | ext { |
| 280 | abiVersionCode = 8 |
| 281 | } |
| 282 | } |
| 283 | afat { |
| 284 | sourceSets.debug { |
| 285 | manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml' |
| 286 | } |
| 287 | /*sourceSets.debugAsan { |
| 288 | manifest.srcFile 'config/debug/AndroidManifest_SDK23.xml' |
| 289 | }*/ |
| 290 | sourceSets.release { |
| 291 | manifest.srcFile 'config/release/AndroidManifest_SDK23.xml' |
| 292 | } |
| 293 | ext { |
| 294 | abiVersionCode = 9 |
| 295 | } |
| 296 | } |
| 297 | } |
| 298 |
| 299 | defaultConfig.versionCode = 10 * 1955 |
| 300 |
| 301 | def tgVoipDexFileName = "libtgvoip.dex" |
| 302 | def tgVoipDexClasses = ["AudioRecordJNI", "AudioTrackJNI", "NativeTgVoipDelegate", "NativeTgVoipInstance", "TgVoipNativeLoader", "Resampler", "VLog"] |
| 303 | def tgVoipDexClassesPath = "org/telegram/messenger/voip" |
| 304 | def dxUtilPath = "${sdkDirectory.path}/build-tools/${buildToolsVersion}/dx" |
| 305 | if (OperatingSystem.current().isWindows()) { |
| 306 | dxUtilPath = "${sdkDirectory.path}\\build-tools\\${buildToolsVersion}\\dx.bat" |
| 307 | } |
| 308 |
| 309 | applicationVariants.all { variant -> |
| 310 | variant.outputs.all { output -> |
| 311 | outputFileName = "Nekogram-${defaultConfig.versionName}-${defaultConfig.versionCode / 10}-${variant.productFlavors.get(0).name}-${buildType.name}.apk" |
| 312 | output.getProcessManifestProvider().get().doLast { |
| 313 | def abiVersion = variant.productFlavors.get(0).abiVersionCode |
| 314 |
| 315 | def outputDir = manifestOutputDirectory |
| 316 | File directory |
| 317 | if (outputDir instanceof File) { |
| 318 | directory = outputDir |
| 319 | } else { |
| 320 | directory = outputDir.get().asFile |
| 321 | } |
| 322 |
| 323 | String manifestPath = directory.toString() + "/AndroidManifest.xml" |
| 324 | def manifestContent = file(manifestPath).getText() |
| 325 |
| 326 | manifestContent = manifestContent.replace(String.format('android:versionCode="%d"', defaultConfig.versionCode), String.format('android:versionCode="%s"', defaultConfig.versionCode + abiVersion)) |
| 327 | file(manifestPath).write(manifestContent) |
| 328 | } |
| 329 | } |
| 330 |
| 331 | def assembleTgVoipDexTaskName = "assemble${variant.name.capitalize()}TgVoipDex" |
| 332 |
| 333 | task "${assembleTgVoipDexTaskName}" { |
| 334 | doLast { |
| 335 | def sourceDir = (File) android.sourceSets.main.java.srcDirs[0] |
| 336 | def classesDir = "${buildDir}/intermediates/javac/${variant.name}/classes" |
| 337 | def javaDir = "${buildDir}/intermediates/java_tgvoip/${variant.name}/java" |
| 338 | def tgVoipDir = new File(classesDir, tgVoipDexClassesPath) |
| 339 | def javaVoipDirFile = new File(javaDir, tgVoipDexClassesPath) |
| 340 | def tgVoipDexJavaFile = new File(javaVoipDirFile, "TgVoipDex.java") |
| 341 | if (!javaVoipDirFile.exists()) { |
| 342 | javaVoipDirFile.mkdirs() |
| 343 | } |
| 344 | def assetsDirFile = new File(buildDir, "intermediates/merged_assets/${variant.name}/out") |
| 345 | if (!assetsDirFile.exists()) { |
| 346 | assetsDirFile.mkdirs() |
| 347 | } |
| 348 | def tgVoipDexFile = new File(assetsDirFile, tgVoipDexFileName) |
| 349 |
| 350 | def classes = tgVoipDir.list(new FilenameFilter() { |
| 351 | @Override |
| 352 | boolean accept(File dir, String name) { |
| 353 | // handle inner and anonymous classes |
| 354 | return tgVoipDexClasses.any { name == "${it}.class" || name.startsWith("${it}\$") && name.endsWith(".class") } |
| 355 | } |
| 356 | }).collect { "${tgVoipDexClassesPath}/${it}" } |
| 357 |
| 358 | // 1. create libtgvoip.dex |
| 359 | exec { |
| 360 | workingDir classesDir |
| 361 | commandLine([dxUtilPath, "--dex", "--output=${tgVoipDexFile}"] + classes) |
| 362 | } |
| 363 |
| 364 | // 2. remove classes from the main dex |
| 365 | project.delete classes.collect { "${classesDir}/${it}" } |
| 366 |
| 367 | // 3. insert checksum of libtgvoip.dex into TgVoipDex.java |
| 368 | def digest = MessageDigest.getInstance("SHA1") |
| 369 | def fileInputStream = tgVoipDexFile.newInputStream() |
| 370 | def buffer = new byte[4096] |
| 371 | def len |
| 372 | while ((len = fileInputStream.read(buffer)) > 0) { |
| 373 | digest.update(buffer, 0, len) |
| 374 | } |
| 375 | def dexChecksum = new String(Base64.getEncoder().encode(digest.digest())).trim() |
| 376 | tgVoipDexJavaFile.write(new String(new File(sourceDir, "${tgVoipDexClassesPath}/TgVoipDex.java").readBytes()).replace("\$CHECKSUM\$", dexChecksum)) |
| 377 | exec { |
| 378 | commandLine([findJavac(), "-d", classesDir, tgVoipDexJavaFile.absolutePath]) |
| 379 | } |
| 380 | } |
| 381 | } |
| 382 |
| 383 | tasks.findByName("compile${variant.name.capitalize()}JavaWithJavac").finalizedBy(assembleTgVoipDexTaskName) |
| 384 | tasks.findByName("${assembleTgVoipDexTaskName}").mustRunAfter tasks.findByName("merge${variant.name.capitalize()}Assets") |
| 385 | } |
| 386 |
| 387 | variantFilter { variant -> |
| 388 | def names = variant.flavors*.name |
| 389 | if (variant.buildType.name != "release" && !names.contains("afat")) { |
| 390 | setIgnore(true) |
| 391 | } |
| 392 | } |
| 393 |
| 394 | defaultConfig { |
| 395 | minSdkVersion 16 |
| 396 | targetSdkVersion 28 |
| 397 | versionName "6.1.1.3" |
| 398 |
| 399 | vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi'] |
| 400 |
| 401 | externalNativeBuild { |
| 402 | ndkBuild { |
| 403 | arguments "NDK_APPLICATION_MK:=jni/Application.mk", "APP_PLATFORM:=android-16", "--jobs=8" |
| 404 | abiFilters "armeabi-v7a", "arm64-v8a", "x86", "x86_64" |
| 405 | } |
| 406 | } |
| 407 | } |
| 408 |
| 409 | bundle { |
| 410 | language { |
| 411 | enableSplit = false |
| 412 | } |
| 413 | } |
| 414 | } |
| 415 |
| 416 | private static File findJavaHome() { |
| 417 | String javaPath = System.getProperty("java.home") |
| 418 | if (javaPath != null) { |
| 419 | File javaBase = new File(javaPath) |
| 420 | if (javaBase.exists()) { |
| 421 | if (javaBase.getName().equalsIgnoreCase("jre") && new File(javaBase.getParentFile(), "bin/java").exists()) { |
| 422 | return javaBase.getParentFile() |
| 423 | } else { |
| 424 | return javaBase |
| 425 | } |
| 426 | } else { |
| 427 | return null |
| 428 | } |
| 429 | } else { |
| 430 | return null |
| 431 | } |
| 432 | } |
| 433 |
| 434 | private static File findJavac() { |
| 435 | File javaHome = findJavaHome() |
| 436 | if (javaHome != null) { |
| 437 | if (OperatingSystem.current().isWindows()) { |
| 438 | return new File(javaHome.getParent(), "bin/javac.exe") |
| 439 | } else { |
| 440 | return new File(javaHome, "bin/javac") |
| 441 | } |
| 442 | } else { |
| 443 | return null |
| 444 | } |
| 445 | } |
| 446 |
| 447 | apply plugin: 'com.google.gms.google-services' |
| 448 |