Cannot access ActivityCompatApi23 class - android

I am having runtime problems with my gradle file. I added this compile 'com.google.android:flexbox:0.3.1' as a compile time dependency to my Gradle file. I encountered an error and added this in my project level Gradle file.
maven {
url "https://maven.google.com"
}
Which finally looked liked this after adding the above
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
After adding the above in my app level Gradle file I am now encountering a different error when I am trying to run my app. So I did the following as per some answers from SO.
Tried a Clean and Rebuild.
Navigated to the path projectName\.idea\libraries and deleted the files that contained the support library version other than the current versions 25.3.1
3.In order to solve the error I further removed this line from my app level Gradle file,
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
Now the final Gradle file looks like this with the error,
Error:
Error:(28, 8) error: cannot access ActivityCompatApi23
class file for android.support.v4.app.ActivityCompatApi23 not found
My Gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "com.example.test"
minSdkVersion 19
targetSdkVersion 25
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 {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.google.android:flexbox:0.3.1'
compile 'uk.co.chrisjenx:calligraphy:2.3.0'
testCompile 'junit:junit:4.12'
}

Like the Problem I meet。
When I Use Android Room like this :
compileSdkVersion 25
compile "android.arch.persistence.room:runtime:1.0.0"
I get the same Error.
Because compileSdkVersion should match support libs major version.
More Detail you can see this :
Error in support lib after room persistence
Room depends on 26.1 of support library, which is probably why it is broken because SupportLibrary does not promise interop between versions.
Also, you can fix the problem use this
compile ("android.arch.persistence.room:runtime:1.0.0") {
exclude group: 'com.android.support'
}

You have declared compileSdkVersion equal to 25, whereas 0.3.1 version of flexbox layout uses support libs version 26.0.0 - that's a problem, compileSdkVersion should match support libs major version.
Either upgrade your project to 26 or use a version of flexbox layout that relies on sdk 25, which seems to be v0.2.7:
compile 'com.google.android:flexbox:0.2.7'

use
compile 'com.android.support:appcompat-v7:26.1.0'

I just changed the line
compile 'com.android.support:appcompat-v7:26.0.0-alpha1'
to
compile 'com.android.support:appcompat-v7:26.+'
and it worked for me

Related

"All com.android.support libraries must use the exact same version specification" when compiling android.support:appcompat-v7:25.2.0

After updating Android Studio to Version 3.1.2 I'm getting an error in my app's build.gradle:
All com.android.support libraries must use the exact same version specification (...). Found versions 28.0.0-alpha1, 26.1.0. Examples include com.android.support:asynclayoutinflater:28.0.0-alpha1 and com.android.support:animated-vector-drawable:26.1.0
This is my gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "org.hopto.****.musicplayer"
minSdkVersion 23
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.cleveroad:audiowidget:0.9.0'
compile 'com.google.android.gms:play-services-ads:10.2.0'
compile 'com.android.support:recyclerview-v7:+'
testCompile 'junit:junit:4.12'
}
I've tried solving this by adding the following lines:
compile 'com.android.support:asynclayoutinflater:25.0.0'
compile 'com.android.support:animated-vector-drawable:25.0.0'
I've also tried this with different version, eg 25.2.0 and 25+, but none of this worked.
You are using the following support libraries:
compile 'com.android.support:appcompat-v7:25.2.0'
compile 'com.android.support:design:25.2.0'
compile 'com.android.support:recyclerview-v7:+' //error here
As you can see, your recyclerview library is using '+' which is the latest version available, that is 28.0.0-alpha1 or 26.1.0 (stable). For the rest you are using 25.2.0, thus the error with the version mismatch.
The solution is to either change recyclerview version to 25.2.0 or everything to 26.1.0 (including the recyclerview).
Side note: you should avoid using '+' in version numbers as you may come up with unexpected behavior when your libraries update.

Several Gradle errors in Android Studio

I try to use FireBase in my App but I get several Gradle error messages:
First, look at my build gradle (module app):
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.2"
defaultConfig {
applicationId "com.example.user.finalchat"
minSdkVersion 22
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 {
compile fileTree(dir: 'libs', include: ['*.jar'])
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.1.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.google.firebase:firebase-core:12.0.1'
compile 'com.firebaseui:firebase-ui-database:3.3.0'
compile 'com.android.support:design:26.0.0'
compile 'com.google.firebase:firebase-auth:12.0.1'
compile 'com.firebaseui:firebase-ui:3.3.0'
implementation 'com.firebaseui:firebase-ui-auth:3.3.0'
testCompile 'junit:junit:4.12'
}
When I sync my project, it throws me this error message:
Error:(27, 0) Gradle DSL method not found: 'implementation()' Possible
causes:The project 'Finalchat' may be using a version of the
Android Gradle plug-in that does not contain the method (e.g.
'testCompile' was added in 1.1.0).
The project 'Finalchat' may be using a version of Gradle that does not contain the method.
The build file may be missing a Gradle plugin
Edit: I read some questions regarding this problem, but my problem was not solved.
update build-tools via SDK Manager, then update your build.gradle to use the most recent buildToolsVersion (27.0.3 (stable), 28.0.0 (preview) atm).
Also replace all compile with implementation, the IDE will give you a warning. Also you may need to update your dependencies.
Do not downgrade, as this will break some day later.

AppCompat & Support library version for SDK Platform 26

I have already installed Android SDK Platform 26, Android SDK Tools 26.0.2
This is my app level build.gradle file.
build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion '26.0.0'
defaultConfig {
...
minSdkVersion 15
targetSdkVersion 26
...
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:26.0.2'
compile 'com.android.support:support-v4:26.0.2'
testCompile 'junit:junit:4.12'
}
I can't sync the gradle. I am getting these errors:
Error:(26, 13) Failed to resolve: com.android.support:appcompat-v7:26.0.2
Error:(27, 13) Failed to resolve: com.android.support:support-v4:26.0.2
Are the appcompat and support library versions are wrong?
How can I solve this issue? Please help.
Thanks in advance.
There are two things to it
First
This is the page that announces recent releases of the support library, and I don't see 26.0.2 version. The latest is 26.0.0-beta2 and
Note that 26.0.0-beta2 is a pre-release version
Second
Make sure you have google's maven repository included in you project's gradle file. Something like :
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
appcompat version must to match with SdkVersion.
Try this one
compile 'com.android.support:appcompat-v7:26.1.0'
compile 'com.android.support:design:26.1.0'

Manifest merger failed when adding Firebase-ui-auth in android

I am unable to configure Firebase-ui-auth in my app. I have tried all versions of firebase-ui-auth but have so far failed.
I read many questions related to firebase-ui-auth but none have helped. I do not want to change my current SDK version.
I have added the below line in gradle.build(Project:Project_Name) :
maven { url 'https://maven.fabric.io/public' }
and this is my gradle.build(Module:app) :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion '26.0.0'
defaultConfig {
applicationId "com.example.nishant.kitbook"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
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'
})
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.firebaseui:firebase-ui-auth:1.1.1'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
Here is the error I am getting:
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : Attribute application#supportsRtl value=(true) from AndroidManifest.xml:12:9-35 is also present at [com.firebaseui:firebase-ui-auth:1.1.1] AndroidManifest.xml:14:18-45 value=(false). Suggestion: add 'tools:replace="android:supportsRtl"' to <application> element at AndroidManifest.xml:8:5-33:19 to override.
I had to drop by a version from 2.1.0 to 2.0.1 for the Gradle file to compile properly.
Ok this eat my half a day. i just changed firebase-ui-auth version to 1.0.1 from 1.1.1 and it worked. if anyone got any problem relating firebase-ui just check firebase-ui version one by one in descending order, one should work for you.

compile appcompat v7:26.+ error when adding play services for fusion location provider

I have an issue and have looked at possible duplicate questions and answers and I think this one is not answered by the others so asking it here.
I updated my play services to make use of the fused location provider and now the appcompat in my gradle is showing an error.
So I created a new project and checked the build.gradle on the new project and have exactly the same appcompat but my project is showing an error.
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "au.com.itmobilesupport.sqltwo"
minSdkVersion 17
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 {
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'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:recyclerview-v7:26.+'
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-maps:11.0.0'
compile 'com.google.android.gms:play-services:11.0.1'
}
Its this line that is showing the error:
compile 'com.android.support:appcompat-v7:26.+'
But in a new project its fine. Why am I getting the error?
UPDATE:
If I remove these two lines then the error goes away:
compile 'com.google.android.gms:play-services-maps:11.0.0'
compile 'com.google.android.gms:play-services:11.0.1'
But I need them so still have the error.
Add these lines to your build.gradle file to get libraries that you don't have based on Google site.
allprojects {
repositories {
jcenter()
maven {
url "https://maven.google.com"
}
}
}
Caution: Using dynamic dependencies (for example, palette-v7:23.0.+) can cause unexpected version updates and regression incompatibilities. We recommend that you explicitly specify a library version (for example, palette-v7:25.4.0).
Finally solved the issue with the help of ZeroOne's answer to a similar question.
What led me to look at ZeroOnes answer was Google giving me the reason but not as an error. My issue was that the following line is too encompassing and a lot of extra dependencies were added that would have made the app unnecessarily larger.
compile 'com.google.android.gms:play-services:11.0.1'
I simply needed to be more specific and the error disappeared.
Here is the final gradle.
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "au.com.itmobilesupport.sqltwo"
minSdkVersion 17
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 {
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'
})
compile 'com.android.support:appcompat-v7:26.+'
compile 'com.android.support:recyclerview-v7:26.+'
compile 'com.readystatesoftware.sqliteasset:sqliteassethelper:+'
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services-maps:11.0.1'
compile 'com.google.android.gms:play-services-location:11.0.1'
}
And this is the specifc line I change the above to:
compile 'com.google.android.gms:play-services-location:11.0.1'
Hope it helps someone who comes across the same issue.
Being more specific using compile 'com.google.android.gms:play-services-location:11.0.1' rather than compile 'com.google.android.gms:play-services:11.0.1' saved my project as well, tks a lot guys.

Categories

Resources