So, i have added all the android new material depency in order to work with BottomAppBar , but after I imported all and changed what the documentation suggest I cant even see the preview and when I compile I get the error that test.runner does not exists, and thats is maybe I removed the support.test.runner because it says that we don't need to mix support with material.
This is what I have done
My dependencies
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.google.android.gms:play-services-maps:16.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.cardview:cardview:1.0.0'
testImplementation 'junit:junit:4.12'
implementation "androidx.room:room-runtime:2.1.0-alpha01"
annotationProcessor "androidx.room:room-compiler:2.1.0-alpha01"
}
Styles
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
I added to my AndroidManifest application tag this two suggeste lines by the compiler
tools:replace="android:appComponentFactory"
android:appComponentFactory="settings"
I changed all the AppCompat from all my classes and replace them with the new AndroidX AppCompat
Errors
error: package android.support.test does not exist
this might be caused because I deleted support.test from my gradle since in the doc says we dont need to mix support with material.
And this error trying to preview coordinatorLayout
Any clue what it could be and how to solve all of this since I need to work with this material design as soon as posible.
Another thing, since it has AppCompat, I can run and see this design on my android 7 ?
thanks
What version of Android studio you have?
According here: https://developer.android.com/jetpack/androidx/migrate
Android studio must be 3.2 or higher.
If your android studio is now 3.2 or higher there is an option under Refactor tab- "Migrate to AndroidX" wait it to compile everything and AS will migrate your existing project to androidX which is the Material you are looking for.
If you may ask, here is my dependency for androidx:
implementation 'androidx.appcompat:appcompat:1.0.0-rc01'
implementation 'com.google.android.material:material:1.0.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha2'
implementation 'com.android.support:appcompat-v7:28.0.0-rc01'
implementation 'com.android.support.constraint:constraint-layout:1.1.2'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha4'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha4'
Solved my problem just importing all material dependencies and not using any support ones
Related
Im getting the error
The following classes could not be found:
- android.support.design.widget.CoordinatorLayout (Fix Build Path, Edit XML, Create Class)
- android.support.design.widget.NavigationView (Fix Build Path, Edit XML, Create Class)
- android.support.v4.widget.DrawerLayout (Fix Build Path, Edit XML, Create Class)
Tip: Try to build the project.
Heres my module app:
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
I've tried to rebuild, clean and change the implementations but nothings seems to work
Does anyone know how I could fix this?? it started when I updated android studio and created a new project.
Your dependency is mixed of support library and AndroidX which is not right. Refactor it to AndroidX using Android Studio.
Refactor > Migrate to AndroidX and press Do Refactor
You have to use
androidx.coordinatorlayout.widget.CoordinatorLayout
com.google.android.material.navigation.NavigationView
androidx.drawerlayout.widget.DrawerLayout
instead of
android.support.design.widget.CoordinatorLayout
android.support.design.widget.NavigationView
android.support.v4.widget.DrawerLayout
I am getting following error while building my project while I haven't used firebase auth in my project:
Error: Program type already present: com.google.firebase.auth.FirebaseAuthException
I have tried following but nothing seems to work
Use navigation option
clean rebuild
invalid cache
exclude group module
my dependencies are as:
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.android.support:design:27.1.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
implementation 'android.arch.lifecycle:extensions:1.1.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.google.firebase:firebase-admin:6.8.0'){
exclude module:'com.google.firebase-auth'
}
}
implementation 'com.google.firebase:firebase-firestore:19.0.1'
You can't use the Firebase Admin SDK in an Android app. It can only be used in a trusted environment, such as your development machine, a server you control, or Cloud Functions.
If you remove this dependency, the error should disappear:
implementation ('com.google.firebase:firebase-admin:6.8.0'){
This problem usually come from a naming conflict (Most probably because a class appears more than once in your project either in the form of dependencies or a mistake).
To find the list of dependencies for the module 'x' we can run
./gradlew x:dependencies to retrieve a list of all the libraries.
From the dependency tree, you an figure out if there is a class/library with the same name being used by two libraries. Based on this finding, you can choose to exclude the module in one of the libraries that are causing the conflict.
I'm following the tutorial https://www.youtube.com/watch?v=X5AOrAhyrkg&list=PLRRNzqzbPLd8Qldg1J3LFesfXW9hWM_t4&index=3&t=0s
But when I implement the library 'me.zhanghai.android.materialprogressbar:library:1.6.1' it causes some error.
I did take a look at Android Material and appcompat Manifest merger failed but when I try that solution on It doesn't work for me. I know that I'm using the latest version of AndroidX which is the problem. But I haven't figured it out yet.
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:design:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'me.zhanghai.android.materialprogressbar:library:1.6.1'
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'
}
So I hope to find a solution
This is what I encountered previously with third party libraries. This issue occurs when you are currently migrated to Androidx and the third party lib (in your case, 'me.zhanghai.android.materialprogressbar:library:1.6.1') is still using android support and it will clash causing the merge dex error.
I don't think if this will help, but do try adding this.
('me.zhanghai.android.materialprogressbar:library:1.6.1'){
exclude group: "com.android.support"
}
If it doesn't, you might have to post your issue on their github page and see if they can promise u an answer.
This question already has answers here:
All com.android.support libraries must use the exact same version specification
(54 answers)
Closed 4 years ago.
I'm trying to add a banner add to a new app of mine and I've hit a roadblock adding the Gradle dependencies. I've been following the Admob tutorial on how to do it Admob Get Started Link
What I'm trying to use is the following
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.android.gms:play-services-ads: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'}
However the line with "appcompat-v7:27.1.1" gets underlined with the following message:
All com.android.support libraries must use the exact same version
specification, Found version 27.1.1, 26.1.0. Examples include
com.android.support:animated-vector-drawable:27.1.1
andcom.android.supports:customtabs:26.1.0
This underline warning only shows up when I add in the dependency for admob, specifically:
implementation 'com.google.android.gms:play-services-ads:17.0.0'
How/what should I be doing to fix this? I was testing this out earlier in the week and I didn't have any errors, the only thing I've added since then is permissions for phone vibration which I can't imagine has any effect. My app crashes on the opening screen
The issue is happening because there are two different versions of support libraries sync one by ads and another by app compat
To solve the issue use
configurations.all
{ resolutionStrategy.force 'com.android.supports:customtabs:27.1.1'
resolutionStrategy.force 'com.android.support:animated-vector-drawable:27.1.1'
}
dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']
........
Have you tried adding the library with the old version, but with new version??
com.android.support:customtabs:26.1.0 is your error so you need to add this:
implementation "com.android.support:customtabs:27.1.1"
It's an confusing error because you are not directly using this library, but more of the libraries you use, depend on this one, so you have to explicitly set which version to use
Recently I have downloaded a code from GitHub and synced it with my android studio. I have faced lots of errors and issues while doing so and somehow fixed most of them. However, the last issue I'm stuck at right now is that my android studio cannot find the class FloatingActionButton as you can see in this screenshot
It is to be noted that earlier many other classes, including 'AppCompatActivity' could not be resolved. Changing the dependencies to following solved the issue
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.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'
}
But even after changing dependencies, clean building the project, doing 'Invalidate Caches / Restart...', the problem with 'FloatingActionButton' is still there.
You can check the repository here
And this is the java code of the activity where the error is occurring
The FloatingActionButton is in the design library.
Add this line to your dependencies:
implementation 'com.android.support:design:27.1.1'
This post also has more general info about FloatingActionButton: FloatingActionButton example with Support Library
#Sub 6 Resources already answered this question wholly but I want to add a bonus tip. If you already added implementation 'com.android.support:design:27.1.1' to your code and the compiler can't still resolve the FloatingActionButton class, simply rebuild your project. A colleague and I recently had this same problem while the dependency was already there and a simple rebuild solved it all.
Update for AndroidX:
The answer of #Sub 6 Resources was perfect before androidX was introduced. Now, it is better to include the following dependency instead of the accepted answer's dependency:
implementation 'com.google.android.material:material:1.6.1'
NOTE: it might not be the latest version by the time you are reading this.