All the libraries must use the same versions - android

My depencies
dependencies {
compile 'me.dm7.barcodescanner:zxing:1.9'
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.constraint:constraint-layout:1.0.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'
compile 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
}
I get an error in appcompat line when compiling that found version 27.1.1,26.1.0 examples include ..vectordrawable 27.1.1 nd supportdesign 26.1.0
My target SDK is 26.
I tried to switch versions to 27 but my SDK target is 26, I get an error.

Whenever you see this type of problem, explicitly declare the probelmatic libraries in your gradle file with the same version of your other support libs:
implementation "com.android.support:animated-vector-drawable:26.1.0"
implementation "com.android.support:design:26.1.0"
implementation 'com.android.support:support-vector-drawable:26.1.0'
This happens because some of your dependencies use a different version of it.
Also, use implementation not compile. Compile has been deprecated:
implementation 'me.dm7.barcodescanner:zxing:1.9'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'

There are conflicted dependencies in your project. You need to check up the dependencies tree of your project by running the following command in your Linux terminal:
./gradlew app:dependencies
or if you're using Windows:
gradlew app:dependencies
in your root project. Where app is your module name.
Quick checking your dependencies block, you will find the following library:
compile 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
is using support library version 27.1.1 for its dependencies (You can check its build.gradle).
You can exclude the library from image cropper with:
implementation ('com.theartofdev.edmodo:android-image-cropper:2.7.0') {
exclude group: 'com.android.support'
exclude module: 'appcompat-v7'
}
The side effect of using the old version of support library is you can't be so sure that your program will work correctly. It's because the owner of library probably didn't test the library with older version of support library.
The better way is by changing your BuildToolsVersion, compileSdkVersion, targetSdkVersion, and support libraries to version 27. Something like the following:
android {
compileSdkVersion 27
buildToolsVersion '27.0.3'
defaultConfig {
applicationId "com.package.name"
minSdkVersion 15
targetSdkVersion 27
...
}
...
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
// your other dependencies
...
}

Related

Application keeps crashing on start when apk is build using mac

I have an android project, When i build the project using mac application crashes on start. When same is done using Windows system it works fine.
Error log is pasted below.
I have tried all the available solutions here Why would I be getting a NoSuchMethodError at super.onCreate() for registerFragmentLifecycleCallbacks in Android?
java.lang.NoSuchMethodError: No virtual method registerFragmentLifecycleCallbacks(Landroid/support/v4/app/FragmentManager$FragmentLifecycleCallbacks;Z)V in class Landroid/support/v4/app/FragmentManager; or its super classes (declaration of 'android.support.v4.app.FragmentManager' appears in /data/app/android.form.avss.prepaidcard-2/base.apk:classes11.dex)
at android.arch.lifecycle.LifecycleDispatcher$DispatcherActivityCallback.onActivityCreated(LifecycleDispatcher.java:75)
at android.app.Application.dispatchActivityCreated(Application.java:219)
at android.app.Activity.onCreate(Activity.java:1039)
at android.support.v4.app.BaseFragmentActivityDonut.onCreate(BaseFragmentActivityDonut.java:39)
at android.support.v4.app.FragmentActivity.onCreate(FragmentActivity.java:297)
at android.support.v7.app.AppCompatActivity.o nCreate(AppCompatActivity.java:85)
at android.form.avss.prepaidcard.ihmf_form_fill.ui.Activities.FormBaseActivity.onCreate(FormBaseActivity.java:30)
at android.form.avss.prepaidcard.ihmf_form_fill.ui.Activities.FormFillActivity.onCreate(FormFillActivity.java:147)
Below is the app gradle config. and dependencies i am using.
Client restricted the sdk versions to 23, so i can't update it. I have tried updating compiled version but no luck.
compileSdkVersion 23
buildToolsVersion '23.0.3'
defaultConfig {
applicationId "android.form.prepaidcard"
minSdkVersion 21
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
dependencies {
def lifecycle_version = "1.1.1"
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
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.android.support:recyclerview-v7:23.4.0'
compile 'com.android.support.constraint:constraint-layout:1.1.3'
compile('com.weiwangcn.betterspinner:library-material:1.1.0') {
exclude group: 'com.android.support', module: 'appcompat-v7'
}
compile 'com.theartofdev.edmodo:android-image-cropper:2.2.5'
compile 'com.journeyapps:zxing-android-embedded:3.4.0'
//network library
compile 'com.squareup.okhttp3:logging-interceptor:3.9.1'
compile 'com.squareup.retrofit2:retrofit:2.5.0'
compile 'com.squareup.retrofit2:converter-gson:2.5.0'
compile 'com.squareup.okhttp:okhttp:2.5.0'
compile 'com.google.code.gson:gson:2.8.5'
//IHMF dependencies
compile "android.arch.lifecycle:extensions:$lifecycle_version"
compile "android.arch.lifecycle:runtime:$lifecycle_version"
compile 'io.reactivex.rxjava2:rxjava:2.0.0'
compile 'io.reactivex.rxjava2:rxandroid:2.0.0'
compile 'com.android.support:recyclerview-v7:23.4.0'
// compile 'com.github.gcacace:signature-pad:1.2.1'
// compile 'com.journeyapps:zxing-android-embedded:3.6.0'
// compile 'com.squareup.picasso:picasso:2.5.2'
}
Currently i am clueless as apk installed using windows runs smooth.
i can't decide if its code or build level issue. I always have to push the code to Github in order to debug code in window. Which consumes a lot of times.
Any help would be highly appreciated. Thanks
This response isn't a definite answer, but it's too long to put in a comment.
I have the feeling this is a multi-dex issue with a dependency that is shared amongst modules. It seems to be complaining about support v4 libraries.
In the command window you could run ./gradlew :app:dependencies | grep v4 and see which version don't equal 23.4.0 and then exclude that module from those dependencies.
Or you can take a heavy handed approach and resolve it at the top level and try to force the version:
allprojects {
...
configurations {
all {
resolutionStrategy {
force 'com.android.support:support-v4:23.4.0'
}
}
}
}

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

"support files should use exactly same version" Android studio error

I have following dependencies in my app-level build.gradle file
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:27.1.1'
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.volley:volley:1.1.1'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'com.android.support:cardview-v7:27.0.2'
}
These works fine without any error. But, When I try to put a new third party dependency of CircleImageView implementation 'de.hdodenhof:circleimageview:2.2.0', the gradle build fails and there is error on implementation 'com.android.support:appcompat-v7:27.0.2' line saying All com.android.support libraries must use the exact same version.... I am wondering how this third party library creating problem in support libraries. What is wrong there?
That library is implementing support libraries as well, but different versions. Specifically, it uses the support-annotations 27.1.0 library.
There are two things you can do.
Update your dependencies. 27.0.2 is outdated. 27.1.0 is as well, but less so.
Exclude that library from your implementation and implement it yourself:
implementation ("de.hdodenhof:circleimageview:2.2.0") {
exclude group: "com.android.support" module: "support-annotations"
}
implementation 'com.android.support:support-annotations:27.1.1'
You should update all your support dependencies to 27.1.1.
The third party library internally uses the app compat library and because the version used by project is different from the library version, it gives the error. Updating appcompat, design and cardview dependencies to version 27.1.1 worked fine as follows.
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:27.1.1'
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.volley:volley:1.1.1'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'de.hdodenhof:circleimageview:2.2.0'
}
If you want all support libraries including third party libraries internally use the same support library version, then add below code in your project level gradle
ext {
support_library_version = '27.1.1'
}
subprojects {
project.configurations.all {
resolutionStrategy.eachDependency { details ->
if (details.requested.group == 'com.android.support'
&& !details.requested.name.contains('multidex')) {
details.useVersion "$support_library_version"
}
}
}
}
The support libraries should have the same version as the other dependencies which are related.
Change them to v 27.1.1 (The point is they should have the same version):
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:cardview-v7:27.1.1'
And then if you saw any errors which points to "should have same version", run :
./gradlew dependencies
To see which library is using old version.
Mostly, it can be fixed by adding the updated version of the library (same as the support library) in your build.gradle dependencies.

Updating Google Firebase dependencies in Android project build.gradle file

I have been working on a project where I am trying to build a messaging application in Android Studio using Google Firebase. I previously had to restart the project due to an error after reaching this stage of the tutorial I have been following which requires you to add an implementation of the 'com.firebaseui:firebase-ui-database:4.1.0' (Or whatever the most recent version is) in my project gradle file and update the existing dependencies I am using accordingly.
I am still relatively new to app dev and as such don't want to mess up this project and start from scratch again by screwing up my gradle file. So could somebody show me what my build.gradle file should look like with the new dependency added and the existing dependencies correctly updated before syncing?
Info on adding the dependency can be found under this link, mainly under the 'Installation' and 'Dependencies' headings. https://github.com/firebase/FirebaseUI-Android
My current gradle file looks like this:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.conormcadorey.chatbox"
minSdkVersion 21
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'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-beta01'
implementation 'com.android.support:design:28.0.0-beta01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.android.support:support-v4:28.0.0-beta01'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.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'
//creates a rounded user profile image
implementation 'de.hdodenhof:circleimageview:2.2.0'
//ArthurHub - allows user to crop their profile image
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.+'
//Picasso - image uploader
implementation 'com.squareup.picasso:picasso:2.71828'
}
apply plugin: 'com.google.gms.google-services'
ps - I appreciate that this may be a simple or obvious question, however when I attempted this myself I ended up having to rebuild the project from scratch so any help would be greatly appreciated.
Using Android Studio v3.1.3
According to the docs:
As of version 4.1.0, FirebaseUI has the following dependency versions:
Library Version
firebase-auth 16.0.1
play-services-auth 15.0.1
firebase-database 16.0.1
firebase-firestore 17.0.1
firebase-storage 16.0.1
Therfore change the following libraries:
implementation 'com.google.firebase:firebase-auth:11.8.0'
implementation 'com.google.firebase:firebase-database:11.8.0'
implementation 'com.google.firebase:firebase-storage:11.8.0'
into this:
implementation 'com.google.firebase:firebase-auth:16.0.2'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-storage:16.0.1'
Also add the firebase-core:
implementation 'com.google.firebase:firebase-core:16.0.1'
Your app gradle file now has to explicitly list com.google.firebase:firebase-core as a dependency for Firebase services to work as expected.

support libraries must use the exact same version specification [duplicate]

This question already has answers here:
All com.android.support libraries must use the exact same version specification
(54 answers)
Closed 5 years ago.
I have tried running my app using a specific activity, and I a continuous crash is taking place.
I have pinpointed an error that is to do with the appcompat version. However, I am unsure as to how to fix this error, i.e. get all my dependencies on the same version.
I was wondering if there is a quick fix to do this? And, if not, what are the steps to making sure that they are all on the correct/same version?
build.gradle (Module: app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.example.benchalmers.myapplication"
minSdkVersion 15
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(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.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:26.1.0'
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'
compile 'com.android.support:recyclerview-v7:26.1.0'
compile 'com.android.support:cardview-v7:26.1.0'
compile 'com.android.volley:volley:1.1.0'
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
}
This is the error that is being given to me:
All com.android.support libraries must use the exact same version
specification (mixing versions can lead to runtime crashes). Found
versions 27.0.2, 26.1.0. Examples include
com.android.support:support-compat:27.0.2 and
com.android.support:animated-vector-drawable:26.1.0 less... (⌘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.)
Any help would be much appreciated. Thanks.
Update your dependencies like so:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:27.0.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'
compile 'com.android.support:recyclerview-v7:27.0.2'
compile 'com.android.support:cardview-v7:27.0.2'
compile 'com.android.volley:volley:1.1.0'
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
}
Like the error message says: There's a conflicting version of Support Libraries found in your project. What you need to do to "fix" it is then make sure your Support Library version is the same (and preferably latest available).
In order to ease this process going forward, you could also make your code look like this:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
def supportLibraryVersion = "27.0.2"
implementation "com.android.support:support-v4:$supportLibraryVersion"
implementation "com.android.support:design:$supportLibraryVersion"
implementation "com.android.support:support-v4:$supportLibraryVersion"
compile "com.android.support:recyclerview-v7:$supportLibraryVersion"
compile "com.android.support:cardview-v7:$supportLibraryVersion"
implementation 'com.android.support.constraint:constraint-layout:1.0.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'
compile 'com.android.volley:volley:1.1.0'
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
}
Also, as suggested by Michael Dodd, in order to use Support Library version 27.0.2, you'd need to bump your compileSdkVersion too:
android {
...
compileSdkVersion 27
...
}

Categories

Resources