Expected Android API level 21+ but was 30 - android

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'

Related

Android Studio Dependency 'androidx.browser:browser:1.4.0' requires 'compileSdkVersion' to be set to 31 or higher

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')

RecyclerView for API 26 - android

I was making an application (API 26) which uses RecyclerView. I use the following line in my build l.gradle
dependencies {
implementation 'com.android.support:recyclerview-v7:28.0.0'
}
But however this doesn't work of API 26. Is there any way that I can use Recyclerview for API 26. Thank you!
Why don't you use androidX?
To know more details about it you can visit https://developer.android.com/jetpack/androidx
dependencies {
implementation 'androidx.recyclerview:recyclerview:1.1.0'
}

ERROR: Failed to resolve: com.google.firebase:firebase-messaging:19.2.0 [duplicate]

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.

Retrofit 2 on sdk < 21

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

Cannot resolve symbol 'FirebaseAuth'

Why am I getting this error? My repository and Google play services are up to date and I've used all the requires steps for using Firebase like copying firebase code in both build.gradle(Project and app). The intellisence doesn't even show FirebaseAuth but displays other members of Firebase.
Solved the error by adding this to the build.gradle file(for app) -
implementation 'com.google.firebase:firebase-auth:18.0.0'
implementation 'com.google.android.gms:play-services-gcm:17.0.0'
The 2nd dependency is to solve the version conflict error.
Add this dependency to Gradle.Build(Module:App)
compile "com.google.firebase:firebase-auth:9.0.2"
then sync with gradle :)
Add these two dependencies into your build.gradle
as 'compile' is replaced by 'implementation'
dependencies {
implementation 'com.google.firebase:firebase-auth:16.0.4'
implementation "com.google.android.gms:play-services-gcm:16.0.0"
}
***For the latest android studio version 3.0 and new ones ***
Same problem. Clean your project with "Build"->"Clean Project".
add the following to the build.gradle (app)
implementation 'com.google.firebase:firebase-auth:9.2.1'
For me this worked with all the firebase extensions:
eg.:
Android studio adds the following line to your gradle file:
implementation 'com.google.firebase:firebase-auth:16.0.1:15.0.0'
You have to change it to:
implementation 'com.google.firebase:firebase-auth:16.0.1'
and add:
kapt 'com.google.firebase:firebase-auth:16.0.1:15.0.0'
I have android studio 3.3.1 installed. Compile is replaced with implementation. So you have to write
implementation 'com.google.firebase:firebase-auth:16.1.0'
You should replace version according to the warning you get.
on dependencies in app gradle
implementation 'com.google.firebase:firebase-core:16.0.1'
implementation 'com.google.firebase:firebase-auth:16.0.1'
this is useful android 3.0 and onwards versions auth:16.0.1 and
core:16.0.1Firebase will work
Solved the error by adding this to the build.gradle file(for app) -
compile 'com.google.firebase:firebase-auth:9.2.1'
compile "com.google.android.gms:play-services-gcm:9.2.1"
You may need to make sure that your activity is importing the Firebase Auth module. In your .java file (eg. Login.java):
import com.google.firebase.auth.FirebaseAuth;
Please add the below line in your build.gradle file:
implementation 'com.google.firebase:firebase-auth:19.3.0'
implementation "com.google.android.gms:play-services-gcm:10.2.1"
In my case, I was using firebase-auth and firebase-messaging with different versions. So After getting an error I kept the same version for both e.g.
implementation 'com.google.firebase:firebase-auth:18.0.0'
implementation 'com.google.firebase:firebase-messaging:18.0.0'
After sync, my problem was solved. try to keep the version the same for firebase libraries
implementation 'com.google.firebase:firebase-auth:16.0.1'
make sure your firebase and all the dependency are the same versions.

Categories

Resources