leandroBorgesFerreira/LoadingButtonAndroid Implementation Error - android

I'm try to use this button style this link But I had Implementation error, my build.gradle like that:
That's my dependencies :
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.firebase:firebase-core:16.0.7'
implementation 'com.google.firebase:firebase-auth:16.1.0'
implementation 'com.google.firebase:firebase-database:16.1.0'
implementation 'com.google.firebase:firebase-storage:16.1.0'
implementation 'com.google.android.gms:play-services-auth:16.0.1'
implementation 'com.google.code.gson:gson:2.8.5'
implementation 'com.android.volley:volley:1.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.testπŸƒ1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
}
And the error:
ERROR: Manifest merger failed : Attribute application#appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to element at AndroidManifest.xml:5:5-19:19 to override.
How can I fix that?

I guess this error is happening because their latest version is using AndroidX but your app is still using Support Library.
So, I guess there are two possibilities:
Downgrade library version
Checking their release history, it seems the AndroidX was introduced on version v2.0.0. So, use an old version: v.1.14.0. Just use implementation 'br.com.simplepass:loading-button-android:1.14.0'
Migrate to AndroidX.
You may also consider to migrate to Android X since Android Support library is now deprecated. For any case, you may want to check first solution to ensure the problem is really being caused by the AndroidSupport/AndroidX conflict
Edit
Just sharing more info since you are not aware about the AndroidX.
When developing an Android App, you probably want to build a single APK which works in different Android Versions. However, as you may imagine, there are some differences between different Android versions such as methods that are no longer used (deprecated) or were added later etc. Features that exists in a version but not in others etc.
For this reason, you will end up using the Android Support Library.
It is a special library which helps you to support several Android versions. Not only that, but some views such as ConstraintLayout, RecyclerView and CardView were released as a library.. as part of the Android Support Library.
In your build gradle, we can see that you are already using the Android Support Library:
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
However, on last year, Android deprecated the Support Library and created the AndroidX. In a certain way, it is the same thing.. Just a different name..
Sooner or later, you will migrate your app to Android X since support library won't be updated anymore.
However, not only you app will migrate to AndroidX but some third party library will move to AndroidX as well. In this case, we have the library LoadingButtonAndroid that started to used the android X in version v.2.0.0. However, since you didn't migrate your app yet, you have some this kind of conflit. So, you fix by either using an old version of LoadingButtonAndroid or by migrating your app to AndroidX.
HERE you can find how to migrate your app to AndroidX. Usually, it is a very simple process. However, Android Studio always forget to change some import and you have to manually change from support library to androidx.
Automatically or manually, migrating to AndroidX just means that you have to update your imports from android.support.v7.app.AppCompatActivity to androidx.appcompat.app.AppCompatActivity
As you can see, class name is the same and there's no code changes... All the views are the same.. Just their package (import) that is different.

Related

react-native-google-signin and android.support.v4.net does not exist error

I have some problem when integrating react-native-google-signin into native android code. I use react-native 0.59.8 and i can't upgrade to 0.60 so far. Therefore I followed an instruction for older react-native-google-signin version which is 2.1.1. Unfortunately it's not working for me. It gives me some errors concerning androidX but as far as I know react-native-google-signin started using androidX from version 3.0.0 upwards, but i use 2.1.1 version which should not use androidX.
Description
The problem starts in sync proccess in Android Studio which gives me the following error:
ERROR: Manifest merger failed : Attribute application#appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.1] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:7:5-117 to override.
Now when I'm trying to build my project in Android Studio it gives me another error:
error: package android.support.v4.net does not exist
Interesingly, now problem concerns the package #react-native-community/netinfo which was working fine before I linked react-native-google-signin into my project. I would be very grateful if someone told me what's going on.
EDIT:
My dependencies section from android/app/build.gradle is as follows:
dependencies {
implementation project(':react-native-google-signin')
implementation project(':react-native-reanimated')
implementation project(':react-native-gesture-handler')
implementation project(':react-native-firebase')
implementation project(':react-native-community-netinfo')
implementation project(':react-native-orientation')
implementation project(':react-native-keychain')
implementation project(':react-native-view-shot')
implementation project(':react-native-video')
implementation project(':react-native-fs')
implementation project(':react-native-blur')
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "com.android.support:appcompat-v7:${rootProject.ext.supportLibVersion}"
implementation 'com.facebook.react:react-native:+'
implementation 'com.android.support:design:27.1.1'
implementation project(':react-native-navigation')
implementation 'com.google.android.gms:play-services-base:16.1.0'
implementation 'com.google.firebase:firebase-core:16.0.8'
implementation "com.google.firebase:firebase-messaging:17.5.0"
}
Please try the following:
Open your /android/app/build.gradle File, and check your dependencies.
Search for any instance of play-services of firebase, and see for two things:
the line starts with implements (instead of compile)
see if there are any get latest Version wildcard (that is the +-Sign) on it. (Example: implementation "com.google.android.gms:play-services-base:+"
(If you don't found any component implemented with +-Sign, go on further down from topic "GO-ON-HERE" ⇓ in this answer.)
Get those (in my example it is com.google.android.gms:play-services-base and search for it on MVNRepository to get an overview of available Versions.
Here you might choose the newest one, or one that definitely work with your used components and force your App to use it, by updating /android/app/build.gradle like this:
implementation ("com.google.android.gms:play-services-base:17.1.0"){ force = true }
(Note: I don't know, if it's play-services-base in your case, it's only an example)
β‡’ GO-ON-HERE
After that, switch to /android and run ./gradlew :app:dependencies. This regenerate your dependency-tree for your Project.
Open the created Text-file and search for your updated Component:com.google.android.gms:play-services-base to see, where the component will be used.
You might find, that still some components use the +-Sign (com.google.android.gms:play-services-base:+) in the dependency. To fix your issue, you need to patch them (maybe use patch-package to simplify this process) to also use the Version for your component (in our example "play-services-base") you've choosed above.
Hope that helps you out.

Android: Adding Firebase Messaging - Menifest merger failed

I added this to my project:
implementation 'com.google.firebase:firebase-messaging:19.0.0'
and result:
ERROR: Manifest merger failed : Attribute application#appComponentFactory value=(android.support.v4.app.CoreComponentFactory) from [com.android.support:support-compat:28.0.0] AndroidManifest.xml:22:18-91
is also present at [androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86 value=(androidx.core.app.CoreComponentFactory).
Suggestion: add 'tools:replace="android:appComponentFactory"' to <application> element at AndroidManifest.xml:15:5-71:19 to override.
So I go went ahead and added that line to the manifest, and I get this:
Manifest merger failed with multiple errors, see logs
I went to merging errors, and I see this now:
Error: tools:replace specified at line:15 for attribute android:appComponentFactory, but no new value specified app main manifest (this file), line 14
Here are my current gradle dependencies:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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 project(path: ':bluefire-api-v25.5')
implementation "com.jakewharton:butterknife:8.5.1"
annotationProcessor "com.jakewharton:butterknife-compiler:8.8.1"
implementation 'com.myhexaville:smart-image-picker:1.0.4'
implementation 'com.github.gcacace:signature-pad:1.2.1'
implementation 'com.squareup.retrofit2:retrofit:2.5.0'
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.google.firebase:firebase-core:16.0.9'
implementation 'com.google.firebase:firebase-messaging:19.0.0'
}
I hit a dead-end. Thoughts?
To troubleshoot your problem, Follow below steps:
Open your AndroidManifest.xml
There is a tab on the bottom of the Ide named "Merged Manifest". Open it.
This will list out the Merged Manifest at the left and their sources
at right.
As you are facing
Manifest "merger failed" error, you will see Some Merging Errors.
This will tell you exactly which part is in conflict. Resolve that
and you are done.
In your case, the error is because of the conflict between different support libraries. i.e. between androidx and older support lib. Migrate all your support library to AndroidX. The latest firebase library you are using is already migrated from the Android Support Libraries to the Jetpack (AndroidX) Libraries.
This post will help you to migrate to AndroidX : Migrating to AndroidX
This Issue occur due to support and andoidx library both present.
Check Firebase Release Note.
This release is a MAJOR version update and includes breaking changes.
With this release, libraries are migrated from the Android Support
Libraries to the Jetpack (AndroidX) Libraries. 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.
If you have used support version in your gradle, than down firebase version to 18.0.0. Otherwise you need to migrate to androidx.
I also got the same issue last day. After downgrading 'com.google.firebase:firebase-messaging:19.0.0' to 'com.google.firebase:firebase-messaging:18.0.0', it is fixed
Add this to your application tag in your manifest:
'tools:replace="android:appComponentFactory"
and go to merger manifest in manifest file to check what the problem is.
change your library to-:
'com.google.firebase:firebase-messaging:18.0.0'

Classes using methods of other dependencies is not working in my custom library, any suggestions?

I have created by own library for helper methods & classes also included few other dependencies, then used the jitpack to create a custom dependency. But after implementing it to a project, the classes using the other dependencies are not visible to android studio.
I tried adding the other specific dependencies to the project and it works but I need to find alternative way without the need of adding specific dependencies. If it is possible, please do help.
My Library: My-Utility
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.makeramen:roundedimageview:2.3.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation 'com.google.android.gms:play-services-location:16.0.0'
If you are expecting any of those implementation dependencies to be automatically visible to apps using your library, replace implementation with api.
See the documentation for more.

Manifest merger failed, when adding the butterknife library

dependencies {
implementation 'com.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
implementation 'com.squareup.picasso:picasso:2.71828'
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
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'
}
These are the dependencies, in build.gradle
Manifest merger failed : Attribute application#appComponentFactory
value=(android.support.v4.app.CoreComponentFactory) from
[com.android.support:support-compat:28.0.0]
AndroidManifest.xml:22:18-91 is also present at
[androidx.core:core:1.0.0] AndroidManifest.xml:22:18-86
value=(androidx.core.app.CoreComponentFactory). Suggestion: add
'tools:replace="android:appComponentFactory"' to element
at AndroidManifest.xml:7:5-21:19 to override.
I wished to add a library to my project, it is called as ButterKnife library, before adding this library the project was fine, but as I added this library. Manifest merger failed error occurred.
What I have tried?
I added these lines to my AndroidManifest.xml:
tools:replace="android:appComponentFactory"
android:appComponentFactory="whateverString"
But this generated another set of errors
Caused by: com.android.tools.r8.utils.AbortException: Error: Static
interface methods are only supported starting with Android N
(--min-api 24): void butterknife.Unbinder.lambda$static$0()
I tried removing butterknife library, and then it builds finely.
I also tried adding only one of those lines:
tools:replace="android:appComponentFactory"
This did nothing and produced yet another error:
Manifest merger failed with multiple errors, see logs
I tried Refractor->migrate to androidx,
this created a new problem in Java file, which now says that it "cannot resolve symbol R"
So what should I do, I am following some course online for app development. And the person teaching this course does not seem to have these errors.
com.jakewharton:butterknife:10.0.0 is using AndroidX. Check it here.
But you also depend on com.android.support:appcompat-v7:28.0.0.
You shouldn't mix dependencies using AndroidX with non-AndroidX.
You have two options:
Use a lower version for ButterKnife.
Migrate to AndroidX.
To migrate to AndroidX:
Use androidx.appcompat:appcompat:1.0.0 instead of com.android.support:appcompat-v7:28.0.0.
Add the following to your gradle.properties:
android.useAndroidX=true
android.enableJetifier=true
Change imports of your Activity's AppCompatActivity from
import android.support.v7.app.AppCompatActivity;
to
import androidx.appcompat.app.AppCompatActivity;
Check the migration guide here.
Issue
I think there is something wrong in the current version (latest) of butterknife. The simplest solution that I found for this problem is that change the version that butterknife applies to.
One possible solution
I changed this
implementation 'com.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
to this
implementation 'com.jakewharton:butterknife:7.0.1'
annotationProcessor 'com.jakewharton:butterknife-compiler:7.0.1'
Why do this?
What we have done is that we now are going to use the older version of butterknife, the version which works.
I faced the same issue when i tried to apply the butterknife to one of my existing Application.
Application without any AndroidX implementations on your gradle file
implementation 'com.jakewharton:butterknife:7.0.1'
annotationProcessor'com.jakewharton:butterknife-compiler:7.0.1'
this is will work fine.
As the Latest version of the Butterknife uses the AndroidX your project should also be migrated to AndroidX which seems to be extra work if you want on existing project.
If the new project with the AndroidX implementation then you can go to the Latest versions:
implementation 'com.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
if you are willing to migrate your old application to AndroidX please go through the link.

Android Studio 3.1: mixing versions can lead to runtime crashes

Have recently upgraded to Android Studio 3.1, and at the same time I'm trying the Android P preview.
I'm getting the following error on compiling:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 28.0.0-alpha1, 26.1.0. Examples include com.android.support:animated-vector-drawable:28.0.0-alpha1 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).
But I cannot see any instance of 26.1.0 anywhere. All I have in my gradle is:
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:design:28.0.0-alpha1'
I've tried clearing caches, rebuilding app, etc. But error remains.
You need to override the conflicted libraries by adding the conflicted libraries to your dependencies block
dependencies {
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:customtabs:28.0.0-alpha1'
implementation 'com.android.support:support-vector-drawable:28.0.0-alpha1'
implementation 'com.android.support:support-media-compat:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'
The above warning is not specific to media-compat dependency. They just added example to explain the issue. The issue get resolved by adding v4 lib for me.
implementation 'com.android.support:support-v4:28.0.0'
in addition to
implementation 'com.android.support:appcompat-v7:28.0.0'
No need include
implementation 'com.android.support:animated-vector-drawable:28.0.0'
implementation 'com.android.support:support-media-compat:28.0.0'
You need to override the conflicted libraries by adding the conflicted libraries to your dependencies block. For example, from your error log you'll find the following:
Found versions 28.0.0-alpha1, 26.1.0. Examples include
com.android.support:animated-vector-drawable:28.0.0-alpha1 and
com.android.support:support-media-compat:26.1.0 less...
You can remove the error by adding the libraries with something like this:
dependencies {
implementation 'com.android.support:animated-vector-drawable:28.0.0-alpha1`
implementation 'com.android.support:support-media-compat:28.0.0-alpha1`
}
this error came,when i connect app to firebase.
no need to add any thing.
just put mouse cursor on error line(below one) and press Alt+Enter
(implementation 'com.android.support:appcompat-v7:28.0.0')
in the list enter first option.(noinspection)
After that it looks like this,
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:28.0.0'
Some dependency β€” perhaps playLicensing β€” has a transitive dependency on at least support-media-compat, for version 26.1.0.
To work around this:
Identify each Support Library artifact that shows up in "External Libraries" that is older than 28.0.0-alpha1. Based on the error, those older ones should all be 26.1.0, and it will be at least support-media-compat.
For each of those, add your own implementation line to your dependencies, requesting that artifact, but for 28.0.0-alpha1. This will cause Gradle to use the newer artifact, which happens to be what you want.
Hope that whatever is depending on those older artifacts will survive with the newer artifacts.
So, at minimum, you are adding:
implementation 'com.android.support:support-media-compat:28.0.0-alpha1'
In my case I resolved it by adding this below the error line.
implementation 'com.android.support:support-media-compat:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
add in dependencies of build.grad (Module.app)
dependencies {
//noinspection GradleCompatible
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'
}
In my case adding support-v4 helped me to got loose of warning.
dependencies {
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:support-v4:28.0.0'
// other dependencies
}
Are you using a firebase in your project?
Using firebase core or firebase app indexing seem to be causing the problem.
I was having the same problem, but commenting on firebase packages makes the error to go away
// implementation 'com.google.firebase:firebase-core:16.0.8'
// implementation 'com.google.firebase:firebase-ads:17.2.0'
// implementation 'com.google.firebase:firebase-appindexing:17.1.0'
I think your gradle file has the below dependency. Add this to your app level build.gradle.
implementation 'com.android.support:appcompat-v7:28.0.0-alpha1'
implementation 'com.android.support:mediarouter-v7:28.0.0-alpha1'
implementation 'com.android.support:support-vector-drawable:28.0.0-alpha1'
implementation 'com.android.support:support-v4:28.0.0-alpha1'

Categories

Resources