| 7 |
| def serviceAccountCredentialsFile = rootProject.file("service_account_credentials.json") |
| 8 |
| 9 | def beta = verName.contains("preview") |
| 10 |
| 11 | if (serviceAccountCredentialsFile.isFile()) { |
| 12 |
| 13 | setupPlay(beta) |
| 14 |
| 15 | play.serviceAccountCredentials = serviceAccountCredentialsFile |
| 16 |
| 17 | } else if (System.getenv().containsKey("ANDROID_PUBLISHER_CREDENTIALS")) { |
| 18 |
| 19 | setupPlay(beta) |
| 20 |
| 21 | } |
| 22 |
| 23 | void setupPlay(boolean beta) { |
| 24 |
| 25 | apply plugin: 'com.github.triplet.play' |
| 26 |
| 27 | play { |
| 28 |
| 29 | track = beta ? "beta" : "production" |
| 30 | defaultToAppBundles = true |
| 31 |
| 32 | } |
| 33 |
| 34 | } |
| 35 |
| 36 | configurations { |
| 37 | compile.exclude module: 'support-v4' |
| 38 | } |
| 39 |
| 40 | def okHttpVersion = '4.9.0' |
| 41 | def fcmVersion = '21.0.1' |
| 42 | def crashlyticsVersion = '17.3.0' |
| 43 | def playCoreVersion = '1.9.0' |
| 44 |
| 45 | repositories { |
| 46 |
| 47 | jcenter() |
| 48 | maven { url "https://oss.sonatype.org/content/repositories/snapshots" } |
| 49 |
| 50 | } |
| 51 |
| 52 | dependencies { |
| 53 |
| 54 | implementation "androidx.browser:browser:1.3.0" |
| 55 | implementation 'androidx.core:core-ktx:1.5.0-alpha05' |
| 56 | implementation 'androidx.palette:palette-ktx:1.0.0' |
| 57 | implementation 'androidx.viewpager:viewpager:1.0.0' |
| 58 | implementation 'androidx.exifinterface:exifinterface:1.3.2' |
| 59 | implementation "androidx.interpolator:interpolator:1.0.0" |
| 60 | implementation 'androidx.dynamicanimation:dynamicanimation:1.0.0' |
| 61 | implementation 'androidx.multidex:multidex:2.0.1' |
| 62 | implementation "androidx.sharetarget:sharetarget:1.0.0" |
| 63 |
| 64 | // replace zxing with latest |
| 65 | // TODO: fix problem with android L |
| 66 | implementation 'com.google.zxing:core:3.4.1' |
| 67 |
| 68 | compileOnly 'org.checkerframework:checker-qual:3.9.0' |
| 69 | compileOnly 'org.checkerframework:checker-compat-qual:2.5.5' |
| 70 |
| 71 | // don't change this :) |
| 72 | //noinspection GradleDependency |
| 73 | implementation 'com.googlecode.mp4parser:isoparser:1.0.6' |
| 74 |
| 75 | implementation 'com.google.code.gson:gson:2.8.6' |
| 76 | implementation 'org.osmdroid:osmdroid-android:6.1.8' |
| 77 | implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.4.21-2' |
| 78 | implementation 'org.jetbrains.kotlinx:kotlinx-coroutines-android:1.4.2' |
| 79 |
| 80 | implementation "com.squareup.okhttp3:okhttp:$okHttpVersion" |
| 81 | implementation "com.squareup.okhttp3:okhttp-dnsoverhttps:$okHttpVersion" |
| 82 | implementation 'dnsjava:dnsjava:3.3.1' |
| 83 | implementation 'org.dizitart:nitrite:3.4.3' |
| 84 |
| 85 | implementation 'cn.hutool:hutool-core:5.5.7' |
| 86 | implementation 'cn.hutool:hutool-crypto:5.5.7' |
| 87 | implementation 'cn.hutool:hutool-http:5.5.7' |
| 88 |
| 89 | implementation 'com.jakewharton:process-phoenix:2.0.0' |
| 90 |
| 91 | implementation project(":openpgp-api") |
| 92 |
| 93 | compileOnly files('libs/libv2ray.aar') |
| 94 | compileOnly "com.google.firebase:firebase-messaging:$fcmVersion" |
| 95 | compileOnly "com.google.firebase:firebase-crashlytics:$crashlyticsVersion" |
| 96 | compileOnly "com.google.android.play:core:$playCoreVersion" |
| 97 |
| 98 | debugImplementation "com.google.firebase:firebase-messaging:$fcmVersion" |
| 99 | debugImplementation "com.google.firebase:firebase-crashlytics:$crashlyticsVersion" |
| 100 | debugImplementation "com.google.android.play:core:$playCoreVersion" |
| 101 | releaseImplementation "com.google.firebase:firebase-messaging:$fcmVersion" |
| 102 | releaseImplementation "com.google.firebase:firebase-crashlytics:$crashlyticsVersion" |
| 103 | releaseImplementation "com.google.android.play:core:$playCoreVersion" |
| 104 |
| 105 | testImplementation 'junit:junit:4.13.1' |
| 106 | testImplementation 'androidx.test:core:1.3.0' |
| 107 | testImplementation "org.robolectric:robolectric:4.4" |
| 108 |
| 109 | coreLibraryDesugaring 'com.android.tools:desugar_jdk_libs:1.1.1' |
| 110 |
| 111 | } |
| 112 |
| 113 | def keystorePwd = null |
| 114 | def alias = null |
| 115 | def pwd = null |
| 116 | Properties properties |
| 117 |
| 118 | if (project.rootProject.file('local.properties').exists()) { |
| 119 | properties = new Properties() |
| 120 | properties.load(project.rootProject.file('local.properties').newDataInputStream()) |
| 121 | } else { |
| 122 | def base64 = System.getenv("LOCAL_PROPERTIES") |
| 123 | if (base64 != null && !base64.isBlank()) { |
| 124 | properties = new Properties() |
| 125 | properties.load(new ByteArrayInputStream(Base64.decoder.decode(base64))) |
| 126 | } |
| 127 | } |
| 128 |
| 129 | if (properties != null) { |
| 130 | keystorePwd = properties.getProperty("KEYSTORE_PASS") |
| 131 | alias = properties.getProperty("ALIAS_NAME") |
| 132 | pwd = properties.getProperty("ALIAS_PASS") |
| 133 | } |
| 134 |
| 135 | keystorePwd = keystorePwd ?: System.getenv("KEYSTORE_PASS") |
| 136 | alias = alias ?: System.getenv("ALIAS_NAME") |
| 137 | pwd = pwd ?: System.getenv("ALIAS_PASS") |
| 138 |
| 139 | android { |
| 140 | compileSdkVersion 30 |
| 141 | buildToolsVersion '30.0.3' |
| 142 | ndkVersion rootProject.ext.ndkVersion |
| 143 |
| 144 | defaultConfig.applicationId = "nekox.messenger" |
| 145 |
| 146 | defaultConfig { |
| 147 | minSdkVersion 16 |
| 148 | //noinspection ExpiredTargetSdkVersion,OldTargetApi |
| 149 | targetSdkVersion 29 |
| 150 |
| 151 | versionName verName |
| 152 | versionCode verCode |
| 153 |
| 154 | def appId = "1391584" |
| 155 | def appHash = "355c91550b0d658cfb7ff89dcf91a08c" |
| 156 |
| 157 | //obtain your own keys at https://core.telegram.org/api/obtaining_api_id |
| 158 |
| 159 | if (properties != null) { |
| 160 | appId = properties.getProperty("TELEGRAM_APP_ID") ?: System.getenv("TELEGRAM_APP_ID") ?: appId |
| 161 | appHash = properties.getProperty("TELEGRAM_APP_HASH") ?: System.getenv("TELEGRAM_APP_HASH") ?: appHash |
| 162 | } |
| 163 |
| 164 | buildConfigField 'int', 'APP_ID', appId |
| 165 | buildConfigField 'String', 'APP_HASH', "\"" + appHash + "\"" |
| 166 |
| 167 | externalNativeBuild { |
| 168 | cmake { |
| 169 | version '3.10.2' |
| 170 | arguments '-DANDROID_STL=c++_static', '-DANDROID_PLATFORM=android-16', "-j=16" |
| 171 | } |
| 172 | } |
| 173 |
| 174 | } |
| 175 |
| 176 | bundle { |
| 177 | language { |
| 178 | enableSplit = false |
| 179 | } |
| 180 | } |
| 181 |
| 182 | externalNativeBuild { |
| 183 | cmake { |
| 184 | path 'jni/CMakeLists.txt' |
| 185 | } |
| 186 | } |
| 187 |
| 188 | lintOptions { |
| 189 | disable 'MissingTranslation' |
| 190 | disable 'ExtraTranslation' |
| 191 | disable 'BlockedPrivateApi' |
| 192 | } |
| 193 |
| 194 | packagingOptions { |
| 195 |
| 196 | exclude '/fabric/**' |
| 197 | exclude '/META-INF/*.version' |
| 198 | exclude '/META-INF/*.kotlin_module' |
| 199 | exclude '/builddef.lst' |
| 200 | exclude '/*.txt' |
| 201 |
| 202 | } |
| 203 |
| 204 | dexOptions { |
| 205 | jumboMode = true |
| 206 | } |
| 207 |
| 208 | compileOptions { |
| 209 | sourceCompatibility JavaVersion.VERSION_1_8 |
| 210 | targetCompatibility JavaVersion.VERSION_1_8 |
| 211 |
| 212 | coreLibraryDesugaringEnabled true |
| 213 | } |
| 214 |
| 215 | kotlinOptions { |
| 216 | jvmTarget = JavaVersion.VERSION_1_8.toString() |
| 217 | } |
| 218 |
| 219 | testOptions { |
| 220 | unitTests.includeAndroidResources = true |
| 221 | } |
| 222 |
| 223 | signingConfigs { |
| 224 | release { |
| 225 | storeFile project.file('release.keystore') |
| 226 | storePassword keystorePwd |
| 227 | keyAlias alias |
| 228 | keyPassword pwd |
| 229 | } |
| 230 | } |
| 231 |
| 232 | buildTypes { |
| 233 | debug { |
| 234 | isDefault true |
| 235 | debuggable true |
| 236 | jniDebuggable false |
| 237 | multiDexEnabled true |
| 238 | zipAlignEnabled true |
| 239 | signingConfig keystorePwd == null ? signingConfigs.debug : signingConfigs.release |
| 240 | } |
| 241 |
| 242 | releaseNoGcm { |
| 243 | debuggable false |
| 244 | jniDebuggable false |
| 245 | minifyEnabled true |
| 246 | shrinkResources true |
| 247 | multiDexEnabled true |
| 248 | zipAlignEnabled true |
| 249 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 250 | matchingFallbacks = ['debug'] |
| 251 | signingConfig signingConfigs.release |
| 252 | } |
| 253 |
| 254 | release { |
| 255 | debuggable false |
| 256 | jniDebuggable false |
| 257 | minifyEnabled true |
| 258 | shrinkResources true |
| 259 | multiDexEnabled true |
| 260 | zipAlignEnabled true |
| 261 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 262 | matchingFallbacks = ['debug'] |
| 263 | signingConfig signingConfigs.release |
| 264 | } |
| 265 |
| 266 | foss { |
| 267 | debuggable false |
| 268 | jniDebuggable false |
| 269 | minifyEnabled true |
| 270 | shrinkResources true |
| 271 | multiDexEnabled true |
| 272 | zipAlignEnabled true |
| 273 | proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' |
| 274 | matchingFallbacks = ['debug'] |
| 275 | } |
| 276 | } |
| 277 |
| 278 | sourceSets { |
| 279 |
| 280 | main { |
| 281 | jni.srcDirs = [] |
| 282 | } |
| 283 |
| 284 | debug { |
| 285 | jniLibs.srcDir 'src/main/libs' |
| 286 | manifest.srcFile 'src/gservcies/AndroidManifest.xml' |
| 287 | } |
| 288 |
| 289 | releaseNoGcm { |
| 290 | jniLibs.srcDir 'src/main/libs' |
| 291 | } |
| 292 |
| 293 | release { |
| 294 | jniLibs.srcDir 'src/main/libs' |
| 295 | manifest.srcFile 'src/gservcies/AndroidManifest.xml' |
| 296 | } |
| 297 |
| 298 | foss { |
| 299 | jni.srcDirs = ['./jni/'] |
| 300 | } |
| 301 |
| 302 | } |
| 303 |
| 304 | splits.abi { |
| 305 |
| 306 | enable true |
| 307 | universalApk false |
| 308 |
| 309 | } |
| 310 |
| 311 | flavorDimensions "version" |
| 312 |
| 313 | productFlavors { |
| 314 | mini { |
| 315 | versionNameSuffix '-mini' |
| 316 | } |
| 317 | miniAppleEmoji { |
| 318 | versionNameSuffix '-mini' |
| 319 | } |
| 320 | full { |
| 321 | isDefault true |
| 322 | } |
| 323 | fullAppleEmoji { |
| 324 | versionNameSuffix '-full-apple-emoji' |
| 325 | } |
| 326 | fullPlay { |
| 327 | versionNameSuffix '-play' |
| 328 | versionCode verCode - 1 |
| 329 | } |
| 330 | } |
| 331 |
| 332 | sourceSets.all { set -> |
| 333 | if (set.name.startsWith("full")) { |
| 334 | set.dependencies { |
| 335 | implementation files('libs/libv2ray.aar', 'libs/ss-rust-release.aar', 'libs/ssr-libev-release.aar') |
| 336 | } |
| 337 | } |
| 338 | if (set.name.matches("(mini|full).*")) { |
| 339 | if (set.name.contains("Apple")) { |
| 340 | set.assets.srcDirs = ["src/main/assets", "src/emojis/apple"] |
| 341 | /*} else if (set.name.contains("Twitter")) { |
| 342 | set.assets.srcDirs = ["src/main/assets", "src/emojis/twitter"]*/ |
| 343 | } else { |
| 344 | set.assets.srcDirs = ["src/main/assets", "src/emojis/twitter"] |
| 345 | } |
| 346 | } |
| 347 | } |
| 348 |
| 349 | tasks.all { task -> |
| 350 | if (((task.name.endsWith('Ndk') || task.name.startsWith('generateJsonModel') || task.name.startsWith('externalNativeBuild'))) && !task.name.contains("Foss")) { |
| 351 | task.enabled = false |
| 352 | } |
| 353 | if (task.name.contains("uploadCrashlyticsMappingFile")) { |
| 354 | enabled = false |
| 355 | } |
| 356 | } |
| 357 |
| 358 | applicationVariants.all { variant -> |
| 359 | variant.outputs.all { output -> |
| 360 | outputFileName = outputFileName.replace("TMessagesProj", "NekoX") |
| 361 | } |
| 362 | } |
| 363 |
| 364 | } |
| 365 |
| 366 | apply plugin: 'com.google.gms.google-services' |
| 367 | apply plugin: 'com.google.firebase.crashlytics' |
| 368 |
| 369 | android { |
| 370 |
| 371 | tasks.all { 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 | } |
| 379 | } |
| 380 |
| 381 | } |
| 382 |