Dependecies for CardView and RecyclerView in SDK version 28 - android

I am trying to add CardView and RecyclerView dependencies in my Android Studio Project for SDK version 28. Upon building the project, I get the message, "Gradle Project Sync Failed. Basic Functionality will not work properly".
build.gradle(Module:app) file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.kavyabarnadhyahazarika.quarterallotmentiocl"
minSdkVersion 16
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '28.0.0'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.mcxiaoke.volley:library:1.0.19'
testImplementation 'junit:junit:4.12'
}
Error Messages:
Failed to resolve: com.android.support:cardview-v7:28.0.0
Failed to resolve: com.android.support:recyclerview-v7:28.0.0
I have tried both build and clean project.
Also if these dependencies are not supported on SDK version 28, how do I resolve the issue?

There is no 28.0.0 final release as of yet - just like your appcompat-v7 dependency, cardview-v7 and recyclerview-v7 should have a version of 28.0.0-alpha3:
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3'
implementation 'com.android.support:cardview-v7:28.0.0-alpha3'
implementation 'com.android.support:recyclerview-v7:28.0.0-alpha3'

This works for me.
// RecyclerView
implementation 'com.android.support:recyclerview-v7:+'
// CardView
implementation 'com.android.support:cardview-v7:+'

Here's a working solution.
replace the following dependencies
implementation 'com.android.support:cardview-v7:28.0.0-alpha3'
implementation 'com.android.support:recyclerview-v7:28.0.0-alpha3'
or
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
with the below implementations
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
I hope it helps.

Related

build.gradle dependencies have same version specification but still shows mixed versions error

I have read the thread at All com.android.support libraries must use the exact same version specification and many other such threads but none of the answers have solved my problem.
Errors:-
1.) For implementation 'com.android.support:appcompat-v7:26.1.0'
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 27.1.1, 26.1.0. Examples include com.android.support:animated-vector-drawable:27.1.1 and com.android.support:cardview-v7: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).
2.) on building the project
Error: Program type already present:
android.support.design.widget.CoordinatorLayout$Behavior
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "freview1.com.freview"
minSdkVersion 21
targetSdkVersion 26
versionCode 2
versionName '2.2.1'
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
//vectorDrawables.useSupportLibrary = true
versionNameSuffix '-alpha'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
/*
ext {
supportLibVersion = '26.1.0' // variable that can be referenced to keep support libs consistent
}
*/
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support:percent:26.1.0'
implementation 'com.android.support:support-vector-drawable:26.1.0' // VectorDrawableCompat
implementation 'com.android.support:animated-vector-drawable:26.1.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.google.firebase:firebase-auth:16.0.3'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
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.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
implementation 'com.squareup.picasso:picasso:2.5.2'
}
apply plugin: 'com.google.gms.google-services'
if you want add an library to your project , best way is :
in android studio : (from toolbar) file \ Project Structure ... \ (from left window , under modules ) app \ Dependencies \ [use green plus]
for example if you want use compileSdkVersion 27 , your import code should be like this :
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "your project"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:support-v4:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-vector-drawable:27.1.0'
implementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.android.support:recyclerview-v7:27.1.0'
implementation 'com.android.support.test.espresso:espresso-core:3.0.1'
}
It's work for me , and if you want use compileSdkVersion 28 , your import code should be like this :
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "your project"
minSdkVersion 14
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '28.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'junit:junit:4.12'
implementation 'com.android.support:support-v13:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support.test.espresso:espresso-contrib:3.0.2'
implementation 'com.google.android.gms:play-services-maps:15.0.1'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:mediarouter-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:2.0.0-alpha2'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:support-annotations:28.0.0'
}
It's work for me too .
Many of these problems will disappear with the help of a new library and you will have more efficient classes.
I hope it's work for you .
This version can help you , I test it , it's working :
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.0.0-beta1'
implementation 'com.android.support:support-v4:26.0.0-beta1'
implementation 'com.android.support:design:26.0.0-beta1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
implementation 'com.android.support:gridlayout-v7:26.0.0-beta1'
implementation 'com.android.support:recyclerview-v7:26.0.0-beta1'
implementation 'com.android.support:cardview-v7:26.0.0-beta1'
}
Ok , I finally find your solution , Just add this Lines :
repositories {
mavenCentral()
maven { url "https://maven.google.com" }
}
for example :
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "your app id"
minSdkVersion 14
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.android.support:design:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:0.5'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:2.2.2'
implementation 'com.android.support:gridlayout-v7:26.1.0'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
}
repositories {
mavenCentral()
maven { url "https://maven.google.com" }
}
It's mostly happens when you use Libraries that uses old version of AppCompat. It happens to me all the time when I use switchButton library. for last 6 month it didn't impact anything, it's just a false alarm.

Firebase libraries must be either above or below 14.0.0 after connecting firebase to android studio

So I was having no package found problem which I solved By authenticating and syncing firebase in android studio, after that I suddenly started having this issue when I sync gradle. Here is My file.
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "APP NAME"
minSdkVersion 15
targetSdkVersion 27
versionCode 42
versionName '3.7'
}
dexOptions {
jumboMode true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
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
}
productFlavors {
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.mcxiaoke.volley:library:1.0.19'
implementation 'com.github.chrisbanes.photoview:library:1.2.3'
implementation 'com.facebook.android:facebook-android-sdk:4.+'
implementation 'com.pkmmte.view:circularimageview:1.1'
implementation 'com.melnykov:floatingactionbutton:1.3.0'
implementation 'com.squareup.okhttp:okhttp:2.5.0'
implementation 'com.github.bumptech.glide:glide:3.7.0'
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:animated-vector-drawable:27.1.1'
implementation 'com.android.support:mediarouter-v7:27.1.1'
implementation 'com.android.support:customtabs:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'com.balysv:material-ripple:1.0.2'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.google.firebase:firebase-ads:15.0.1'
implementation 'com.google.firebase:firebase-messaging:17.0.0'
implementation 'com.google.android.gms:play-services-gcm:15.0.1'
implementation 'com.google.android.gms:play-services-ads:15.0.1'
implementation 'com.google.firebase:firebase-auth:11.6.0'
compile 'com.google.firebase:firebase-core:16.0.0'
}
apply plugin: 'com.google.gms.google-services'
I am unable to figure what suddenly went wrong here, I minute there is no problem,just a problem related to package name in json file/firebase sync and then when that is solved this popped up.
This dependency is violating the statement made in the error message:
com.google.firebase:firebase-auth:11.6.0
You should update it:
com.google.firebase:firebase-auth:16.0.3
The latest versions of all the libraries are listed here.

Cannot resolve symbol 'CalligraphyContextWrapper'

Till yesterday everything was working fine but today i have updated my Android studio from 2.3 to 3.1 and i am getting this error now. But even i am getting Cannot resolve symbol CalligraphyContextWrapper, still project is successfully clean and build and the font is changing fine. I am surprised if everything is working fine then why this error appears. You can see the error in image and also i am adding my gradle code below. Please let me know if i am doing something wrong.
build.grade:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId "com.package"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
androidTestImplementation('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:27.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testImplementation 'junit:junit:4.12'
implementation 'com.android.support:design:27.0.0'
implementation 'com.android.support:cardview-v7:27.0.0'
/* Retrofit */
implementation 'com.squareup.retrofit2:retrofit:2.3.0'
implementation 'com.squareup.retrofit2:converter-gson:2.3.0'
implementation 'com.squareup.okhttp3:logging-interceptor:3.4.1'
implementation 'com.squareup.retrofit2:adapter-rxjava2:2.3.0'
implementation 'com.google.code.gson:gson:2.7'
implementation 'com.squareup.okhttp3:okhttp:3.4.2'
//multi dex
implementation 'com.android.support:multidex:1.0.1'
//Picasso
implementation 'com.squareup.picasso:picasso:2.5.2'
//Buimplementationtter knife
implementation 'com.jakewharton:butterknife:8.8.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:8.8.1'
//planet payment gateway
implementation 'com.google.android.gms:play-services-wallet:11.0.4'
//font
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'io.card:android-sdk:5.5.1'
}
I have also raised the issue in github but there is no response from Calligraphy team.
https://github.com/chrisjenx/Calligraphy/issues/449#issuecomment-386390551
Any help or clue will be appreciated.
You can Downgrade version. Use 2.2.0 instead of 2.3.0.
implementation 'uk.co.chrisjenx:calligraphy:2.2.0'
Then Clean-Rebuild-Run.
I am not sure if it is related but I've resolved a similar issue by doing the following;
Remove the dependency from gradle build file
Sync the gradle file
Put the same dependency and sync it again.

How to Solve Error:Unable to merge dex

I'm following an Tutorial from youtube and now I ran into an problem. When I sync the build File. Build Completes without any Error but when I run app connecting my Device it give me error of
Error:Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'.
java.lang.RuntimeException: java.lang.RuntimeException: com.android.builder.dexing.DexArchiveMergerException: Unable to merge dex
But when I remove the line
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
It works Fine, but I need this library. So How can I resolve it.
My app build.gradle file is
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.nepalpolice.cdp"
minSdkVersion 21
targetSdkVersion 26
versionCode 2
versionName "2.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation 'com.google.firebase:firebase-auth:11.0.4'
implementation 'com.google.firebase:firebase-storage:11.0.4'
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
implementation 'com.android.support:appcompat-v7:26.+'
implementation 'com.android.support:support-v4:26.+'
implementation 'com.android.support:cardview-v7:26.+'
implementation 'com.google.firebase:firebase-messaging:11.0.4'
implementation 'com.google.gms:google-services:3.1.0'
implementation 'com.android.support:design:26.+'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.android.support:multidex:1.0.1'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.6.+'
implementation 'com.android.support:gridlayout-v7:26.+'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
implementation 'com.google.android.gms:play-services-maps:11.0.4'
}
apply plugin: 'com.google.gms.google-services'
and inside my lib folder , I have volley jar file.
I tried below solution but it didn't work for me.
One
android {
defaultConfig {
multiDexEnabled true
}
}
and also using
compile 'com.android.support:multidex:1.0.1'
and also I deleted .gradle file and clean and rebuild project but didn't help either.
How can I solve this?? Thanks in advance.
This issue happened to me and the solution was about the release of the image cropper library.
In my case and as well yours, the SDK is 26 so you need to compile 2.5.1 version, not 2.6.0:
implementation 'com.theartofdev.edmodo:android-image-cropper:2.5.1'
Android Image Cropper releases

Adding dagger2 to android studio 3.1 preview

Can anyone tell my why dagger2 isn't working for me in Android Studio 3.1 preview?
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.2'
defaultConfig {
applicationId "com.orbitlab.mowerapp"
minSdkVersion 23
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:26.1.0'
implementation 'com.google.firebase:firebase-messaging:11.4.2'
implementation 'com.google.firebase:firebase-database:11.4.2'
implementation 'com.google.firebase:firebase-auth:11.4.2'
implementation "com.google.firebase:firebase-firestore:11.4.2"
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'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.google.code.gson:gson:2.8.2'
implementation 'com.github.bumptech.glide:glide:4.3.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.3.1'
implementation 'com.android.support:customtabs:26.1.0'
implementation 'com.google.android.gms:play-services-fitness:11.4.2'
implementation 'com.google.android.gms:play-services-auth:11.4.2'
implementation 'com.squareup.retrofit2:retrofit:2.2.0'
implementation 'com.squareup.retrofit2:converter-gson:2.2.0'
annotationProcessor 'com.google.dagger:dagger-compiler:2.10'
implementation 'com.google.dagger:dagger:2.10'
}
apply plugin: 'com.google.gms.google-services'
This is how my app's build.gradle file looks like. I haven't added anything in the project's build.gradle file.
Can anyone help?
Edit:
The gradle syncs now, but i get dex errors when trying to deploy to my device (havent used Dagger in this project yet).
The error is:
Execution failed for task ':app:transformDexArchiveWithExternalLibsDexMergerForDebug'
Try to update dagger version and check it like this.
annotationProcessor 'com.google.dagger:dagger-compiler:2.10'
implementation 'com.google.dagger:dagger:2.10'
You need to add following code to gradle file,
android {
defaultConfig {
multiDexEnabled true
}
}
Then,
1.Clean your project
2.Build the code

Categories

Resources