How to use support library graddle.app in Kotlin? - android

I want to make a To-Do app in Kotlin. I opened the Android Studio.
What is the reason for this difference?
Android Studio version: Android Studio 3.5
Build #AI-191.8026.42.35.5791312, built on August 9, 2019
JRE: 1.8.0_202-release-1483-b03 amd64
JVM: OpenJDK 64-Bit
Windows 10
My Gradle Scripts :
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.core:core-ktx:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}
This is the script in the video I watch:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:constraint:constraintlayout:1.1.2'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
}

Quoted from official doc:
Note: With the release of Android 9.0 (API level 28) there is a new
version of the support library called AndroidX which is part of
Jetpack. The AndroidX library contains the existing support library
and also includes the latest Jetpack components.
You can continue to use the support library. Historical artifacts
(those versioned 27 and earlier, and packaged as android.support.*)
will remain available on Google Maven. However, all new library
development will occur in the AndroidX library.
We recommend using the AndroidX libraries in all new projects. You
should also consider migrating existing projects to AndroidX as well.

Related

Firebase UI Database Implementation

Tried to add Firebase UI implementation
implementation 'com.firebaseui:firebase-ui-database:6.2.0'
in build.gradle file.
The following error was shown.
*ERROR: Unable to resolve dependency for ':app#debug/compileClasspath': Could not resolve com.firebaseui:firebase-ui-database:6.2.0.
Affected Modules: app*
Please guide me how to resolve the issue.
I am using Android Studio 3.5.3
Other dependencies I have already implemented in the app
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-database:16.0.4'
You need to update the following dependencies:
implementation 'com.google.firebase:firebase-auth:16.0.5'
implementation 'com.google.firebase:firebase-database:16.0.4'
to
implementation 'com.google.firebase:firebase-auth:19.2.0'
implementation 'com.google.firebase:firebase-database:19.2.0
Also upgrade to androidX. Check the following for more information:
From the docs:
FirebaseUI version 6.0.0 has no breaking API changes from version 5.1.0 but updates critical dependencies to new major versions.
There are two major groups of changes:
Convert all Android Support Library dependencies to AndroidX or Jetpack dependencies. For information on migrating to AndroidX see this guide.
Update all Firebase and Google Play services dependencies to their latest major versions. For information on changes included in these SDKs visit the release notes.
You can follow these steps:
Press F4 to open Module settings
Select Dependency
Click Add new dependency
Type firebase, search for firebase.ui and add its latest dependency.
At last I was able to sync successfully without Error.
The final dependencies in the build.gradle file of the app.
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.lifecycle:lifecycle-extensions:2.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.2.0-alpha03'
implementation 'androidx.recyclerview:recyclerview:1.2.0-alpha01'
implementation 'com.google.firebase:firebase-auth:19.2.0'
implementation 'com.google.firebase:firebase-database:19.2.0'
implementation 'com.firebaseui:firebase-ui-database:6.2.0'

AndroidX Q material component not working

I have just started a new project with the latest version of Android studio 3.5.2. Min API - 19 and using SDK Q, which forces us to use AndroidX.
com.google.android.material.textfield.TextInputLayout
Giving error: Android resource linking failed.
With this setup, I am trying to user Material Component, but it is not working.
I am not sure if anything changed in AndroidX or Material component is already included or not. However, I have added the material dependency anyway.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
// here is the one
implementation 'com.google.android.material:material:1.2.0-alpha01'
}
So my issue is how can I use material components on this setup.

How to fix com.android.support libraries version error when I add firebase libraries

when I try to insert libraries as indicated by firebase, and I try to Sync the project, i get this error:
This support library should not use a different version (26) than the compileSdkVersion (27) less... (Ctrl+F1)
Inspection info:There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).
I tried to follow some guides (https://firebase.google.com/docs/android/setup?authuser=0) and past answers of this problem, but the error persists
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation 'com.google.firebase:firebase-auth:16.2.1'
implementation 'com.google.firebase:firebase-database:16.1.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
apply plugin: 'com.google.gms.google-services'
Make sure that you are using the same API level 27, for 27.1.1 android support, from your app build.gradle:
android {
compileSdkVersion 27
defaultConfig {
.
minSdkVersion 15
targetSdkVersion 27
.
.
.
}
.
}
UPDATE
This may be caused by conflicts with the firebase versions. See this question.
Try to add this implementations on dependences, to fix this conflicts:
def android_api = "27.1.1"
implementation "com.android.support:appcompat-v7:$android_api"
implementation "com.android.support:animated-vector-drawable:$android_api"
implementation "com.android.support:exifinterface:$android_api"
implementation "com.android.support:cardview-v7:$android_api"
implementation "com.android.support:customtabs:$android_api"
implementation "com.android.support:support-media-compat:$android_api"
implementation "com.android.support:support-v4:$android_api"
Update:
implementation 'com.android.support:support-media-compat:26.1.0'
to the following:
implementation 'com.android.support:support-media-compat:27.1.1'
So, it can be the same version as appcompat-v7

dependencies error when add firebase libraries

When add firebase in
dependencies
implementation 'com.google.firebase:firebase-core:16.0.6'
Or
implementation 'com.google.firebase:firebase-ads:17.1.2'
Or
implementation 'com.google.android.gms:play-services-ads:17.1.1
It shows error under implementation 'com.android.support:appcompat-v7:28.0.0' that All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes).
When I sync the app no error but when install the app it shows you app has been stopped (Crashing during run time).
When remove the firebase dependencies and run, my app it's working fine.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-
core:3.0.2'
implementation 'com.google.firebase:firebase-core:16.0.6'
implementation 'com.google.firebase:firebase-ads:17.1.2'
implementation 'com.google.android.gms:play-services-ads:17.1.1'
}
apply plugin: 'com.google.gms.google-services'
When you include dependencies, they too, will sometimes include dependencies of their own. Some of the firebase libraries happen to include support libraries at a lower version than 28. When you hover over the error message for appcompat-v7 it should tell you what library is lower than 28. You may have to click 'show more' on the error message. Once you figure out which one it is, include that exact same library but version 28. Resync your gradle and you're good to go. Also, you might have to do this multiple times because some firebase libraries include multiple lower version support libraries and the error message will only show you one library at a time.

Android Studio 3.1.4 implementation 'com.android.support:appcompat-v7:28.0.0-rc01' error

is there any fix to this error?
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
Error Log:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0-rc01, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0-rc01 and com.android.support:support-media-compat:26.1.0 less... (Ctrl+F1)
There are some combinations of libraries, or tools and libraries, that are incompatible, or can lead to bugs. One such incompatibility is compiling with a version of the Android support libraries that is not the latest version (or in particular, a version lower than your targetSdkVersion).
what does it need me to do?
Here is my gradle file:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
compile 'com.google.firebase:firebase-core:16.0.0'
Just follow the instructions and the error will be gone. Add the following dependencies to the gradle file because you must have to use the same version of library in your project for smooth operation of app.
implementation 'com.android.support:animated-vector-drawable:28.0.0-rc01'
implementation 'com.android.support:support-media-compat:28.0.0-rc01'
Actually android studio provides all the information (errors and warning) to ease the development.
And also a suggestion change the compile to implementation in the firebase-core library

Categories

Resources