Chip material component crash
I'm using android.support.design.chip.Chip material element using com.android.support:appcompat-v7:28.0.0 support library. App crashes with this error:
Caused by: android.view.InflateException: Binary XML file line #130: Binary XML file line #130: Error inflating class com.google.android.material.chip.Chip
Caused by: android.view.InflateException: Binary XML file line #130: Error inflating class com.google.android.material.chip.Chip
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.google.android.material.chip.Chip" on path: DexPathList[[zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/base.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_dependencies_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_resources_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_slice_0_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_slice_1_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_slice_2_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_slice_3_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_slice_4_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_slice_5_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_slice_6_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_slice_7_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_slice_8_apk.apk", zip file "/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.example.m22_3.pilotapp-Em4FGoATeSyeWoDIACtXXA==/lib/arm, /system/lib, /system/vendor/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:93)
I have already tried using this solution and replaced my theme parent with these:
Theme.MaterialComponents.NoActionBar
Theme.MaterialComponents.Light.NoActionBar
Theme.MaterialComponents.Light.Bridge
but still have that crash. I also Migrated to AndroidX but still no chance.
App gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.m22_3.pilotapp"
minSdkVersion 16
targetSdkVersion 28
versionCode 6
versionName "2.3"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/proguard/androidx-annotations.pro'
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'androidx.appcompat:appcompat:1.0.2'
implementation 'androidx.appcompat:appcompat:1.1.0-alpha02'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'com.google.android.material:material:1.1.0-alpha03'
implementation 'androidx.constraintlayout:constraintlayout:2.0.0-alpha3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.2-alpha01'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.2-alpha01'
implementation 'com.aurelhubert:ahbottomnavigation:2.1.0'
implementation 'com.github.florent37:expansionpanel:1.0.0'
implementation 'com.airbnb.android:lottie:2.5.5'
implementation 'com.github.PhilJay:MPAndroidChart:v3.1.0-alpha'
implementation 'com.fasterxml.jackson.core:jackson-core:2.8.9'
implementation 'com.fasterxml.jackson.core:jackson-annotations:2.8.9'
implementation 'com.fasterxml.jackson.core:jackson-databind:2.8.9'
implementation 'org.glassfish:javax.annotation:10.0-b28'
implementation 'com.github.bumptech.glide:glide:4.6.1'
}
Project's gradle file:
buildscript {
repositories {
maven { url 'https://jitpack.io' } //https://jitpack.io or https://maven.google.com
mavenCentral()
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
maven {
url 'https://jitpack.io'
}
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
XML code:
<CoodrdinateLayout>....<LinearLayout>.... <com.google.android.material.appbar.AppBarLayout
android:layout_width="200dp"
android:layout_height="wrap_content"
android:background="#color/transparent">
<HorizontalScrollView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:measureAllChildren="false"
android:scrollbars="none">
<LinearLayout
android:id="#+id/filter_linear_layout_detailAc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/cornered2_stroked_tab2color"
android:orientation="horizontal"
android:padding="5dp">
<com.google.android.material.chip.Chip
android:id="#+id/filter_chip_detailAc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/cornered_filled_tab2color"
android:padding="4dp"
android:text="#string/filter"
android:textColor="#color/white"
app:chipIcon="#drawable/filter"
app:closeIconEnabled="false"
app:singleLine="true" />
<com.google.android.material.chip.Chip
android:id="#+id/location_filter_chip_detailAc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:closeIconEnabled="true"
app:singleLine="true" />
<com.google.android.material.chip.Chip
android:id="#+id/experience_filter_chip_detailAc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:closeIconEnabled="true"
app:singleLine="true" />
<com.google.android.material.chip.Chip
android:id="#+id/timeInterval_filter_chip_detailAc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:closeIconEnabled="true"
app:singleLine="true" />
<com.google.android.material.chip.Chip
android:id="#+id/industry_filter_chip_detailAc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:closeIconEnabled="true"
app:singleLine="true" />
<com.google.android.material.chip.Chip
android:id="#+id/partFullTime_filter_chip_detailAc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:closeIconEnabled="true"
app:singleLine="true" />
<com.google.android.material.chip.Chip
android:id="#+id/blueWhiteCollar_filter_chip_detailAc"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="gone"
app:closeIconEnabled="true"
app:singleLine="true" />
</LinearLayout>
</HorizontalScrollView>
</com.google.android.material.appbar.AppBarLayout>
Would appreciate if someone could help.
Related
I'm trying to use a viewpager in my app which used androidX but it showed me an error ERROR: Failed to resolve: viewpager Affected Modules: app after added implementation 'android.viewpager:viewpager:1.0.0' and Gradle project sync. I searched a lot but not found any solution.please any help thanks in advance.here is xml file.
xml file
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Favourites.FavouriteLinks">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_chainStyle="spread_inside"
app:popupTheme="#style/AppTheme.PopupOverlay"
tools:layout_conversion_absoluteHeight="56dp"
tools:layout_conversion_absoluteWidth="384dp" android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintVertical_bias="0.0">
<TextView
android:id="#+id/toolbar_title"
style="#style/TextAppearance.AppCompat.Widget.ActionBar.Title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fontFamily="casual"
android:gravity="left"
android:text="Favourites Brochures"
android:textColor="#color/colorwhite"
android:textSize="18sp"
android:textStyle="bold"
tools:layout_conversion_absoluteHeight="28dp"
tools:layout_conversion_absoluteWidth="56dp"
tools:layout_editor_absoluteX="16dp"
tools:layout_editor_absoluteY="14dp"/>
</androidx.appcompat.widget.Toolbar>
<com.google.android.material.tabs.TabLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/colorPrimary"
app:tabSelectedTextColor="#android:color/white"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginTop="32dp"
app:layout_constraintTop_toTopOf="#+id/toolbar"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintVertical_bias="0.04000002" android:id="#+id/tabLayout">
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textSize="21sp"
android:textStyle="bold"
android:text="tab2"
/>
<com.google.android.material.tabs.TabItem
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="tab1"
android:textSize="21sp"
android:textStyle="bold"
/>
</com.google.android.material.tabs.TabLayout>
<androidx.viewpager.widget.ViewPager
android:id="#+id/viewPager"
android:layout_width="match_parent"
android:layout_height="508dp"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
android:layout_marginBottom="8dp"
app:layout_constraintBottom_toBottomOf="parent"
android:layout_marginTop="8dp"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintVertical_bias="0.85"/>
</androidx.constraintlayout.widget.ConstraintLayout>
kotlin code
class FavouriteLinks : AppCompatActivity() {
//This is our viewPager
var viewPager: ViewPager? = null
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
setContentView(R.layout.activity_favourite_links)
setSupportActionBar(toolbar)
supportActionBar?.setDisplayShowTitleEnabled(false)
viewPager = findViewById<ViewPager>(R.id.viewPager)
val pageAdapter = PageAdapter(supportFragmentManager, tabLayout.tabCount)
viewPager?.adapter = pageAdapter
}
}
gradle file
//noinspection GradleCompatible
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-kapt'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.nanotech.i_cardplatform"
minSdkVersion 17
targetSdkVersion 21
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
//noinspection GradleCompatible
implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.0-alpha3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.0-alpha3'
implementation 'com.google.android.material:material:1.0.0-alpha1'
//RETROFIT ... NETWORK LIBRARY
implementation 'com.squareup.retrofit2:retrofit:2.4.0'
// RETROFIT .. CONVERTER
implementation 'com.squareup.retrofit2:converter-gson:2.4.0'
// Logging
implementation 'com.squareup.okhttp3:logging-interceptor:3.10.0'
implementation 'com.squareup.retrofit2:converter-scalars:2.3.0'
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.squareup.okhttp3:okhttp:3.10.0'
// Room dependencies
implementation 'androidx.room:room-runtime:2.0.0-alpha1'
kapt 'androidx.room:room-compiler:2.0.0-alpha1'
annotationProcessor 'androidx.room:room-compiler:2.0.0-alpha1'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'androidx.viewpager:viewpager:1.0.0'
}
repositories {
mavenCentral()
}
Do not add viewPager library separately it's already included in
implementation 'androidx.appcompat:appcompat:1.0.0-alpha1'
I'm getting this error in android after updating the android studio from 3.0 to 3.1 and Gradle from 3.1 to 4.4.
How can I fix it?
It's working properly with Gradle 3.1 and android studio 3.0.
How can I get it to work?
Gradle app:
buildscript {
repositories {
maven { url 'https://maven.fabric.io/public' }
}
dependencies {
classpath 'io.fabric.tools:gradle:1.+'
}
}
apply plugin: 'com.android.application'
apply plugin: 'io.fabric'
repositories {
mavenCentral()
google()
maven { url 'https://maven.fabric.io/public' }
}
android {
compileSdkVersion 27
dataBinding {
enabled = true
}
defaultConfig {
applicationId "com.example.example"
minSdkVersion 22
targetSdkVersion 23
versionCode 13
versionName "1.13"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
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'
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.0.2'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:design:27.0.2'
implementation 'com.google.firebase:firebase-messaging:11.8.0'
implementation 'com.google.firebase:firebase-crash:11.8.0'
implementation 'com.google.firebase:firebase-core:11.8.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
compile 'com.amazonaws:aws-android-sdk-cognitoidentityprovider:2.6.8'
compile 'com.squareup.retrofit2:retrofit:2.2.0'
compile 'com.squareup.retrofit2:converter-gson:2.2.0'
compile 'com.amazonaws:aws-android-sdk-core:2.6.8'
compile 'com.amazonaws:aws-android-sdk-s3:2.6.8'
compile 'com.amazonaws:aws-android-sdk-ddb:2.6.8'
compile 'com.github.twinkle942910:monthyearpicker:0.0.1'
compile('com.crashlytics.sdk.android:crashlytics:2.9.0#aar') {
transitive = true;
}
compile 'com.google.android.gms:play-services-location:11.8.0'
compile 'com.zsoltsafrany:needle:1.0.0'
implementation 'com.android.support:cardview-v7:27.0.2'
compile 'com.white:progressview:1.0.1'
compile 'br.com.simplepass:loading-button-android:1.8.1'
implementation files('/libs/android-sdk-0.1.0.jar')
compile 'com.android.support:support-v4:27.0.2'
compile 'com.clevertap.android:clevertap-android-sdk:3.1.8'
compile 'testfairy:testfairy-android-sdk:1.+#aar'
implementation 'com.github.bumptech.glide:glide:4.6.1'
annotationProcessor 'com.github.bumptech.glide:compiler:4.6.1'
}
apply plugin: 'com.google.gms.google-services'
Gradle-Project:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.0'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.2.31"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.1.0'
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Gradle-wrapper.Properties:
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-4.4-all.zip
Gradle.properties
org.gradle.jvmargs=-Xmx1536m
android.databinding.enableV2=true
Layout.xml
<?xml version="1.0" encoding="utf-8"?>
<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">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:padding="4dp"
app:layout_behavior="#string/appbar_scrolling_view_behavior"
tools:context=".Class_application_MyClass1"
tools:showIn="#layout/activity_class_application_myclass_1">
<ScrollView
android:id="#+id/scrollView2"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="60dip"
android:layout_marginTop="20dip"
android:padding="10dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<android.support.v7.widget.CardView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:cardUseCompatPadding="true">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:focusableInTouchMode="true"
android:orientation="vertical"
android:padding="25dp">
<android.support.design.widget.TextInputLayout
android:id="#+id/name_TextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="25dp">
<android.support.design.widget.TextInputEditText
android:id="#+id/name"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="10dp"
android:hint="Name"
android:imeOptions="actionNext"
android:singleLine="true"
android:text=""
android:textSize="13sp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/number_TextInputLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_marginBottom="25dp">
<android.support.design.widget.TextInputEditText
android:id="#+id/number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="10dp"
android:hint="number"
android:inputType="textCapCharacters"
android:maxLength="10"
android:text=""
android:textAllCaps="true"
android:textSize="13sp" />
</android.support.design.widget.TextInputLayout>
<android.support.design.widget.TextInputLayout
android:id="#+id/classnumber_TextInputLayout"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="25dp">
<android.support.design.widget.TextInputEditText
android:id="#+id/class_number"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:drawablePadding="10dp"
android:hint="class"
android:imeOptions="actionNext"
android:inputType="textCapCharacters"
android:maxLength="15"
android:singleLine="true"
android:text=""
android:textSize="12sp" />
</android.support.design.widget.TextInputLayout>
</LinearLayout>
</android.support.v7.widget.CardView>
</ScrollView>
</android.support.constraint.ConstraintLayout>
</layout>
Activity.xml
<?xml version="1.0" encoding="utf-8"?>
<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">
<android.support.design.widget.CoordinatorLayout
android:id="#+id/top_layout"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".Class_application_MyClass1">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="#style/AppTheme.AppBarOverlay">
<android.support.v7.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:background="#color/fundscorner_blue"
app:popupTheme="#style/AppTheme.PopupOverlay" />
<android.support.constraint.ConstraintLayout
android:id="#+id/linearLayout3"
android:layout_width="fill_parent"
android:layout_height="20dp"
android:background="#color/white"
app:layout_anchor="#+id/content_class_application_myclass_1"
app:layout_anchorGravity="top|center">
<com.white.progressview.HorizontalProgressView
android:id="#+id/progress100"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:progress="25"
app:progressReachColor="#color/colorPrimary"
app:progressTextColor="#color/colorPrimary"
app:progressTextVisible="false"
android:minHeight="20dip"
android:maxHeight="20dip"
/>
</android.support.constraint.ConstraintLayout>
</android.support.design.widget.AppBarLayout>
<include
android:id="#+id/content_class_application_myclass_1"
layout="#layout/content_class_application_myclass_1"/>
<LinearLayout
app:layout_anchor="#+id/content_class_application_myclass_1"
app:layout_anchorGravity="bottom|center"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<Button
android:background="#drawable/ripple"
style="?borderlessButtonStyle"
android:id="#+id/button_stage1"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:backgroundTint="#color/fundscorner_blue"
android:text="Next"
android:textColor="#color/white"
/>
</LinearLayout>
</android.support.design.widget.CoordinatorLayout>
</layout>
In JAVA file:
ActivityClassApplicationMyClass1Binding binding;
binding = DataBindingUtil.setContentView(this, R.layout.activity_class_application_myclass_1);
binding.name.settext("Name");
Its because of you class name or package name which use databinding. These class( which use databinding) have to start with capital word and packages start with lowercase.
The reason for this error is, as Mehdi already stated in his answer, the capitalization in the Java package name of the binding and variable classes.
When further examining the logs, you can see that the error gets thrown at ClassName.bestGuess(String). The reason is that the package name of your bound classes, aka the ones in the <variable> field in your layout, contain uppercase characters in their package name. This causes the method to not be able to separate the Class name from the package name, and it throws an error.
[to be honest, that's a rather poor behavior, but probably no better way exists (yet)]
The same is true for the generated binding class, it also needs to be in a package that doesn't have any uppercase letters in it. As it uses your app package name by default, you have to change the java package name by adding the class property to the <data> field in your layout (Read more here).
Example:
<layout xmlns:app="http://schemas.android.com/apk/res-auto">
<data class="com.example.ExampleDataBinding">
<variable
name="example"
type="com.example.ExampleClass" />
</data>
</layout>
The Binding class name seems to be wrong. Can you try changing it from ActivityClassApplicationMyClass1Binding to ActivityClassApplicationMyclass1Binding
As others have suggested, package names must start with a lowercase letter. My problem was that it started with an underscore "_" which was not allowed as well.
you need to start all the class name with capital letter and package with small.
One possible cause is the type of variable in xml layout is empty.
Example :
<variable
name="onClickListener"
type="" />
so in the above variable the type is empty this will lead to :
couldn't make a guess for
I have created a library that uses Android CardView.
The library is available as aar file.
When I add the aar file to the project, it gives the following error, on syncing. I still have not used it in the project
attribute for 'cardElevation' not found in com.sampleapp
How do I resolve this namespace issue? So anyone using the library does not have to add cardview to their gradle.
library xml file using cardview
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.CardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/networkCard"
android:layout_width="match_parent"
android:layout_height="match_parent"
app:cardUseCompatPadding="true"
app:cardCornerRadius="#dimen/cardCornerRadius"
app:cardElevation="6dp"
app:cardPreventCornerOverlap="true"
>
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/card_background"
android:clipToPadding="false">
<ImageView
android:id="#+id/source_type_icon"
style="#style/ServiceConnectUIComponentsTheme"
android:layout_alignParentTop="true"
android:src="#drawable/ic_linkedin3x"
android:tint="#android:color/white"
/>
<android.support.v7.widget.AppCompatTextView
android:id="#+id/connect_to_source_rational"
style="#style/ServiceConnectUIComponentsTheme"
android:layout_centerInParent="true"
android:text="Your LinkedIn account allows us to check your professional info, employment & education history"
/>
<FrameLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginLeft="#dimen/connect_buttons_extra_margin"
android:layout_marginStart="#dimen/connect_buttons_extra_margin"
android:layout_marginEnd="#dimen/connect_buttons_extra_margin"
android:layout_marginRight="#dimen/connect_buttons_extra_margin"
android:layout_marginTop="#dimen/connect_button_margin"
android:layout_marginBottom="#dimen/circle_indicator_connect_button_margin"
>
<Button
android:id="#+id/access_source"
android:text="Connect LinkedIn"
style="#style/Widget.AppCompat.Button.Colored"
android:background="#drawable/connect_data_button_drawable"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:elevation="10dp"
android:textAllCaps="false"
/>
<com.UIUtils.HorizontalDottedProgress
android:id="#+id/connectDataProgress"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:visibility="gone"
></com.UIUtils.HorizontalDottedProgress>
</FrameLayout>
</RelativeLayout>
</android.support.v7.widget.CardView>
The sampleapp/build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.sampleapp"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
repositories {
jcenter()
flatDir {
dirs 'libs'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.0'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta1'
testCompile 'junit:junit:4.12'
compile project(':UI-release')
}
Thanks
sorry, this answer is late am just putting it others might find it useful in their project.
Any library you used building your library or aar you have to add that library in any project you use the library you build.
let me put it like this.
for instance, I compiled a library that uses card view, I have to add the card view library to any project I want to use my library.
Im trying to add proper databinding functionality into my project, but for some reason it's still fail.
build.gradle file looks like this:
apply plugin: 'com.android.application'
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'me.tatarka:gradle-retrolambda:3.2.5'
}
}
repositories {
mavenCentral()
}
apply plugin: 'com.android.application'
apply plugin: 'me.tatarka.retrolambda'
android {
compileSdkVersion 23
buildToolsVersion "24.0.0 rc4"
defaultConfig {
applicationId "boilerplate"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dataBinding {
enabled = true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:design:23.4.0'
compile 'io.reactivex:rxandroid:1.2.0'
compile 'io.reactivex:rxjava:1.1.5'
compile 'com.jakewharton.rxbinding:rxbinding:0.4.0'
}
layout file looks like this:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="match_parent">
<data>
<variable name="user" type="boilerplate.UserModel"/>
</data>
<Button android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Test"
android:id="#+id/btn2"
android:onClick="OnBtnClick7"
android:layout_below="#+id/editText3"
android:layout_alignRight="#+id/editText3"
android:layout_alignEnd="#+id/editText3"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPersonName"
android:text="#{user.name}"
android:ems="10"
android:id="#+id/editText"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textEmailAddress"
android:ems="10"
android:id="#+id/editText2"
android:layout_below="#+id/editText"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="#{user.email}"/>
<EditText
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:inputType="textPassword"
android:ems="10"
android:id="#+id/editText3"
android:layout_below="#+id/editText2"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:text="#{user.password}"/>
</LinearLayout>
But when trying to build the code I have this errors:
Error:(23, 34) Gradle: No resource type specified (at 'text' with value '#{user.name}').
Error:(38, 35) Gradle: No resource type specified (at 'text' with value '#{user.email}').
Error:(49, 38) Gradle: No resource type specified (at 'text' with value '#{user.password}').
What should i do to fix this?
That is not the proper structure for the layout file. For a data binding layout file:
The root element is <layout> (not <LinearLayout>)
The <layout> has a child <data> element, akin to yours
Your views then follow the <data> element as a child of <layout>
For example, in this sample project, I have:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<data>
<variable
name="item"
type="com.commonsware.android.databind.basic.Item"/>
</data>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<ImageView
android:id="#+id/icon"
android:layout_width="#dimen/icon"
android:layout_height="#dimen/icon"
android:layout_gravity="center_vertical"
android:contentDescription="#string/icon"
android:padding="8dip"/>
<TextView
android:id="#+id/title"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="left|center_vertical"
android:text="#{item.title}"
android:textSize="20sp"/>
</LinearLayout>
</layout>
Hello I try to use MapBox Android SDK, but I have problem.
When APK is launched error shows like : Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class com.mapbox.mapboxsdk.views.MapView
I use Android studio.
My XML Layout
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:mapbox="http://schemas.android.com/apk/res-auto"
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.mapbox.mapboxsdk.views.MapView
android:id="#+id/mapview"
android:layout_width="match_parent"
android:layout_height="match_parent"
mapbox:mapid="map ID "/>
<LinearLayout
android:id="#+id/llCardInfo"
android:visibility="gone"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#CCffffff"
android:layout_marginLeft="8dp"
android:layout_marginRight="8dp"
android:layout_marginTop="8dp"
android:layout_marginBottom="8dp"
android:paddingLeft="8dp"
android:paddingTop="8dp"
android:paddingRight="8dp"
android:paddingBottom="8dp"
android:orientation="horizontal">
<LinearLayout
android:orientation="horizontal"
android:weightSum="1"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="0.99">
<TextView
android:layout_width="match_parent"
android:layout_height="70dp"
android:text="Hello" />
</LinearLayout>
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<ImageView
android:id="#+id/ivCloseCard"
android:visibility="invisible"
android:src="#drawable/close_card_anim"
android:layout_width="40dp"
android:layout_height="40dp"/>
</LinearLayout>
</LinearLayout>
</LinearLayout>
</RelativeLayout>
And This is Fragment.
this is my gradle file
apply plugin: 'com.android.application'
android {
compileSdkVersion 19
buildToolsVersion '19.1.0'
defaultConfig {
minSdkVersion 14
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
dexOptions {
preDexLibraries = false
}
}
repositories {
mavenCentral()
}
dependencies {
compile 'com.google.android.gms:play-services:5.0.77'
compile 'com.actionbarsherlock:actionbarsherlock:4.4.0#aar'
compile project(':lib:SlidingMenu')
compile files('libs/okhttp-2.0.0.jar')
compile files('libs/android-support-v4.jar')
compile files('libs/guava-17.0.jar')
compile files('libs/nineoldandroids-2.4.0.jar')
compile files('libs/disklrucache-2.0.2.jar')
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:0.3.0#aar'){
transitive=true
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/android-support-v4.jar')
compile files('libs/Parse-1.5.1.jar')
}
The issue is being caused by overlapping versions of OkHttp. Mapbox Android 0.3.0 uses OkHttp 1.x and the provided Gradle dependency lists also contains OkHttp 2.0. This causes confusion at runtime with this error message being the result.
Mapbox Android 0.5.0 has addresses this issue and will allow parallel use of OkHttp 2.0.