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