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