I used Retrofit library in my android application. My project's minSDK is 16. Now I see that my apps not working on SDK < 21 because of retrofit version. My retrofit version:
implementation 'com.squareup.retrofit2:retrofit:2.6.1'
implementation 'com.squareup.retrofit2:converter-gson:2.6.1'
I tested OkHttp 2 but it is not adapted with my retrofit. What should I do?
The problem is that OkHttp3, from version 3.13.0 upped its minimum SDK version to API 21+.
If you just want to do basic HTTP(s) requests and do not care about TLS 1.2, then you can just exclude that specific version and use 3.12.13 which is the last version to support minSDK 9+.
implementation("com.squareup.retrofit2:retrofit:2.9.0") {
exclude group: "com.squareup.okhttp3"
}
implementation "com.squareup.okhttp3:okhttp:3.12.13"
Add this to your build.gradle file and things should start working. However, from the next version, you should ideally be removing this and up your minSDK level to 21+.
Add these lines in build gradle file:
// retrofit, gson
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.2'
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.3.0'
implementation 'com.squareup:otto:1.3.8'
implementation 'com.google.code.gson:gson:2.8.5'
This is complete package of retrofit
Related
I've been working with Android Studio only for a short time and it's giving me a lot of grief. I have a project that (so far) requires
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.5.0"
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-android:1.5.0"
implementation 'androidx.core:core-ktx:1.7.0'
implementation "androidx.compose.ui:ui:$compose_version"
implementation "androidx.compose.material:material:$compose_version"
implementation "androidx.compose.ui:ui-tooling-preview:$compose_version"
implementation 'androidx.lifecycle:lifecycle-extensions:2.2.0'
implementation "androidx.lifecycle:lifecycle-livedata-ktx:2.3.1"
implementation "androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1"
// added 8/29
implementation "androidx.lifecycle:lifecycle-viewmodel-compose:2.3.1"
implementation 'androidx.activity:activity-compose:1.3.1'
// added
implementation 'androidx.navigation:navigation-compose:2.4.0'
// hilt
implementation "com.google.dagger:hilt-android:$hilt_version"
implementation 'androidx.datastore:datastore-core:1.0.0'
kapt "com.google.dagger:hilt-android-compiler:$hilt_version"
implementation("androidx.hilt:hilt-navigation-compose:1.0.0")
// datastore
implementation "androidx.datastore:datastore-preferences:1.0.0"
where
compose_version = '1.1.0-beta03'
hilt_version = '2.40'
kotlin_version = '1.5.30' //'1.4.32'
I've spent several hours trying to find a good set that does result in build warnings because of conflicting JDK version reported as well as messages saying I have to build using API 32 or 33 when I really want API 29. If I can build at 33 but still have minSDK of 29, that would work too.
I think a web tool where I could list the libraries and the API and it would give me the version numbers of the libraries, that would solve my problem.
Any suggestions? BTW - I'm using the Chipmunk.
currently my sdk version is 29.
I've added firebase imports in gradle and it works fine for the database and firestore.
But when I add the import for the firebase auth I get this error.
One or more issues found when checking AAR metadata values:
Dependency 'androidx.browser:browser:1.4.0' requires 'compileSdkVersion' to be set to 31 or higher.
Compilation target for module ':app' is 'android-29'
I've tried importing with no version (in firebase documentation firebase bom select the version automatic and I've tried setting the version to implementation 'com.google.firebase:firebase-auth:21.0.6' but I get the same error)
Here is a piece of my gradle file:
implementation platform('com.google.firebase:firebase-bom:30.1.0')
implementation 'com.google.firebase:firebase-analytics'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
implementation 'com.google.firebase:firebase-firestore'
implementation 'com.google.firebase:firebase-auth'
The problem is the firebase-auth because if I comment the line of code the app runs fine
Fixed by setting the implementation of firebase bom to the version of 29:
implementation platform('com.google.firebase:firebase-bom:29.3.1')
How is it possible that I get this message? It does not make any sense.
I'm using com.squareup.retrofit2:retrofit:2.9.0
Caused by: java.lang.IllegalStateException: Expected Android API level 21+ but was 30
at okhttp3.internal.platform.AndroidPlatform$Companion.buildIfSupported(AndroidPlatform.kt:370)
at okhttp3.internal.platform.Platform$Companion.findPlatform(Platform.kt:204)
at okhttp3.internal.platform.Platform$Companion.access$findPlatform(Platform.kt:178)
2020-09-16 12:37:07.645 6480-6480/lv.ltt.gasogmp.dev_v3 E/AndroidRuntime: at
okhttp3.internal.platform.Platform.<clinit>(Platform.kt:179)
Add an explicit dependency on OkHttp 4.9.0. Or whatever is newest at the time you read this.
This bug is embarrassing but it's been fixed for so long that you shouldn’t be encountering it in new code.
Just Add the Dependency implementation 'com.squareup.okhttp3:okhttp:4.9.2'
PS - Check the latest version here before you add the dependency https://mvnrepository.com/artifact/com.squareup.okhttp3/okhttp
Add implementation 'com.squareup.okhttp3:okhttp:4.9.2' inside android\app\build.gradle
dependencies {
........
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.squareup.okhttp3:okhttp:4.9.2'
..........
}
Upgrage Okhttp3 or retrofit version
Latest Okhttp3 version is 4.9.2
Latest Retrofit version is 2.9.0
implementation 'com.squareup.okhttp3:okhttp:4.9.2'
implementation 'com.squareup.retrofit2:retrofit:2.9.0'
This question already has an answer here:
How to fix "manifest merger error" due to the Firebase Database implementation
(1 answer)
Closed 3 years ago.
implementation 'com.google.firebase:firebase-messaging:19.2.0'
implementation 'com.firebaseui:firebase-ui-database:2.1.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.github.bumptech.glide:glide:4.11.0'
implementation 'jp.wasabeef:glide-transformations:2.0.1'
implementation 'frankiesardo:icepick:3.2.0'
implementation 'org.greenrobot:eventbus:3.1.1'
implementation 'com.jakewharton:butterknife:10.2.1'
implementation 'com.zsoltsafrany:needle:1.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.2.1'
compileOnly 'frankiesardo:icepick-processor:3.2.0'
implementation 'joda-time:joda-time:2.10.5'
testImplementation 'junit:junit:4.13
this is my build.gradle code
i have attched the image of my code and therror am getting pls help me with resolveing this error
Update the dependency to the following:
implementation 'com.google.firebase:firebase-messaging:20.1.0'
Also it seems you are using the android support libraries. But the newest version of firebase support androidx and not com.android.support. Therefore you need to do the following:
The updated libraries will not work unless you make the following changes in your app:
- Upgrade com.android.tools.build:gradle to v3.2.1 or later.
- Upgrade compileSdkVersion to 28 or later.
- Update your app to use Jetpack (AndroidX); follow the instructions in Migrating to AndroidX.
Check the following for more info:
https://developer.android.com/jetpack/androidx/migrate
https://firebase.google.com/support/release-notes/android#2019-06-17
There is no Firebase Cloud Messaging Library with Version 19.2.0
Change it to :
com.google.firebase:firebase-messaging:20.1.0
If you don't want to migrate with android x just try using :
Versions before 17 June. I don't recommand this as solution.
Please Read on this you will find Release Notes.
I am developing a project in which I have used Firebase and Google Play service maps and location. Here is my app-level build Gradle file.
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.gridlayout:gridlayout:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation "com.google.android.gms:play-services-location:$playServicesVersion"
implementation "com.google.android.gms:play-services-maps:$playServicesVersion"
implementation 'com.google.android.libraries.places:places:2.0.0'
implementation "com.google.firebase:firebase-core:$firebaseCoreVersion"
implementation "com.google.firebase:firebase-perf:$firebasePerfVersion"
implementation "com.google.firebase:firebase-messaging:$firebaseMessagingVersion"
implementation "com.crashlytics.sdk.android:crashlytics:$crashlyticsVersion"
// Room
implementation 'androidx.room:room-runtime:2.1.0'
annotationProcessor 'androidx.room:room-compiler:2.1.0'
// LiveData and ViewModel
implementation 'androidx.lifecycle:lifecycle-extensions:2.0.0'
implementation 'androidx.lifecycle:lifecycle-common-java8:2.0.0'
implementation "net.danlew:android.joda:$jodaTimeVersion"
// Annotations
implementation 'androidx.annotation:annotation:1.1.0'
implementation "com.squareup.picasso:picasso:$picassoVersion"
dependencies {
implementation 'com.github.TouchBoarder:weekdays-buttons-bar:v1.0.2'
}
Now, this all works fine and the application runs normally. But when I tried to add below line:
implementation 'com.google.android.gms:play-services-ads:17.0.0'
then the following error comes
cannot fit requested classes in a single dex file
I have searched that and found out some solutions like multi dex enabled and minifyenabled for debug but the when these solutions applied then the app runs and crash on start always.
I also applied the solution of removing some libraries just to check whether Google Ads gradle library can be added but it shows the same error. Even if I remove 3-4 libraries and add one Google Ad library then the error still the same.
What to do in this case.
Please make sure you are using the same version of all libs of Google Play Services. Also, enable multidex for your application.
implementation "androidx.multidex:multidex:2.0.1"
prior approach:
Instead of implementing entire ads library, you should implement only required one...
Check out this link for further info:
Other Approach.
You can follow this link.
Versions of the platform prior to Android 5.0 (API level 21) use the Dalvik runtime for executing app code. By default, Dalvik limits apps to a single classes.dex bytecode file per APK. In order to get around this limitation, you can add the multidex support library to your project:
dependencies {
implementation 'com.android.support:multidex:1.0.3'
}
If your minSdkVersion is set to 21 or higher, all you need to do is set multiDexEnabled to true in your module-level build.gradle file, as shown here:
android {
defaultConfig {
...
minSdkVersion 21
targetSdkVersion 28
multiDexEnabled true
}
...
}
Hope you will have your solution.