I am trying to use Safe Args with the NavigationComponent. I have followed a tutorial, but I have problems because any class is generated automatically, so I can't pass any arguments because Classes (obviously) are not recognized
These are my Gradle file
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
mavenCentral()
}
dependencies {
def nav_version = "2.4.1"
classpath "androidx.navigation:navigation-safe-args-gradle-plugin:$nav_version"
classpath 'com.android.tools.build:gradle:7.1.0'
classpath 'com.google.gms:google-services:4.3.10'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
plugins {
id 'com.android.application'
id 'com.google.gms.google-services'
id 'androidx.navigation.safeargs'
}
android {
compileSdk 31
defaultConfig {
applicationId "com.example.frangela"
minSdk 21
targetSdk 31
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
}
buildFeatures {
viewBinding true
}
}
dependencies {
def nav_version = "2.4.1"
implementation 'androidx.appcompat:appcompat:1.4.1'
implementation 'com.google.android.material:material:1.5.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.3'
implementation 'androidx.lifecycle:lifecycle-livedata-ktx:2.4.0'
implementation 'androidx.lifecycle:lifecycle-viewmodel-ktx:2.4.0'
implementation "androidx.navigation:navigation-fragment:$nav_version"
implementation "androidx.navigation:navigation-ui:$nav_version"
implementation 'com.google.firebase:firebase-database:20.0.3'
implementation 'com.google.firebase:firebase-common-ktx:20.0.0'
implementation 'com.google.android.gms:play-services-maps:18.0.1'
implementation 'com.google.android.gms:play-services-location:19.0.1'
implementation 'com.google.firebase:firebase-crashlytics-buildtools:2.8.1'
testImplementation 'junit:junit:'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation platform('com.google.firebase:firebase-bom:29.0.3')
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation 'com.firebaseui:firebase-ui-database:6.2.1'
implementation 'com.google.firebase:firebase-auth'
implementation 'com.google.android.gms:play-services-auth:20.1.0'
}
This is the xml code:
<?xml version="1.0" encoding="utf-8"?>
<navigation 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:id="#+id/mobile_navigation"
app:startDestination="#+id/nav_home">
<fragment
android:id="#+id/nav_home"
android:name="com.example.frangela.ui.home.HomeFragment"
android:label="#string/menu_home"
tools:layout="#layout/fragment_home" />
<fragment
android:id="#+id/nav_gallery"
android:name="com.example.frangela.ui.gallery.GalleryFragment"
android:label="#string/menu_gallery"
tools:layout="#layout/fragment_gallery" />
<fragment
android:id="#+id/nav_slideshow"
android:name="com.example.frangela.ui.slideshow.InserisciSpesaFragment"
android:label="#string/menu_slideshow"
tools:layout="#layout/fragment_inserisci" >
<argument
android:name="descrizione"
app:argType="string" />
<argument
android:name="ammontare"
app:argType="float" />
</fragment>
<fragment
android:id="#+id/nav_stipendio"
android:name="com.example.frangela.ui.stipendio.InserisciStipendioFragment"
android:label="#string/menu_stipendio"
tools:layout="#layout/fragment_stipendio" />
<fragment
android:id="#+id/nav_resoconto"
android:name="com.example.frangela.ui.resocard.ResocardFragment"
android:label="#string/Resoconto"
tools:layout="#layout/fragment_resocard" >
<action
android:id="#+id/action_nav_resoconto_to_nav_slideshow"
app:destination="#id/nav_slideshow" />
</fragment>
</navigation>
After that I resync my project and rebuild, but nothing changes.
I tried to follow different tutorials and questions but none of them solved my problem. What am I missing?
Thanks in advance
After some days, I have found that the code has been generated, but in different folders, so that I cannot see them
Related
I'm trying to get datas from my class to my xml file so i tried to use data binding. But data-binding library does not working. When i write <data in my xml file, compiler does not shows anything. How can i solve this problem ? Otherwise how can i get datas from class to xml file without data binding ? Xml belongs to a fragment view.
'''plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
id("androidx.navigation.safeargs")
id 'com.google.gms.google-services'
id "org.jetbrains.kotlin.kapt"
id 'kotlin-kapt'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.cagataysencan.forumfisk_it"
minSdkVersion 24
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'
}
buildFeatures {
dataBinding true
}
}
dataBinding {
enabled = true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.5.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.3.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
//Navigation v Google Maps
implementation("androidx.navigation:navigation-fragment-ktx:2.3.5")
implementation("androidx.navigation:navigation-ui-ktx:2.3.5")
implementation 'com.google.android.gms:play-services-maps:17.0.1'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// Firebase
implementation platform('com.google.firebase:firebase-bom:28.2.0')
implementation 'com.google.firebase:firebase-auth-ktx'
implementation 'com.google.firebase:firebase-firestore-ktx'
implementation 'com.google.firebase:firebase-storage-ktx'
// Picasso
implementation 'com.squareup.picasso:picasso:2.71828'
// ViewModel
implementation("androidx.lifecycle:lifecycle-viewmodel-ktx:2.3.1")
implementation("androidx.lifecycle:lifecycle-livedata-ktx:2.3.1")
implementation("androidx.lifecycle:lifecycle-runtime-ktx:2.3.1")
implementation("androidx.lifecycle:lifecycle-viewmodel-savedstate:2.3.1")
implementation("androidx.lifecycle:lifecycle-service:2.3.1")
implementation("androidx.lifecycle:lifecycle-process:2.3.1")
implementation("androidx.lifecycle:lifecycle-reactivestreams-ktx:2.3.1")
testImplementation("androidx.arch.core:core-testing:2.1.0")
// Retrofit
implementation 'com.squareup.retrofit2:retrofit:2.8.1'
implementation 'com.squareup.retrofit2:converter-gson:2.8.1'
implementation "com.squareup.retrofit2:adapter-rxjava2:2.8.1"
// RX Java
implementation "io.reactivex.rxjava2:rxjava:2.2.9"
implementation "io.reactivex.rxjava2:rxandroid:2.1.1"
// Glide
implementation 'com.github.bumptech.glide:glide:4.12.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.12.0'
// Room
implementation 'androidx.room:room-rxjava2:2.3.0'
implementation "androidx.room:room-guava:2.3.0"
implementation "androidx.room:room-ktx:2.3.0"
implementation ("androidx.room:room-runtime:2.3.0")
annotationProcessor "androidx.room:room-compiler:2.3.0"
kapt("androidx.room:room-compiler:2.3.0")
implementation "org.jetbrains.kotlinx:kotlinx-coroutines-core:1.4.1"
}**
Remove the lines:
databinding {
enabled=true
}
Also, remove viewBinding since there is no need for it if you are already using dataBinding..
Move buildFeatures out of buildTypes so that it should be like this
android {
...
buildTypes {
...
}
buildFeatures {
dataBinding true
}
}
And when you want to use dataBinding, make sure you enclose your layout with the <layout> tag to signify that the layout is eligible for dataBinding. So each xml file you want to bind should have the <layout> tag and can be like this for example:
<layout 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">
<data>
...
</data>
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<TextView
...
...
</layout>
Please match some line of plugin and dependency and version with kotlin and databinding in your gradle file that what you missing please check
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
dependencies{
kapt 'com.android.databinding:compiler:4.0.0'
}
ext.kotlin_version = '1.4.10'
classpath 'com.android.tools.build:gradle:4.0.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
Hope it may help you
masters.
I've just started developing an Android(kotlin).
I tried to use open source for my project, but there is an error.
What am I supposed to do here?
(I referred to "https://androidexample365.com/customizable-timetableview-for-android/")
my project's gradle(module)-----------------------------------------------------------------------
plugins {
id 'com.android.application'
id 'kotlin-android'
id 'kotlin-android-extensions'
}
android {
compileSdkVersion 30
buildToolsVersion "30.0.3"
defaultConfig {
applicationId "com.akj.callback"
minSdkVersion 23
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
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation 'com.github.islandparadise14:Mintable:x.y.z'
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation 'androidx.core:core-ktx:1.6.0'
implementation 'androidx.appcompat:appcompat:1.3.0'
implementation 'com.google.android.material:material:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
implementation "com.airbnb.android:lottie-compose:1.0.0-rc02-1"
}
my project's gradle(Project)----------------------------------------------------------------------
buildscript {
ext.kotlin_version = "1.5.21"
repositories {
google()
mavenCentral()
}
dependencies {
classpath "com.android.tools.build:gradle:4.2.2"
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
mavenCentral()
jcenter()
// Warning: this repository is going to shut down soon
maven { url uri("https://jitpack.io") }
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
my project's 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=".test_timetable">
<com.islandparadise14.mintable.MinTimeTableView
android:id="#+id/table"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
error message-------------------------------------------------------------------------------------
Execution failed for task ':app:checkDebugAarMetadata'.
> Could not resolve all files for configuration ':app:debugRuntimeClasspath'.
> Could not find com.github.islandparadise14:Mintable:x.y.z.
Searched in the following locations:
- https://dl.google.com/dl/android/maven2/com/github/islandparadise14/Mintable/x.y.z/Mintable-x.y.z.pom
- https://repo.maven.apache.org/maven2/com/github/islandparadise14/Mintable/x.y.z/Mintable-x.y.z.pom
- https://jcenter.bintray.com/com/github/islandparadise14/Mintable/x.y.z/Mintable-x.y.z.pom
- https://jitpack.io/com/github/islandparadise14/Mintable/x.y.z/Mintable-x.y.z.pom
Required by:
project :app
Possible solution:
- Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html`enter code here`
I did not touch any of the above settings.
I just want to use this off-source for my project.
I'd like to solve this problem.
See the reference on jitpack's page. Use the latest version, or any other version that is fit for your purpose.
When you declare a remote dependency in your module-level Gradle file (written in Groovy or Kotlin), the format is generally like this:
implementation '{package/group}:{module/project}:{versionNumber}'
// Example: 'com.example.android:app-magic:12.3'
// which is shorthand for:
implementation group: 'com.example.android', name: 'app-magic', version: '12.3'
See the Android docs for more info.
Here, the module/project name may or may not be present, as it is typically optional for the creator of the library/module to generate or use. Thus, in the case of the Mintable project, to use the newest version, you would use:
implementation 'com.github.islandparadise14:Mintable:1.5.1' //in place of x.y.z
Hope this information is also helpful in the future. All the best!
firstly my module build.gradle was like this:
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.depressionanalysis"
minSdkVersion 27
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'
}
}
productFlavors {
}
buildToolsVersion '28.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.firebase:firebase-firestore:17.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.guava:guava:27.0.1-jre'
implementation 'com.loopj.android:android-async-http:1.4.9'
}
which resulted in this warning:
" The app gradle file must have a dependency on com.google.firebase:firebase-core for Firebase services to work as intended. "
so i tried to add it in (and updated firestore as well)
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.depressionanalysis"
minSdkVersion 27
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'
}
}
productFlavors {
}
buildToolsVersion '28.0.3'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0-rc02'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:28.0.0'
implementation 'com.google.firebase:firebase-firestore:21.4.2'
implementation 'com.google.firebase:firebase-core:17.3.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.guava:guava:27.0.1-jre'
implementation 'com.loopj.android:android-async-http:1.4.9'
}
but got this 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:10:5-46:19 to override. "
How do i fix it? I've tried out a few solutions found here but to no avail.. Thanks in advance! Let me know if any other codes are needed!!
You are using the latest version of firestore:
com.google.firebase:firebase-firestore:21.4.2
and on June 2019, firebase started supporting androidX, therefore you need to migrate to androidX to be able to use firebase.
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.
Check how to migrate:
https://developer.android.com/jetpack/androidx/migrate
Actually, for the same library, you have different versions via different sources, You have support library as well as their AndroidX version, For Now, you can try solving it using
tools:replace="android:appComponentFactory
attribute as given in your error itself.
Go to your AndroidManifest file add this attribute like below.
<application
android:name=".AbcApplication"
tools:replace="android:appComponentFactory
>
</application>
for me i have add two attribute in AndroidMenifest.xml
tools:replace="android:appComponentFactory"
android:appComponentFactory="androidx"
full tag it like :
<application
android:allowBackup="true"
android:icon="#mipmap/logo"
android:label="#string/app_name"
android:roundIcon="#mipmap/logo"
android:theme="#style/AppTheme"
tools:replace="android:appComponentFactory"
android:appComponentFactory="androidx"
tools:ignore="GoogleAppIndexingWarning">
and your project should be in Androidx.
I've got an error for 'Theme.MaterialComponents.Light.NoActionBar' in styles.xml (the 'Theme.MaterialComponents.Light.NoActionBar' is colored red because of error) after several gradle update. My component are also not well arranged according to my idea of designing.
I've already clean and rebuild project, invalidate caches/restart, update the gradle (maybe not the correct answer) and there's no answer for this. I just think maybe I'm the only one that have this problem maybe for my beginner level problem :')
styles.xml
`
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.MaterialComponents.Light.NoActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">#color/colorPrimary</item>
<item name="colorPrimaryDark">#color/hitam</item>
<item name="colorAccent">#color/colorAccent</item>
</style>
`
Project gradle
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.4.2'
classpath 'com.google.gms:google-services:4.2.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
'
App gradle
apply plugin: 'com.android.application'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 29
defaultConfig {
applicationId "blablabla"
minSdkVersion 23
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
buildToolsVersion '29.0.1'
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_6
targetCompatibility JavaVersion.VERSION_1_6
sourceCompatibility JavaVersion.VERSION_1_7
targetCompatibility JavaVersion.VERSION_1_7
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.google.ar.sceneform.ux:sceneform-ux:1.10.0'
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'com.google.firebase:firebase-core:17.0.1'
implementation 'com.google.firebase:firebase-auth:18.1.0'
implementation 'com.google.firebase:firebase-database:18.0.0'
implementation 'androidx.appcompat:appcompat:1.1.0-rc01'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
}
apply plugin: 'com.google.gms.google-services'
buildToolsVersion = '29.0.1'
}
`
I expect the error is not visible when there's like no one in this earth that have this error. PLEASE HELP T_T
The Material Components themes are included in the Material Components for Android library.
Since you are using androidx library just add this dependency in you app/build.gradle file.
dependencies {
// ...
implementation 'com.google.android.material:material:x.x.x'
// ...
}
Currently (April 29, 2022) the latest stable version is
implementation 'com.google.android.material:material:1.5.0'
Here you can find all the info the setup.
The reason why the MaterialComponents theme does not show is because you did not include the required Material Components library in your app/build.gradle:
dependencies {
implementation 'com.google.android.material:material:<version>'
}
The currently available versions are listed on the project's GitHub releases.
Add the dependency on Android’s Material in /android/app/build.gradle:
dependencies {
// ...
implementation 'com.google.android.material:material:<version>'
// ...
}
To find out the latest version, visit Google Maven.
Set the theme in /android/app/src/main/res/values/styles.xml:
//<style name="LaunchTheme" parent="Theme.AppCompat"> - remove
<style name="LaunchTheme" parent="Theme.MaterialComponents.NoActionBar"> - add
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.