Could not resolve dependency for retrofit - android

I still got error even after changing retrofit 2.3.0 to 2.6.2 I am stucking with this for a long time please help me to resolve this
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.blog"
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
implementation 'com.squareup.retrofit2:retrofit:2.6.2'
implementation 'com.squareup.retrofit2:convertor-gson:2.6.2'

Your external libraries should be inside dependencies.
It should something like below
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.blog"
minSdkVersion 15
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies{
// other external libraries
implementation 'com.squareup.retrofit2:retrofit:2.6.2'
implementation 'com.squareup.retrofit2:convertor-gson:2.6.2'
}

Related

Android wear application from targetSDk 28 to 30

I m upgrading my Android wear project using Android Studio.
So I change the follow code:
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.medicinanucleare.cardio"
minSdkVersion 26
targetSdkVersion 28
versionCode 4
versionName "1.3"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
with this:
android {
compileSdkVersion 30
defaultConfig {
applicationId "com.medicinanucleare.cardio"
minSdkVersion 26
targetSdkVersion 30
versionCode 4
versionName "1.3"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = '1.8'
targetCompatibility = '1.8'
}
}
as you can see I change the targetSdkVersion from 28 to 30.
But now I have some errore on build.gradle file:
implementation 'com.android.support:percent-v4:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:wear:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
these lines are not recognized. I try also to comment the code but I have this error while I try to compile the application:
java.lang.RuntimeException: Duplicate class android.support.v4.app.INotificationSideChannel found in modules core-1.3.2-runtime.jar (androidx.core:core:1.3.2) and support-compat-28.0.0-runtime.jar (com.android.support:support-compat:28.0.0)
I try also to migrande application to Androidx but the operation failed.

android.support:appcompat-v7 and android.support:design is not working for api 30

hello i am making a app that requires api 29+ but
'com.android.support:appcompat-v7:28.0.0'
'com.android.support:design:28.0.0'
this two library is not supported api 29 or 30 how can i fix my issue?
heres my build.gradle (:app)
......................................................................................................................................................................................
android {
compileSdkVersion 30
defaultConfig {
applicationId "uk.lgl.modmenu"
minSdkVersion 17
//noinspection ExpiredTargetSdkVersion
targetSdkVersion 30
versionCode 1
versionName "1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
ndk {
abiFilters 'armeabi-v7a', 'arm64-v8a', 'x86'
}
signingConfig signingConfigs.debug
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
externalNativeBuild {
ndkBuild {
path file('src/main/jni/Android.mk')
}
}
ndkVersion = '23.1.7779620'
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
}
}
You should switch to using the AndroidX versions of those libraries. Such as:
androidx.appcompat:appcompat:1.4.1

java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex || Android

**
While runing the code I encounter this error "Unable to merge dex || Android in the android studio
This is basically use of map in the android application**
This is the Build.gradle code
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.npatel7.carparking"
minSdkVersion 24
targetSdkVersion 26
versionCode 1
versionName "image1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
repositories {
mavenCentral()
}
}
Please assist me

Handheld multi flavor app with single wear project

My project was working fine when I had just a simple handheld app with one wear app.
Now, I've introduced three flavors to the handheld app and kept the same single flavor wear app.
The problem is that release builds are not being pushed to the wearable.
My project looks like this:
smartphone's build.gradle:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 8
versionName "3.1.0"
applicationId "br.com.test"
}
signingConfigs {
...
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig = android.signingConfigs.release
}
debug {
applicationIdSuffix ".debug"
versionNameSuffix "-debug"
zipAlignEnabled true
}
}
productFlavors {
generic {
applicationId "br.com.generic"
}
abc {
applicationId "br.com.teste.abc"
}
company {
applicationId "br.com.test.company"
}
}
}
dependencies {
genericWearApp project(path:':wear', configuration: 'genericRelease')
abcWearApp project(path:':wear', configuration: 'abcRelease')
companyWearApp project(path:':wear', configuration: 'companyRelease')
compile project(':common')
}
and wear's build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
publishNonDefault true
defaultConfig {
minSdkVersion 14
targetSdkVersion 23
versionCode 8
versionName "3.1.0"
applicationId "br.com.test"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".debug"
versionNameSuffix "-debug"
zipAlignEnabled true
}
}
productFlavors {
generic {
applicationId "br.com.generic"
}
abc {
applicationId "br.com.teste.abc"
}
company {
applicationId "br.com.test.company"
}
}
}
dependencies {
compile project(':common')
}
Why does the wearable does not gets the app? Any tips?
I was only a matter of tricky details... This repo offers a really nice example and was enough to help me solve this:
https://github.com/vngrs/PomoPomoAndroid/

Gradle BuildConfigFields Syntax

What could be wrong with this syntax? I am getting Gradle DSL method not found:'buildConfigFields()' error.
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.okason.drawingapp"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
def filesAuthorityValue = applicationId + ".files"
//Now you can use ${filesAuthority} in your manifest
manifestPlaceholders = [filesAuthority: filesAuthorityValue]
//Now you can use BuildConfig.FILES_AUTHORITY in our code
buildConfigFields "String", "FILES_AUTHORITY", "\"${filesAuthorityValue}\""
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
you should be using buildConfigField and not buildConfigFields
Change
//Now you can use BuildConfig.FILES_AUTHORITY in our code
buildConfigFields "String", "FILES_AUTHORITY", "\"${filesAuthorityValue}\""
to
//Now you can use BuildConfig.FILES_AUTHORITY in our code
buildConfigField "String", "FILES_AUTHORITY", "\"${filesAuthorityValue}\""
are you sure that buildConfigFields even exits ?

Categories

Resources