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.
Related
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.
Failed to find style 'floatingActionButtonStyle' in current theme.
I even tried doing this in my style.xml
<style name="AppTheme" parent="Base.Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="floatingActionButtonStyle">#style/Widget.Design.FloatingActionButton</item>
</style>
It did not work. I used Base.theme because of appcompat problem I was facing . My appcompat is - 'com.android.support:appcompat-v7:28.0.0-alpha1
Here is the XML file where error is shown:
<?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:id="#+id/activity_main"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:paddingBottom="16dp"
android:paddingLeft="16dp"
android:paddingRight="16dp"
android:paddingTop="16dp"
tools:context=".MainActivity">
<android.support.design.widget.FloatingActionButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:clickable="true"
android:focusable="true"
android:src="#drawable/ic_send"
android:id="#+id/fab"
android:tint="#android:color/white"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
app:fabSize="mini"
/>
<android.support.design.widget.TextInputLayout
android:layout_height="wrap_content"
android:layout_width="match_parent"
android:layout_toLeftOf="#+id/fab"
android:layout_alignParentBottom="true"
android:layout_toStartOf="#+id/fab"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
>
<EditText
android:id="#+id/input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="Message..."
android:inputType="text" />
</android.support.design.widget.TextInputLayout>
<ListView
android:id="#+id/list_of_message"
android:layout_alignParentTop="true"
android:layout_alignParentStart="true"
android:layout_above="#+id/fab"
android:dividerHeight="16dp"
android:divider="#android:color/transparent"
android:layout_marginBottom="16dp"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentLeft="true">
</ListView>
</RelativeLayout>
Build.gradle(app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.example.hp.chatapp"
minSdkVersion 16
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: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'
//add library
implementation 'com.android.support:design:27.1.1'
// implementation 'com.firebaseui:firebase-ui-database:4.1.0'
}
apply plugin: 'com.google.gms.google-services'
After all the comments this is what I came up to:
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.hp.chatapp"
minSdkVersion 16
targetSdkVersion 27
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: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'
//add library
implementation 'com.android.support:design:27.1.1'
// implementation 'com.firebaseui:firebase-ui-database:4.1.0'
// consider using implementation 'com.firebaseui:firebase-ui-database:3.1.1'
// see the question below
}
apply plugin: 'com.google.gms.google-services'
I suggest using compileSdkVersion and targetSdkVersion 27 because, as you noticed,
28.0.0-alpha1 doesnt support FloatingActionButton style.
and might also cause problems as it is in alpha version.
Question about firebase-ui-database here.
Extra: You can search for libraries here and see how many people are using it or the release date.
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
for round about 2 weeks from now, I receive an error message, whenever I try to preview an .xml design-file in my Android Studio Project. As I am relatively new to the whole topic I'd like to ask whether you have an answer.
The error message:
Rendering Problems:
The following classes could not be found:
- android.support.v7.widget.Toolbar
OR
Rendering Problems:
The following classes could not be found:
- android.support.v7.widget.CardView
One of the .xml files:
<?xml version="1.0" encoding="utf-8"?>
<android.support.v7.widget.Toolbar xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:orientation="vertical"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/toolbar_tabs"
android:background="#color/primaryColor"
app:contentInsetStart="0dp"
app:contentInsetEnd="0dp">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="56dp">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="VPlan App RC1"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/white"
android:textSize="20sp"
android:layout_marginLeft="16dp"
android:fontFamily="sans-serif-medium"
android:id="#+id/textView7"
android:layout_marginStart="16dp"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true" />
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_marginRight="16dp"
android:layout_marginTop="16dp"
android:layout_centerHorizontal="true"
android:src="#drawable/ic_refresh"
android:id="#+id/ic_refresh"/>
</RelativeLayout>
<com.astuetz.PagerSlidingTabStrip
android:layout_width="match_parent"
android:layout_height="48dp"
android:background="#color/primaryColor"
android:textColorPrimary="#color/white"
android:textSize="14sp"
android:id="#+id/tabs"
android:layout_marginTop="?attr/actionBarSize" />
</RelativeLayout>
</android.support.v7.widget.Toolbar>
Also as it might help, here's the build.gradle file where the support library is located.
The build.grade file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId 'com.nocomment.vplanehs'
minSdkVersion 10
targetSdkVersion 22
versionCode 16
versionName '0.8.5_RC1'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':volley')
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.android.support:cardview-v7:22.1.1'
compile 'com.android.support:recyclerview-v7:22.1.1'
compile 'com.android.support:support-v4:22.2.1'
compile 'com.jpardogo.materialtabstrip:library:1.0.9'
}
In this project we also use volley as well as libraries from ZXing's QR Code reader.
I'd be very thankful if someone could help me. Thank you in advance!
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.