I have a project with this build setting :
Project have separate debug variant
applicationIdSuffix '.debug'
versionNameSuffix '-DEBUG'
On the time of release, there are showing many build variants.
But I'm a beginner developer, so need to sure from you guys, which one is debug build variant that one I need to release?
Then what will do the other build variants?
And this project includes many modules ( like 3rd Party Sample Project )
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
//noinspection GradleDynamicVersion
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.firebase.firebase-perf'
repositories {
maven { url 'https://maven.fabric.io/public' }
maven {
url 'some url/'
credentials {
username 'someusername'
password 'somepassword'
}
}
}
// for Crashlytics
apply plugin: 'io.fabric'
// Create a variable called keystorePropertiesFile, and initialize it to your
// keystore.properties file, in the rootProject folder.
def keystorePropertiesFile = rootProject.file("keystore.properties")
// Initialize a new Properties() object called keystoreProperties.
def keystoreProperties = new Properties()
// Load your keystore.properties file into the keystoreProperties object.
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
// applicationVariants.all { variant ->
// //(variant.buildType.name == 'release') {
// variant.mergeAssetsProvider.configure {
// doLast {
// delete(fileTree(dir: outputDir, includes: ['**/*.pdf'])) // '**/js',
// }
// }
// //}
// }
signingConfigs {
release {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
lintOptions {
checkReleaseBuilds true
abortOnError true
//warningsAsErrors true
baseline file("lint-baseline.xml")
fatal 'StopShip'
}
compileSdkVersion 28
useLibrary 'org.apache.http.legacy'
defaultConfig {
applicationId "com.application.sanchyan"
versionName "3.1.8.4"
versionCode 18
targetSdkVersion 28
vectorDrawables.useSupportLibrary = true
renderscriptSupportModeEnabled true
renderscriptTargetApi 19
multiDexEnabled true
}
buildTypes {
debug {
applicationIdSuffix '.debug'
versionNameSuffix '-DEBUG'
//minifyEnabled true
// By using a special debug ProGuard file, you can turn off obfuscation, which would
// otherwise hinder debugging.
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro',
'proguard-rules-debug.pro'
}
release {
minifyEnabled true
//shrinkResources true
signingConfig signingConfigs.release
//multiDexKeepFile file('multidex-config.txt')
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
ext.enableCrashlytics = true
//
// IMPORTANT PART:
//
// tell your MultiDex to keep the classes you defined in your Proguard .pro file.
//multiDexKeepProguard file('proguard-rules.pro')
}
}
flavorDimensions "region", "mode", "api"
productFlavors {
// Read these to understand the whole concept better:
// li
// https://proandroiddev.com/advanced-android-flavors-part-1-building-white-label-apps-on-android-ade16af23bcf
// API
pre21 {
dimension "api"
minSdkVersion 19
versionNameSuffix ""
}
post21 {
dimension "api"
minSdkVersion 21
versionNameSuffix ""
}
// MODE
full {
dimension "mode"
}
demo {
dimension "mode"
applicationIdSuffix '.demo'
versionNameSuffix " [Demo]"
}
internal {
dimension "mode"
applicationIdSuffix '.internal'
versionNameSuffix " [Internal]"
}
// REGION
brigon {
dimension "region"
applicationIdSuffix '.brigon'
}
uei {
dimension "region"
applicationIdSuffix '.uei'
}
uk {
dimension "region"
versionNameSuffix ""
}
}
compileOptions {
targetCompatibility JavaVersion.VERSION_1_8
sourceCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'com.android.support:multidex:1.0.3'
implementation project(':polygonview')
implementation project(':tabbuttonview')
implementation project(':imagetoggleview')
implementation project(':wedgeview')
implementation project(':panzoomview')
implementation project(':flowlayout')
implementation project(':infoview')
implementation project(path: ':utilities')
implementation 'androidx.appcompat:appcompat:1.1.0' // 1.1.0-rc01
/* beta2 causes issues with layouts not showing content till updating (eg DevicePicker) */
//noinspection GradleDependency
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta3' // 2.0.0-beta1
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'cn.aigestudio.wheelpicker:WheelPicker:1.1.2'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.material:material:1.2.0-alpha02' // 1.1.0-alpha09
implementation 'com.google.firebase:firebase-core:17.2.1' // 17.0.0
implementation 'com.google.firebase:firebase-messaging:20.0.1'
implementation 'com.google.firebase:firebase-perf:19.0.2'
implementation 'com.google.maps.android:android-maps-utils:0.6.2'
implementation 'com.pacioianu.david:ink-page-indicator:1.3.0'
implementation 'com.squareup.moshi:moshi:1.9.2'
//noinspection GradleDependency
pre21Implementation 'com.squareup.okhttp3:okhttp:3.14.4'
post21Implementation 'com.squareup.okhttp3:okhttp:4.2.2'
//implementation 'com.squareup.okhttp3:okhttp:3.14.4'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'org.apache.commons:commons-text:1.8'
// for Crashlytics
implementation 'com.crashlytics.sdk.android:crashlytics:2.10.1'
implementation 'com.crashlytics.sdk.android:answers:1.4.7'
// for PSPDFKit
implementation 'com.pspdfkit:pspdfkit:6.0.3'
implementation 'androidx.palette:palette:1.0.0'
// for Chrome web content
implementation 'com.android.support:customtabs:28.0.0'
// for image cropping
// implementation 'com.github.yalantis:ucrop:2.2.4-native'
implementation 'com.github.yalantis:ucrop:2.2.4'
// implementation 'com.androidplot:androidplot-core:0.9.4'
// Room components
// implementation "android.arch.persistence.room:runtime:$rootProject.roomVersion"
// annotationProcessor "android.arch.persistence.room:compiler:$rootProject.roomVersion"
// androidTestImplementation "android.arch.persistence.room:testing:$rootProject.roomVersion"
// Lifecycle components
implementation "android.arch.lifecycle:extensions:$rootProject.archLifecycleVersion"
//annotationProcessor "android.arch.lifecycle:compiler:$rootProject.archLifecycleVersion"
implementation "android.arch.lifecycle:common-java8:1.1.1"
testImplementation 'junit:junit:4.13-rc-2'
testImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
debugImplementation 'com.squareup.leakcanary:leakcanary-android:1.5.1'
releaseImplementation 'com.squareup.leakcanary:leakcanary-android-no-op:1.5.1'
//noinspection GradlePath
implementation files('C:/Users/Dell/Documents/ProjectFilePath/libs/YouTubeAndroidPlayerApi.jar')
}
apply plugin: 'com.google.gms.google-services'
And the error shows on release build time is
Missing org.conscrypt.ConscryptHostnameVerifer
I don't know how much future error will come to release.
Please help me out
read this topic
And this one
While reading the info message, it gives me an idea about this Conscrypt and did a research and found out that I need to install conscrypt to my gradle.app
implementation 'org.conscrypt:conscrypt-android:2.2.1'
and it works.
Related
In my Android application, I have both imported the OpenCV library, as well as integrated a live edge detection library, which in turn uses OpenCV on its own.
Originally, this created a conflict between the two versions of OpenCV, but I was able to resolve that.
I am now trying to do a production release for the first time since this change, and I am encountering the following error during my release build (in the mergeDex...Release stage):
Type org.opencv.calib3d.Calib3d is defined multiple times: .../OpenCVSDK/build/.transforms/73aaad4d2991f9ad7ec3aa9b43023dc9/transformed/release/org/opencv/calib3d/Calib3d.dex, .../app/build/intermediates/external_libs_dex/prodSbirRelease/mergeExtDexProdSbirRelease/classes3.dex
Why is this suddenly an issue now, with a release build, when it was (and continues to be) fine with debug builds? And how can I fix it?
Here is my app build.gradle:
plugins {
id 'com.android.application'
id 'com.google.android.gms.oss-licenses-plugin'
}
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
apply plugin: 'com.google.firebase.crashlytics'
android {
signingConfigs {
debug {
storeFile file('.../ReleaseKeyStore')
storePassword '...'
keyAlias 'key0'
keyPassword '...'
}
release {
storeFile file('.../ReleaseKeyStore')
storePassword '...'
keyAlias 'key0'
keyPassword '...'
}
}
compileSdk 31
defaultConfig {
minSdk 26
targetSdk 31
versionCode 3
versionName "0.9.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
signingConfig signingConfigs.release
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
// Based on https://www.geeksforgeeks.org/how-to-change-the-default-generated-apk-name-in-android-studio/
// and https://stackoverflow.com/questions/25104323/how-to-customize-the-apk-file-name-for-product-flavors
applicationVariants.all{
variant ->
variant.outputs.each{
output->
def name = "ImageCapture-${variant.flavorName}-${variant.versionName}.apk"
output.outputFileName = name
}
}
}
flavorDimensions "environment", "product"
productFlavors {
local {
dimension "environment"
resValue "string", "app_name", "LOCAL Image Capture"
}
dev {
dimension "environment"
resValue "string", "app_name", "DEV Image Capture"
}
prod {
dimension "environment"
resValue "string", "app_name", "Image Capture"
}
sbir {
dimension "product"
}
nci {
dimension "product"
}
}
androidComponents {
onVariants(selector().all(), { variant ->
switch (variant.name) {
case "localSbirDebug":
case "devSbirDebug":
case "localSbirRelease":
case "devSbirRelease":
variant.applicationId = "ai.dlanalytics.imagecapture.dev"
break
case "prodSbirDebug":
case "prodSbirRelease":
variant.applicationId = "ai.dlanalytics.imagecapture"
break
case "localNciDebug":
case "devNciDebug":
case "localNciRelease":
case "devNciRelease":
variant.applicationId = "ai.dlanalytics.imagecapture.nci.dev"
break
case "prodNciDebug":
case "prodNciRelease":
variant.applicationId = "ai.dlanalytics.imagecapture.nci"
break
}
})
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
packagingOptions {
pickFirst '**/*.so'
resources {
excludes += ['META-INF/DEPENDENCIES', 'META-INF/LICENSE', 'META-INF/LICENSE.txt', 'META-INF/license.txt', 'META-INF/NOTICE', 'META-INF/NOTICE.txt', 'META-INF/notice.txt', 'META-INF/ASL2.0', 'META-INF/*.kotlin_module']
}
}
buildFeatures {
viewBinding true
mlModelBinding true
}
namespace 'ai.dlanalytics.imagecapture'
}
dependencies {
implementation 'com.github.adityaarora1:LiveEdgeDetection:master-SNAPSHOT'
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation "androidx.activity:activity:1.4.0"
implementation "androidx.fragment:fragment:1.4.1"
implementation 'com.google.android.material:material:1.6.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'com.google.android.gms:play-services-auth:20.2.0'
implementation "com.google.android.gms:play-services-location:19.0.1"
implementation 'com.google.api-client:google-api-client:1.32.2'
implementation 'com.google.android.gms:play-services-vision:20.1.3'
implementation 'com.android.volley:volley:1.2.1'
implementation 'androidx.navigation:navigation-fragment:2.4.2'
implementation 'androidx.navigation:navigation-ui:2.4.2'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation "androidx.camera:camera-camera2:1.2.0-alpha01"
implementation "androidx.camera:camera-lifecycle:1.2.0-alpha01"
implementation "androidx.camera:camera-view:1.2.0-alpha01"
implementation "androidx.camera:camera-extensions:1.2.0-alpha01"
implementation "com.github.bumptech.glide:glide:4.11.0"
implementation 'com.github.chrisbanes:PhotoView:2.0.0'
implementation platform('com.google.firebase:firebase-bom:30.0.1')
implementation 'com.google.firebase:firebase-crashlytics'
implementation 'com.google.firebase:firebase-analytics'
implementation 'com.google.android.gms:play-services-oss-licenses:17.0.0'
implementation 'androidx.preference:preference:1.1.1'
implementation 'org.tensorflow:tensorflow-lite-support:0.1.0'
implementation 'org.tensorflow:tensorflow-lite-metadata:0.1.0'
implementation "androidx.work:work-runtime:2.7.1"
implementation project(path: ':OpenCVSDK')
// implementation 'org.bytedeco:opencv:4.5.5-1.5.7'
implementation 'org.tensorflow:tensorflow-lite-gpu:2.3.0'
implementation 'com.google.android.flexbox:flexbox:3.0.0'
implementation platform('com.google.firebase:firebase-bom:30.2.0')
implementation 'com.google.firebase:firebase-ml-modeldownloader'
implementation 'org.tensorflow:tensorflow-lite:2.3.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
And my project build.gradle:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
maven { url "https://www.jitpack.io" }
google() // Google's Maven repository
}
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.google.firebase:firebase-crashlytics-gradle:2.8.1'
classpath 'com.google.android.gms:oss-licenses-plugin:0.10.5'
}
}
plugins {
id 'com.android.application' version '7.2.0' apply false
id 'com.android.library' version '7.2.0' apply false
}
allprojects {
repositories {
google()
mavenCentral()
maven { url "https://www.jitpack.io" }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
I'm relatively new to Android builds, so please let me know what other helpful information I can provide.
The APK is generated and everything works at compile time but app crash at runtime. The crash is when launching the camera module for barcode scanning implemented with CameraX.
Here is the crash log:
08-22 17:31:16.537 16660-16660/com.xxx.xxx E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.xxx.xxx, PID: 16660
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/xxx/xxx/viewmodels/CameraXViewModel;
at com.xxx.xxx.barcode.CameraXLivePreviewActivity.onCreate(CameraXLivePreviewActivity.kt:94)
at android.app.Activity.performCreate(Activity.java:7314)
at android.app.Activity.performCreate(Activity.java:7305)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1215)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2948)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3073)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1774)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:198)
at android.app.ActivityThread.main(ActivityThread.java:7055)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:523)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:836)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.xxx.xxx.viewmodels.CameraXViewModel" on path: DexPathList[[zip file "/data/app/com.xxx.xxx-LKiFwx0pU2KUfueyYsAm-w==/base.apk"],nativeLibraryDirectories=[/data/app/com.xxx.xxx-LKiFwx0pU2KUfueyYsAm-w==/lib/arm64, /data/app/com.xxx.xxx-LKiFwx0pU2KUfueyYsAm-w==/base.apk!/lib/arm64-v8a, /system/lib64, /vendor/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:125)
Here is line 94 where the ViewModel is accessed.
Kindly refer my build details.
Here is the project-level build.gradle
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
classpath 'com.google.gms:google-services:4.3.10'
classpath 'com.android.tools.build:gradle:7.1.3'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10"
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
build.gradle(:app)
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.gms.google-services'
id 'kotlin-android'
id 'kotlin-android-extensions'
id 'kotlin-kapt'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.xxx.xxx"
minSdk 21
targetSdk 31
versionCode 19
versionName "1.2.13"
multiDexEnabled true
signingConfig signingConfigs.config
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
buildConfigField "String", "AREA", "\"\""
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
buildConfigField "String", "AREA", "\"\""
}
ABC {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
buildConfigField "String", "AREA", "\"_A\""
}
XYZ {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
buildConfigField "String", "AREA", "\"_X\""
}
}
flavorDimensions "appVariant", "projectCode"
productFlavors {
A {
dimension "appVariant"
}
B {
dimension "appVariant"
}
C {
dimension "appVariant"
}
D {
dimension "appVariant"
}
DEV {
dimension "projectCode"
}
QA {
dimension "projectCode"
}
LIVE {
dimension "projectCode"
}
DEMO {
dimension "projectCode"
}
BETA {
dimension "projectCode"
}
}
applicationVariants.all { variant ->
variant.outputs.all { output ->
def project = "TEST_PROJECT"
def SEP = "_"
def flavor = variant.productFlavors[0].name
def projcode = variant.productFlavors[1].name
def buildType = variant.buildType.name
def buildTypeName = "";
switch (buildType) {
case "ABC": buildTypeName = SEP + "AB"; break;
case "XYZ": buildTypeName = SEP + "XY"; break;
default:
buildTypeName = "";
}
def version = variant.versionName
def date = new Date();
def formattedDate = date.format('ddMMyy_HHmm')
def newApkName = project + buildTypeName + SEP + flavor + SEP + projcode + SEP + version + ".apk"
outputFileName = new File(newApkName)
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
dataBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
implementation 'androidx.databinding:databinding-runtime:7.0.2'
implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation 'com.google.firebase:firebase-messaging-ktx:22.0.0'
implementation 'org.jetbrains.kotlinx:kotlinx-serialization-json:1.2.2'
implementation 'androidx.camera:camera-core:1.0.2'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
//Retrofit and GSON
implementation 'com.squareup.retrofit2:retrofit:2.6.0'
implementation 'com.squareup.retrofit2:converter-gson:2.6.0'
implementation 'com.squareup.retrofit2:adapter-rxjava:2.5.0'
implementation 'com.squareup.okhttp3:logging-interceptor:4.2.1'
implementation 'com.jakewharton.retrofit:retrofit2-kotlin-coroutines-adapter:0.9.2'
//Kotlin Coroutines
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.3.0"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.3.0"
// ViewModel and LiveData
implementation "androidx.lifecycle:lifecycle-extensions:2.2.0"
//Kodein Dependency Injection
implementation "org.kodein.di:kodein-di-generic-jvm:6.2.1"
implementation "org.kodein.di:kodein-di-framework-android-x:6.2.1"
//Android Room
implementation "androidx.room:room-runtime:2.2.5"
implementation "androidx.room:room-ktx:2.2.5"
kapt "androidx.room:room-compiler:2.2.5"
//Android Navigation Architecture
implementation "androidx.navigation:navigation-fragment-ktx:2.2.0-alpha02"
implementation "androidx.navigation:navigation-ui-ktx:2.2.0-alpha02"
implementation 'com.xwray:groupie:2.8.0'
implementation 'com.xwray:groupie-kotlin-android-extensions:2.8.0'
implementation 'com.xwray:groupie-databinding:2.8.0'
implementation "androidx.preference:preference-ktx:1.1.0"
//Image loading
implementation "com.squareup.picasso:picasso:2.71828"
//barcode
implementation 'com.google.mlkit:barcode-scanning:17.0.0'
// CameraX
implementation "androidx.camera:camera-camera2:1.0.0-SNAPSHOT"
implementation "androidx.camera:camera-lifecycle:1.0.0-SNAPSHOT"
implementation "androidx.camera:camera-view:1.0.0-SNAPSHOT"
// On Device Machine Learnings
implementation "com.google.android.odml:image:1.0.0-beta1"
implementation 'com.google.mlkit:camera:16.0.0-beta1'
implementation 'me.dm7.barcodescanner:zxing:1.9.13'
implementation(files("./libs/scandecode-release.aar"))
implementation 'com.valdesekamdem.library:md-toast:0.9.0'
implementation 'com.tt:whorlviewlibrary:1.0.3'
}
Not sure what is wrong.
Any help will be appreciated.
Solved!.
Implemented multidex from the developer site.
https://developer.android.com/studio/build/multidex
Also there were two view model classes CameraXViewModel & CameraXviewModel.kt, removed the file CameraXviewModel.kt from the project. CameraXViewModel is the one which is used and CameraXviewModel was not referenced any where in the project.
ASFAIK Java and Kotlin is case sensitive for classes, so ideally it should work. Here everything compiled and APK generated but app crashed at runtime.
Hope this helps someone.
I have this errors when I try to sync gradle. I am using Android Studio 3.5 and gradle 5.4.1 . It worked fine with this configuration and suddenly I start getting this errors.
**ERROR**: Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve com.google.android.gms:play-services-location:[15.0.0, 16.0.0).
Affected Modules: app
**ERROR**: Unable to resolve dependency for ':app#debugAndroidTest/compileClasspath': Could not resolve com.google.android.gms:play-services-location:[15.0.0, 16.0.0).
Affected Modules: app
**ERROR**: Unable to resolve dependency for ':app#debugUnitTest/compileClasspath': Could not resolve com.google.firebase:firebase-messaging:[10.2.1, 12.1.0).
Affected Modules: app
**ERROR**: Unable to resolve dependency for ':app#debugUnitTest/compileClasspath': Could not resolve com.google.android.gms:play-services-location:[10.2.1, 12.1.0).
Affected Modules: app
this is my app/build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: "androidx.navigation.safeargs"
apply plugin: 'com.apollographql.android'
apply plugin: 'com.onesignal.androidsdk.onesignal-gradle-plugin'
apply plugin: 'io.fabric'
def versionMajor = 4
def versionMinor = 0
def versionPatch = 0
def versionBuild = 345
def keystorePropertiesFile = rootProject.file("keystore.properties")
def keystoreProperties = new Properties()
keystoreProperties.load(new FileInputStream(keystorePropertiesFile))
android {
signingConfigs {
config {
keyAlias keystoreProperties['keyAlias']
keyPassword keystoreProperties['keyPassword']
storeFile file(keystoreProperties['storeFile'])
storePassword keystoreProperties['storePassword']
}
}
compileSdkVersion 29
defaultConfig {
applicationId "example"
minSdkVersion 26
targetSdkVersion 29
versionCode versionMajor * 10000 + versionMinor * 1000 + versionPatch * 100 + versionBuild
versionName "${versionMajor}.${versionMinor}.${versionPatch}.${versionBuild}"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
manifestPlaceholders = [auth0Domain: "#string/com_auth0_domain", auth0Scheme: "demo"]
setArchivesBaseName new Date().format("dd.MMM.yy") + "-v#" + versionName
//OneSignal
manifestPlaceholders = [
onesignal_app_id: 'id',
// Project number pulled from dashboard, local value is ignored.
onesignal_google_project_number: 'REMOTE'
]
// add some strings to res
resValue('string', 'google_maps_api_key', google_maps_api_token)
resValue('string', 'google_maps_places_api_key', google_maps_places_api_token)
buildConfigField("String", "API_TOKEN", "\"$api_token\"")
buildConfigField("String", "ADJUST_TOKEN", "\"$adjust_token\"")
buildConfigField("String", "GRAPH_QL", "\"$api_graphql\"")
renderscriptTargetApi 28
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled false
debuggable false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField("String", "SERVER_URL", "\"$api_base_url$api_ext_release\"")
signingConfig signingConfigs.config
}
staging {
debuggable true
applicationIdSuffix ".staging"
buildConfigField("String", "SERVER_URL", "\"$api_base_url$api_ext_staging\"")
signingConfig signingConfigs.config
}
debug {
debuggable true
applicationIdSuffix ".debug"
buildConfigField("String", "SERVER_URL", "\"$api_base_url$api_ext_dev\"")
signingConfig signingConfigs.config
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
lintOptions {
checkReleaseBuilds false
// Or, if you prefer, you can continue to check for errors in release builds,
// but continue the build even when errors are found:
abortOnError false
}
}
repositories {
maven { url 'https://maven.fabric.io/public' }
}
apollo {
customTypeMapping = ["Datetime": "java.lang.String"]
customTypeMapping = ["Currency": "java.lang.String"]
useSemanticNaming = false
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
// android ui and support versions
implementation(
"androidx.appcompat:appcompat:$appcompat_version",
"androidx.constraintlayout:constraintlayout:$constraintlayout_version",
"com.google.android.material:material:$material_design_components_version"
)
compileOnly group: "javax.annotation", name: "javax.annotation-api", version: "1.3.2"
compileOnly group: "org.jetbrains", name: "annotations", version: "13.0"
implementation(
"androidx.core:core-ktx:$ktx_version",
"androidx.fragment:fragment-ktx:$ktx_version",
"android.arch.navigation:navigation-fragment-ktx:$nav_version",
"android.arch.navigation:navigation-ui-ktx:$nav_version"
)
implementation "android.arch.navigation:navigation-fragment:$nav_version"
// use -ktx for Kotlin
implementation "android.arch.navigation:navigation-ui:$nav_version"
// use -ktx for Kotlin
implementation(
"com.mikepenz:fastadapter:$fast_adapter_version",
"com.mikepenz:fastadapter-commons:$fast_adapter_version",
"com.mikepenz:fastadapter-extensions-expandable:$fast_adapter_version",
"com.mikepenz:fastadapter-extensions:$fast_adapter_version",
"com.mikepenz:materialize:$materialize_version"
)
// firebase
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-messaging:18.0.0'
// data and api
implementation(
"com.apollographql.apollo:apollo-runtime:$apollo_version",
"com.apollographql.apollo:apollo-http-cache:$apollo_version"
)
implementation "com.squareup.okhttp3:logging-interceptor:$okhttp_interceptor_version"
// rx
implementation(
"io.reactivex.rxjava2:rxandroid:$rx_android_version",
"io.reactivex.rxjava2:rxjava:$rx_java_version",
"com.apollographql.apollo:apollo-rx2-support:$apollo_version"
)
implementation "de.hdodenhof:circleimageview:$circle_imageview_version"
// koin di
implementation(
"org.koin:koin-android:$koin_version",
"org.koin:koin-androidx-scope:$koin_version",
"org.koin:koin-androidx-viewmodel:$koin_version"
)
// rx android networking
implementation(
"com.amitshekhar.android:rx2-android-networking:$afn_version",
"com.github.prashantsolanki3:Secure-Pref-Manager:$secure_prefs_vresion"
)
//Beta by Crashlytics
compile('com.crashlytics.sdk.android:crashlytics:2.10.1#aar') {
transitive = true;
}
implementation 'com.jakewharton.timber:timber:4.7.1'
implementation "com.google.maps.android:android-maps-utils:0.5"
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation 'com.google.android.gms:play-services-location:17.0.0'
implementation 'com.google.android.gms:play-services-places:17.0.0'
implementation 'com.google.android.libraries.places:places:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation "junit:junit:$junit_version"
androidTestImplementation("androidx.test:runner:$test_runner_version",
"androidx.test.espresso:espresso-core:$espresso_test_version"
)
//Glide
implementation "com.github.bumptech.glide:glide:$glide_version"
annotationProcessor "com.github.bumptech.glide:compiler:$glide_version"
//Permission Manager
implementation 'com.github.florent37:runtime-permission-kotlin:1.1.0'
//Notification banner
implementation 'com.github.shasin89:NotificationBanner:1.1.0'
//Loading spinner
implementation 'com.github.ybq:Android-SpinKit:1.2.0'
//Circle image view
implementation 'de.hdodenhof:circleimageview:3.0.0'
//helpers for Android SDK
implementation "org.jetbrains.anko:anko:$anko_version"
//date helper
implementation 'com.jakewharton.threetenabp:threetenabp:1.1.0'
//Picasso
implementation 'com.squareup.picasso:picasso:2.71828'
//EventBus
implementation 'org.greenrobot:eventbus:3.1.1'
//Round corner progress bar
implementation 'com.akexorcist:RoundCornerProgressBar:2.0.3'
//Expandable RecycleView
implementation 'com.thoughtbot:expandablerecyclerview:1.3'
//OneSignal
implementation 'com.onesignal:OneSignal:[3.9.1, 3.99.99]'
implementation "joda-time:joda-time:$jodatime_version"
implementation 'com.github.drawers:SpinnerDatePicker:2.0.1'
//Adjust
implementation 'com.adjust.sdk:adjust-android:4.18.0'
implementation 'com.android.installreferrer:installreferrer:1.0'
// implementation 'com.adjust.sdk:adjust-android-webbridge:4.18.0' if user Adjust with webview
testImplementation 'org.koin:koin-test:1.0.1'
debugImplementation 'com.readystatesoftware.chuck:library:1.1.0'
stagingImplementation 'com.readystatesoftware.chuck:library:1.1.0'
releaseImplementation 'com.readystatesoftware.chuck:library-no-op:1.1.0'
}
apply plugin: 'com.google.gms.google-services'
If you have it declared as follows in project build.gradle
maven { url "https://jitpack.io" }
try changing to
maven { url "https://www.jitpack.io" }
You must check your internet connection and disabled gradle offline mode in setting
after that do :
File > Invalidate Cache and restart.
And try to sync the app !
I'm developing an android application for my company. The project holds directories: our sdk (library in this case) and a sample app that imports the sdk. When I add product flavors to the sdk (library) the app breaks due to being unable to resolve the dependencies imported from the sdk.
The errors are:
error cannot find symbol class S
error cannot find symbol class SO
error package S does not exist
error method does not override or
implement a method from a supertype
Here is the top-level/project level build.gradle file
buildscript {
repositories {
jcenter()
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.2.0'
classpath 'com.novoda:bintray-release:0.9'
}
}
allprojects {
repositories {
jcenter()
google()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Here is the SDK/Library build.gradle file:
apply plugin: 'com.android.application'
apply plugin: 'com.novoda.bintray-release'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 14
targetSdkVersion 27
versionCode 1
versionName version
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
defaultPublishConfig "nonlocationVersionRelease"
publishNonDefault true
flavorDimensions "version"
productFlavors {
nonlocation {
dimension "version"
}
location {
dimension "version"
}
}
buildTypes {
release {
minifyEnabled false
//proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
}
}
lintOptions {
abortOnError false
}
}
configurations {
javadocDeps
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.mcxiaoke.volley:library:1.0.19'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
}
publish {
userOrg = '*******'
groupId = 'com.*******.android'
artifactId = '*******'
publishVersion = '2.0.0'
desc = '******* sdk'
website = 'https://github.com/*******/*******-android-public-sdk'
}
and here is the app's build.gradle file:
apply plugin: 'com.android.application'
def computeVersionCode = { ->
def stdout = new ByteArrayOutputStream()
exec {
commandLine 'git', 'rev-list', 'HEAD', '--count'
standardOutput = stdout
}
return stdout.toString().trim().toInteger();
}
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.*******.demo"
minSdkVersion 15
targetSdkVersion 27
versionCode computeVersionCode()
versionName "1.0"
renderscriptTargetApi 20
renderscriptSupportModeEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
signingConfigs {
debugConfig {
storeFile file("debug.jks")
storePassword "*******"
keyAlias "com.*******.android"
keyPassword "*******"
}
releaseConfig {
storeFile file("release.jks")
storePassword "*******"
keyAlias "com.*******.android"
keyPassword "*******"
}
}
buildTypes {
debug {
signingConfig signingConfigs.debugConfig
}
release {
signingConfig signingConfigs.releaseConfig
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
lintOptions {
abortOnError false
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:preference-v7:27.1.1'
implementation 'com.google.guava:guava:23.0'
implementation 'com.squareup:seismic:1.0.2'
implementation 'net.hockeyapp.android:HockeySDK:3.7.0'
implementation 'jp.wasabeef:blurry:1.0.5'
implementation project(path: ':*******-sdk', configuration:'default')
}
I have been trying to fix this for 4 days and am still stuck. I've tried all of the typical solutions found on stackoverflow. This has been a cascade of problem after problem and this specific one came directly after updating how the sdk is loaded in the app's build.gradle file. I suspect something is wrong with this line where I import the sdk as a dependency (end of app's build.gradle):
implementation project(path: ':*******-sdk', configuration:'default')
but not including 'configuration: 'default'' causes another bug where the app cannot discern which buildVariant of the SDK to use.
How can I get my app up and running while also maintaining the product flavors found in the SDK?
I am not able to build release APK. Every time I get DexMergerException.
Here are my build.gradles:
I am using MVVM structure. I have core(package name for core is same as my app package) has my lib where I only write view models, models and network layers.
Errors I am getting:
Caused by: com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives:
Caused by: com.android.tools.r8.CompilationFailedException: Compilation failed to complete
Caused by: com.android.tools.r8.utils.AbortException
Program type already present:
app build.gradle:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
maven { url 'https://maven.fabric.io/public' }
}
android {
signingConfigs {
debug {
storeFile file(DEBUG_STORE_FILE)
}
release {
storeFile file(RELEASE_STORE_FILE)
storePassword RELEASE_STORE_PASSWORD
keyAlias RELEASE_KEY_ALIAS
keyPassword RELEASE_KEY_PASSWORD
v2SigningEnabled false
}
}
compileSdkVersion 27
flavorDimensions "default"
defaultConfig {
applicationId "com.puma.one8crew"
minSdkVersion 21
targetSdkVersion 27
vectorDrawables.useSupportLibrary = true
versionCode 1
multiDexEnabled true
versionName "1.0"
resValue 'string', 'facebook_app_id', FACEBOOK_APP_ID_DEV
resValue 'string', 'fb_login_protocol_scheme', FACEBOOK_LOGIN_PROTOCOL_SCHEME
manifestPlaceholders += [
FACEBOOK_APP_ID_BGY: FACEBOOK_APP_ID_DEV,
FB_LOGIN_SCHEME : FACEBOOK_LOGIN_PROTOCOL_SCHEME
]
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dataBinding {
enabled = true
}
buildTypes {
debug {
minifyEnabled false
signingConfig signingConfigs.debug
}
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.release
}
}
/* productFlavors {
prod {
resValue 'string', 'facebook_app_id', FACEBOOK_APP_ID_DEV
resValue 'string', 'fb_login_protocol_scheme', FACEBOOK_LOGIN_PROTOCOL_SCHEME
}
stage {
resValue 'string', 'facebook_app_id', FACEBOOK_APP_ID_DEV
resValue 'string', 'fb_login_protocol_scheme', FACEBOOK_LOGIN_PROTOCOL_SCHEME
}
}*/
applicationVariants.all { variant ->
variant.outputs.all { output ->
def project = "one8crew"
outputFileName = "${project}_${variant.buildType.name}_${variant.versionName}.apk"
}
}
dexOptions {
javaMaxHeapSize "4g" //specify the heap size for the dex process
preDexLibraries = true //delete the already predexed libraries
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation project(':core')
implementation 'com.android.support:animated-vector-drawable:27.0.1'
implementation 'com.android.support:customtabs:27.0.1'
implementation 'com.android.support:cardview-v7:27.0.1'
implementation 'com.android.support:appcompat-v7:27.0.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.facebook.android:facebook-android-sdk:4.31.0'
implementation 'com.android.support:recyclerview-v7:27.0.1'
implementation 'com.google.firebase:firebase-messaging:12.0.1'
implementation 'com.google.android.gms:play-services-auth:12.0.1'
implementation 'com.android.support:support-v4:27.0.1'
implementation 'com.android.support:design:27.0.1'
implementation 'com.android.support:support-v13:27.0.1'
implementation 'com.alimuzaffar.lib:pinentryedittext:1.3.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
//Dependencies for LifeCycle Android ViewModel
implementation 'android.arch.lifecycle:extensions:1.1.1'
implementation project(':com.wowza.gocoder.sdk')
implementation 'com.skyfishjy.ripplebackground:library:1.0.1'
//support design lib dependency fot tab
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation('com.crashlytics.sdk.android:crashlytics:2.9.1#aar') {
transitive = true;
}
}
Below is my core build.gradle and I have also updated the same version for all lib.
core build.gradle:
apply plugin: 'com.android.library'
android {
compileSdkVersion 27
defaultConfig {
minSdkVersion 21
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
dataBinding {
enabled = true
}
repositories {
flatDir {
dirs 'libs'
}
jcenter()
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
compileOnly 'com.wowza.gocoder.sdk.android:com.wowza.gocoder.sdk:1.0b7#aar'
// compile 'android.arch.lifecycle:extensions:1.1.1'
implementation 'com.google.dagger:dagger:2.11'
api('com.squareup.retrofit2:retrofit:2.1.0') {
exclude module: 'okhttp'
}
api 'com.google.code.gson:gson:2.8.1'
api 'com.squareup.retrofit2:converter-gson:2.3.0'
api 'swarajsaaj:otpreader:1.1'
api 'com.github.bumptech.glide:glide:4.3.0'
annotationProcessor 'com.google.dagger:dagger-compiler:2.11'
//Dependencies for LifeCycle Android ViewModel
implementation 'android.arch.lifecycle:extensions:1.1.1'
// annotationProcessor "android.arch.lifecycle:compiler:1.1.1"
compileOnly project(':com.wowza.gocoder.sdk')
compile project(':libraries:horizontalcalendar')
compile project(':libraries:calendarview')
//Library for setting fonts
api 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'com.android.support:multidex:1.0.3'
}
I tried so many time and I am not able to understand the reason behind this issue.
Same happened today to me and this is what solved the issue:
Find all the dependencies of com.google.android.gms:play-services.
They all have now different versions. Just place the mouse over them and correct the version numbers (i.e. for me was upgrading maps from 15.0.0 to 15.0.2 and tag-manager to 15.0.1)