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