How to fix appcompat gradle error? android 3.4 - android

Having continuous problems with my gradle. The
implementation 'com.android.support:appcompat-v7:28.0.0'
is underlined in red
This is stopping me from continuing in my development (i'm still very new to android). My problem initially started with
SupportMapFragment mapFragment = (SupportMapFragment) getSupportFragmentManager()
.findFragmentById(R.id.map);
being underline in red and causing an error, but changing my import to
import androidx.fragment.app.FragmentActivity;
cured the problem, but my gradle still is having build problems. I have android 3.4, and my gradle wrapper is 5.1.1. I have no idea how to stop the error from occurring and getting rid of my gradle errors.
I've changed it to alpha1, rc01 and tried downgrading the version but its not working.
The dependencies is where my problem is occuring:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha7'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.google.android.gms:play-services-maps:17.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'
}
I just want the gradle to full work and be able to move on haha, I've been trying to fix this for a while...

You are still using older support libraries hence the errors persist even in the app level Gradle file. Add these to your Gradle:
implementation 'com.google.android.material:material:1.0.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
After replacing these with your current implementations in your Gradle, sync the project. After that, clean/rebuild the cache.
Now the code you have wrote is most likely going to give error because the code was using older support library which is no longer in your project. To solve it, you need to rewrite the error code but this time using androidx imports.

You need to refactor your project to androidx
Go to Refactor -> Migrate to androidx
Click on Migrate

Related

Conflicting Task<ReviewInfo> class, google service gms vs core

I encountered this error while building my app after adding in app review feature. Other similar problems seems to advise on correcting the dependencies version but both gms and core seems to be on the latest (no warning sign on android studio). What direction should I go in order to fix this problem?
error: incompatible types: com.google.android.gms.tasks.Task<ReviewInfo> cannot be converted to com.google.android.play.core.tasks.Task<ReviewInfo>
Snippet of my gradle file
implementation 'com.google.android:flexbox:0.3.2'
implementation 'com.google.code.gson:gson:2.8.6'
implementation 'io.github.kexanie.library:MathView:0.0.6'
implementation "com.google.android.play:core:1.10.3"
implementation("com.google.android.play:review:2.0.0")
testImplementation 'junit:junit:4.13.2'
//implementation 'com.google.android.gms:play-services-measurement-impl:17.5.0'
implementation 'com.google.android.gms:play-services-ads:21.2.0'
implementation 'com.android.billingclient:billing:3.0.2'
Found the problem.
Per https://developer.android.com/guide/playcore, I removed the core dependency ("com.google.android.play:core:1.10.3") and update any existing import statements of Task objects from import com.google.android.play.core.tasks.; to import com.google.android.gms.tasks.;

error: package android.support.v7.widget does not exist

I'm trying to use an SDK given with the RFID scanner I recently bought.
I'm trying to run the sample code given, but it won't compile. I get the following errors on compilation:
error: package android.support.v7.widget does not exist
error: package RecyclerView does not exist
I've tried all the solutions on similar posts, and I'm pretty sure I have the support library correctly installed.
Here are all my dependencies in my build.gradle (app)
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
implementation 'com.google.android.material:material:1.1.0-alpha08'
testImplementation 'junit:junit:4.13-beta-3'
androidTestImplementation 'androidx.test:runner:1.3.0-alpha02'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02'
implementation project(':Rfid.AsciiProtocol-Library')
implementation 'com.android.support:appcompat-v7:+'
implementation 'com.android.support:recyclerview-v7:26.0.0'
}
I'm new to Android Studio, and as I said I tried pretty much all the answers for similar problems and nothing works. Any help welcome :)
Thanks a lot in advance,
Cyril
You should replace android support recyclerview with androidx
implementation 'androidx.recyclerview:recyclerview:1.0.0'
And you can delete 'com.android.support:appcompat-v7:+' dependency, because you've already import it with
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
It frustrated me for literally hours because the answer here given is missing so much.
In dependencies of gradle:
import:
implementation 'androidx.recyclerview:recyclerview:1.0.0'
click gradle sync (should be a bar on top of the page that pops up
Then in your java file where u actually use the RecyclerView class, import this:
import androidx.recyclerview.widget.RecyclerView;
and you are done
EDIT: So apprently you just need to auto-fill the object you need and android studio will auto inport for you. example:
try to type recyclerview, but press tab to auto-fill it. The object should automatically be imported for you on top of the java page. This works with all android studio objects like view and intent.

leandroBorgesFerreira/LoadingButtonAndroid Implementation Error

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.

How to change default dependencies implementations when starting new projects

When I create a new project the activity_main.xml file does not show the default "Hello World!" TextView. I found a video which corrected this by changing an "implementation" line in the build.gradle (Module:app) file. He changed the end of the second implementation line from beta01 to alpha1.
`dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0-beta01'
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'
}`
I suspect that some setting is off, either in the way I configure new projects to build, or some other possibility I'm completely unaware of. Is there a way to change what defaults under dependencies on a new project build? I'm not certain if this is the cause of the problem, or the symptom of a larger one. I cannot seem to follow the simplest of tutorials three steps in before getting errors which seem simple, but I cannot seem to resolve.
I'm new to Android and have some experience coding. I'm quite lost, however, because I can't seem to follow alongside simple tutorials. Any help would be great.
I'm using Android Studio 3.1.4
The video I reference (near 45s to 1m in): https://www.youtube.com/watch?v=dpGqlBDqz_M&t=80s
I've also checked out the Gradle doc's to no avail: https://docs.gradle.org/current/userguide/declaring_dependencies.html

Updating External Libraries in Android Studio

I'm fairly new to Android development, so apologies if this is obvious. I've searched quite a lot but am unable to resolve my issue.
In my build.gradle file I have the following section:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.0'
implementation 'com.android.support:design:26.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'
implementation 'com.google.firebase:firebase-auth:15.1.0'
implementation 'com.google.android.gms:play-services-auth:15.0.1'
implementation 'com.wdullaer:materialdatetimepicker:3.2.2'
}
However the line implementation 'com.android.support:appcompat-v7:26.1.0' is showing with a red squiggly line underneath and displaying the following message:
All com.android.support libraries must use the exact same version specification (mixing versions can lead to runtime crashes). Found versions 26.1.0, 25.3.1. Examples include com.android.support:animated-vector-drawable:26.1.0 and com.android.support:support-v13:25.3.1 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).
I am unable to find out how to solve this issue. Building the project works fine and does not report any errors. I've tried doing File > Invalidate Caches / Restart but to no avail.
After doing a bit of searching I read that I can add implementation 'com.android.support:support-v4:26.1.0' to the build.gradle file and it should fix it, however the same error shows even after syncing.
This is an old project I made sometime last year and it doesn't have a lot in it, but I thought it would be better to learn how to resolve this issue rather than just creating a new project to get around it.
Try adding
implementation 'com.android.support:support-v13:26.1.0'
Although in your question, error is explaining everything, com.android.support:animated-vector-drawable:26.1.0 and com.android.support:support-v13:25.3.1 are not having same version.
Should always keep support libraries version same in build.grdale.
implementation "com.android.support:appcompat-v7:$support_lib_version"
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation "com.android.support:design:$support_lib_version"
implementation "com.android.support:support-v4:$support_lib_version"
implementation "com.android.support:cardview-v7:$support_lib_version"
implementation "com.android.support:recyclerview-v7:$support_lib_version"
where support_lib_version is a constant.
ext { support_lib_version = '26.1.0'}
in same build.gradle file out side 'android' and 'dependencies'.

Categories

Resources