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