Not able to use CoordinatorLayout in Android Studio - java

My problem is that I am not able to use CoordinatorLayout in Android Studio despite adding all the possible dependencies in my build.gradle file. The class is not instantinated.
Here's my build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.uiuxpractical4materialdesign"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.1.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'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.coordinatorlayout:coordinatorlayout:1.1.0'
}
activity_main.xml:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="16dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="16dp"
android:layout_marginBottom="16dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
The Error:
java.lang.NoClassDefFoundError: androidx/coordinatorlayout/R$attr
at androidx.coordinatorlayout.widget.CoordinatorLayout.<init>(CoordinatorLayout.java:211)
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:62)
at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at org.jetbrains.android.uipreview.ViewLoader.createNewInstance(ViewLoader.java:403)
at org.jetbrains.android.uipreview.ViewLoader.loadClass(ViewLoader.java:186)
at org.jetbrains.android.uipreview.ViewLoader.loadView(ViewLoader.java:144)
at com.android.tools.idea.rendering.LayoutlibCallbackImpl.loadView(LayoutlibCallbackImpl.java:309)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:418)
at android.view.BridgeInflater.loadCustomView(BridgeInflater.java:429)
at android.view.BridgeInflater.createViewFromTag(BridgeInflater.java:333)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate_Original(LayoutInflater.java:863)
at android.view.LayoutInflater_Delegate.rInflate(LayoutInflater_Delegate.java:72)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:837)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:394)
at com.android.layoutlib.bridge.impl.RenderSessionImpl.inflate(RenderSessionImpl.java:323)
at com.android.layoutlib.bridge.Bridge.createSession(Bridge.java:394)
at com.android.tools.idea.layoutlib.LayoutLibrary.createSession(LayoutLibrary.java:200)
at com.android.tools.idea.rendering.RenderTask.createRenderSession(RenderTask.java:572)
at com.android.tools.idea.rendering.RenderTask.lambda$inflate$5(RenderTask.java:698)
at java.util.concurrent.CompletableFuture$AsyncSupply.run(CompletableFuture.java:1590)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624)
at java.lang.Thread.run(Thread.java:748)
Due to this, the class is not instantinated and I get something like this:-
Also, here a small picture of the error too:-
Thanks for everyone helping out there to solve this issue.
Please also inform if you need anything else.

try to add this line in your dependencies in build.gradle
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'com.android.support:design:29.0.2'
don't worry about the difference between com.android..... and androidx.... This implementation androidx. automatically migrate the implementation if your android studio is higher than 3.2.
you can check this link.https://stackoverflow.com/a/58619780/10075771 it will help you understand also the situation :)
Hoping i help you in little way :)

try adding below dependencies
implementation 'com.android.support:appcompat-v7:23.1.1'
implementation 'com.android.support:design:23.1.1'
Hope this will work for you.

Related

How to disable scrolling for CalendarView - Android Dev

I am currently refreshing my android developement skills and came across the CalendarView component. I wanted to disable the scrolling of the calendar and instead enable the arrows to browse through the calendar.
What I want to know is the following:
How can I disable the scrolling from the CalendarView? And why does Android Studio show me the arrow browse-version in the Designer-Mode but compiles and runs the scroll-version of the calendar?
I am running an Android VM, a "Galaxy Nexus" with API 22. I also posted the "build.gradle" further below.
What Android shows me/What I want:
What Android Studio compiles & runs:
Here some code:
// activity_main.java:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
app:layout_constraintBottom_toBottomOf="parent"
tools:layout_editor_absoluteX="0dp">
<CalendarView
android:id="#+id/calendarView4"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:isScrollContainer="false" />
</LinearLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
// build.gradle
plugins {
id 'com.android.application'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.2"
defaultConfig {
applicationId "com.example.kalender003_emptyactivity"
minSdkVersion 16
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.3.1'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
Use MaterialComponents Theme, it will most probably solve the issue.
In your values/themes file replace the parent them with this,
parent="Theme.MaterialComponents.DayNight.DarkActionBar"
If you don't want Action Bar then ,
parent="Theme.MaterialComponents.DayNight.NoActionBar"
And if you only want to show Light Coloured Calendar view regardless of Devices's theme use,
parent="Theme.MaterialComponents.Light.NoActionBar"
Thanks to Vaibhav Goyal i came across the solution.
The API level I used was to low (API 22, Android 5.1). Changing that to API 23 (Android 6.0) solved my problem. Now it shows me the CalendarView with arrow-navigation instead of the scroll version!
yourCalenenderId.addOnItemTouchListener(object : RecyclerView.SimpleOnItemTouchListener() {
override fun onInterceptTouchEvent(rv: RecyclerView, e: MotionEvent): Boolean {
return if (e.action == MotionEvent.ACTION_MOVE) {
true
} else {
super.onInterceptTouchEvent(rv, e)
}
}
})

android.view.InflateException: always error

I have frustrating error that I cannot explain. Here is my main activity layout file:
build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.asser.egycab"
minSdkVersion 23
targetSdkVersion 29
versionCode 5
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.2.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test:runner:1.3.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.vectordrawable:vectordrawable:1.1.0'
implementation 'androidx.multidex:multidex:2.0.1'
implementation 'androidx.recyclerview:recyclerview:1.1.0'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.code.findbugs:jsr305:3.0.2'
//Horizontal date picker
implementation 'joda-time:joda-time:2.9.7'
//Timeline
// implementation 'com.github.vipulasri:timelineview:1.0.6'
//Calendar
implementation 'com.applandeo:material-calendar-view:1.4.0'
//Paypal
implementation 'com.paypal.sdk:paypal-android-sdk:2.16.0'
//Credit Card
implementation 'com.craftman.cardform:cardform:0.0.2'
//Job Scheduler
implementation 'com.github.simplymadeapps:QuickPeriodicJobScheduler:-SNAPSHOT'
implementation 'com.github.jd-alexander:library:1.1.0'
//Volley
implementation 'com.mcxiaoke.volley:library-aar:1.0.1'
//Google Map
implementation 'com.google.android.gms:play-services-location:18.0.0'
implementation 'com.google.android.gms:play-services-maps:17.0.0'
implementation('com.google.android.libraries.places:places:2.4.0') {
exclude module: 'volley'
}
//Glide
implementation 'com.github.bumptech.glide:glide:4.12.0'
//Place Picker
implementation 'com.sucho:placepicker:0.1.8'
implementation 'org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.4.31'
//Firebase
implementation 'com.google.android.gms:play-services-auth:19.0.0'
implementation 'com.google.firebase:firebase-core:18.0.2'
implementation 'com.google.firebase:firebase-messaging:21.0.1'
//Retrofit
implementation('com.squareup.retrofit2:retrofit:2.9.0') {
// exclude Retrofit’s OkHttp peer-dependency module and define your own module import
exclude module: 'okhttp'
}
implementation 'com.squareup.okhttp3:logging-interceptor:5.0.0-alpha.2'
implementation 'com.squareup.okhttp3:okhttp:5.0.0-alpha.2'
implementation 'com.squareup.retrofit2:converter-gson:2.9.0'
//Braintree
implementation 'com.braintreepayments.api:drop-in:5.1.0'
}
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'
rootProject.allprojects {
repositories {
maven {
url "https://cardinalcommerce.bintray.com/android"
credentials {
username 'braintree-team-sdk#cardinalcommerce'
password '220cc9476025679c4e5c843666c27d97cfb0f951'
}
}
}
}
The error:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.asser.egycab, PID: 12254
android.view.InflateException: Binary XML file line #175 in com.asser.egycab:layout/fragment_bottom_sheet_booking: Binary XML file line #175 in com.asser.egycab:layout/fragment_bottom_sheet_booking: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #175 in com.asser.egycab:layout/fragment_bottom_sheet_booking: Error inflating class <unknown>
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:855)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1012)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:963)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1142)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1103)
at com.asser.egycab.fragment.customer.BottomSheetFragmentBooking.onCreateView(BottomSheetFragmentBooking.java:127) 
I Don't know the reall error here
android.view.InflateException: Binary XML file line #175
android.view.InflateException: Binary XML file line #175 in com.asser.egycab:layout/fragment_bottom_sheet_booking: Binary XML file line #175 in com.asser
Line #175:
<com.google.android.material.textfield.TextInputLayout
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:id="#+id/intput_layout_place"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/TextLabel">
<EditText
android:drawableTint="#color/colorLogoBlack"
android:drawableEnd="#drawable/ic_location_pin_"
android:hint="#string/specify_exactly_your_location"
android:textSize="16sp"
android:id="#+id/input_place"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:importantForAutofill="no" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:layout_marginStart="0dp"
android:layout_marginEnd="0dp"
android:id="#+id/intput_layout_people_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/TextLabel">
<EditText
android:drawableTint="#color/colorLogoBlack"
android:drawableEnd="#drawable/ic_team"
android:maxLength="2"
android:hint="#string/number_of_people"
android:textSize="16sp"
android:id="#+id/people_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:inputType="number"
android:importantForAutofill="no" />
</com.google.android.material.textfield.TextInputLayout>
And Line #127:
View rootView = inflater.inflate(R.layout.fragment_bottom_sheet_booking, container, false);
So how this error could be fixed, I search here and on Google a lot but no luck!.
Finaly i solve it
By changing <style name="TextLabel" parent="TextAppearance.AppCompat">
To <style name="TextLabel" parent="Widget.MaterialComponents.TextInputLayout.FilledBox">

How to solve Error inflating class android.support.design.widget.BottomNavigationView?

I'm trying to implement the method Bottom Navigation view but when i run my code i get this error
Caused by: android.view.InflateException: Binary XML file line #19: Binary XML file line #19: Error inflating class android.support.design.widget.BottomNavigationView
Caused by: android.view.InflateException: Binary XML file line #19: Error inflating class android.support.design.widget.BottomNavigationView
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.widget.BottomNavigationView" on path: DexPathList[
what should i do to solve this problems?
activity_home layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
app:layout_behavior="android:.support.design.widget.BottomSheetBehaviour"
tools:context=".HomeActivity">
<FrameLayout
android:id="#+id/fragment_container"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/bottom_navigation">
</FrameLayout>
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/purpleBae"
app:itemIconTint="#android:color/white"
app:itemTextColor="#android:color/white"
app:menu="#menu/home_menu" />
</RelativeLayout>
build.gradle(Module app)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "com.example.gerobokgoapp"
minSdkVersion 21
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
// Exclude file to avoid
// Error: Duplicate files during packaging of APK
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
compileOptions {
incremental true
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.2.0'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
//add libraries
implementation 'androidx.appcompat:appcompat:1.1.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'com.google.android.gms:play-services-auth:17.0.0'
implementation 'com.google.firebase:firebase-firestore:21.0.0'
implementation 'com.jakewharton:butterknife:10.1.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.1.0'
implementation 'com.facebook.android:account-kit-sdk:4.39.0'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
testImplementation 'androidx.test.ext:junit:1.1.1'
}
You cannot mix both support and androidx libraries together in the same project, there will surely be conflicts unless you're using Jetpack tool. Migrate your support libraries to androidx
Also References in an Androidx layout file should all be androidx artifacts and not otherwise.
Hence tag like this:
<android.support.design.widget.BottomNavigationView
android:id="#+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/purpleBae"
app:itemIconTint="#android:color/white"
app:itemTextColor="#android:color/white"
app:menu="#menu/home_menu" />
Should be:
<com.google.android.material.bottomnavigation.BottomNavigationView
android:id="#+id/bottom_navigation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:background="#color/purpleBae"
app:itemIconTint="#android:color/white"
app:itemTextColor="#android:color/white"
app:menu="#menu/home_menu" />
add below dependency:
dependencies {
// https://mvnrepository.com/artifact/com.google.android.material/material
implementation "com.google.android.material:material:1.0.0"
}
and use com.google.android.material.bottomnavigation.BottomNavigationView instead

android studio showing control as text

Android studio not showing the controls from 'com.android.support:support-v4:28.0.0' properly even if i added it in my build.gradle file
i have already tried setting AppTheme in my styles.xml to 'Base.Theme.AppCompat.Light.DarkActionBar' and tried multiple rebuilds
<android.support.v4.widget.DrawerLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"/>
here the 'android.support.v4.widget.DrawerLayout' just shows as android.support.v4.widget.DrawerLayout in the preview
[this is what shows in the preview][1]
here's my gradle.build file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.alto.alizer.altovpn"
minSdkVersion 19
targetSdkVersion 28
versionCode 1
versionName "1.2"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
minifyEnabled true
shrinkResources false
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design: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'
}

Theme Error - how to fix?

Tried Many Solution But No Helped
Ref : Failed to find style 'coordinatorLayoutStyle' in current theme
But not Helped
Render Problem:
Failed to find style 'coordinatorLayoutStyle' in current theme
Tip: Try to refresh the layout.
build.gradle file of my project is :
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
module:app
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "*****"
minSdkVersion 19
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-alpha1'
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'
implementation 'com.android.support:design:28.0.0-alpha1'
}
main Activity XML code
<?xml version="1.0" encoding="utf-8"?>
<android.support.design.widget.CoordinatorLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<android.support.design.bottomappbar.BottomAppBar
android:id="#+id/bar"
style="#style/Widget.MaterialComponents.BottomAppBar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
app:navigationIcon="#drawable/ic_menu"
app:theme="#style/ThemeOverlay.AppCompat.Dark.ActionBar"
app:popupTheme="#style/ThemeOverlay.AppCompat.Light"
app:fabAttached="true"
app:backgroundTint="#color/colorPrimary"
app:fabCradleVerticalOffset="12dp"/>
<android.support.design.widget.FloatingActionButton
android:id="#+id/fab"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_anchor="#id/bar"/>
</android.support.design.widget.CoordinatorLayout>
Why I am Not changing compiled SDK version 28 to 27
bcz I want to use Bottom app bar
Bottom App Bar Material Design
App Bars:Bottom- Material Design
This is a bug in 28.0.0 and the only fix(workaround) is adding this to your Build.gradle:
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == "com.android.support") {
if (!requested.name.startsWith("multidex")) {
details.useVersion "27.1.1"
}
}
}
}
Which somehow, this bypasses the issue and uses 27 support library for that. Otherwise, you may wanna update your Android Studio to canary channel version or using backward support library like 27.1.1 or etc.
This error was occurred in your Rendering Layout which is a part of Studio Not in any files or Library
Try adding "Base" before Theme in styles.xml as show : -
"Base.Theme.AppCompat.Light.DarkActionBar"
Please restart Android Studio by selecting the menu option "File" →
"Invalidate Caches / Restart"
Workarounds: Try rendering with M preview using AS v1.3 preview OR
use FrameLayout for designing and change to
android.support.design.widget.CoordinatorLayout while debugging.

Categories