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!
Related
I am experiencing layout issues when trying to use the latest versions of constraint layout. It seems to not follow guideline rules. Is this a bug in the library? My project uses many guidelines and to change every one of them would be a huge pain. Anyone know if there is a work around of am I doing this wrong? This layout issue seems to happen in versions greater than constraint layout 2.0.1.
Constraint layout v 1.1.3
Constraint Layout v 2.0.4 - the location icon is behind my widget constraint layout
MainActivity layout 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"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#ffffffff"
android:clickable="true"
android:focusable="true">
<androidx.appcompat.widget.AppCompatEditText
android:id="#+id/edit_text_message_input"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:background="#null"
android:hint="Please Type Something"
android:maxHeight="100dp"
android:minHeight="56dp"
android:paddingStart="16dp"
android:paddingTop="8dp"
android:paddingEnd="16dp"
android:paddingBottom="13dp"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent">
<requestFocus />
</androidx.appcompat.widget.AppCompatEditText>
<RelativeLayout
android:id="#+id/mic_container"
android:layout_width="140dp"
android:layout_height="140dp"
app:layout_constraintTop_toBottomOf="#+id/edit_text_message_input"
app:layout_constraintBottom_toTopOf="#+id/edit_text_message_input"
app:layout_constraintLeft_toLeftOf="#+id/mic_icon_guideline"
app:layout_constraintRight_toRightOf="#+id/mic_icon_guideline">
<CheckBox
android:layout_centerInParent="true"
android:id="#+id/button_nav"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:button="#drawable/navigation_button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
</RelativeLayout>
<androidx.constraintlayout.widget.Guideline
android:id="#+id/mic_icon_guideline"
app:layout_constraintGuide_end="28dp"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="vertical"/>
<androidx.constraintlayout.widget.ConstraintLayout
android:id="#+id/attachment_icon_container"
android:layout_width="match_parent"
android:layout_height="48dp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toBottomOf="#+id/edit_text_message_input">
<CheckBox
android:id="#+id/button_add_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="16dp"
android:button="#drawable/add_location_button"
app:layout_constraintLeft_toRightOf="#+id/button_remove_location"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<CheckBox
android:id="#+id/button_remove_location"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="32dp"
android:button="#drawable/remove_location_button"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toRightOf="#+id/button_add_location"
app:layout_constraintTop_toTopOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</androidx.constraintlayout.widget.ConstraintLayout>
build.gradle file
plugins {
id 'com.android.application'
id 'kotlin-android'
}
android {
compileSdkVersion 29
buildToolsVersion "29.0.3"
defaultConfig {
applicationId "com.example.test_constraint_project"
minSdkVersion 28
targetSdkVersion 29
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
kotlinOptions {
jvmTarget = '1.8'
}
}
dependencies {
implementation "org.jetbrains.kotlin:kotlin-stdlib:$kotlin_version"
implementation "androidx.core:core-ktx:1.3.2"
implementation "androidx.appcompat:appcompat:1.2.0"
implementation "com.google.android.material:material:1.2.1"
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
//implementation 'androidx.constraintlayout:constraintlayout:2.0.4'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.2'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0'
}
The RelativeLayout mic_container has the following constraints:
app:layout_constraintTop_toBottomOf="#+id/edit_text_message_input"
app:layout_constraintBottom_toTopOf="#+id/edit_text_message_input"
It doesn't seem right that the top of one view should be constrained to the bottom of another and the bottom of the first view should be constrainted to the top of the second. This is really an invalid situation and I think that you are seeing ConstraintLayout resolving this differently between the two versions.
If you state the following as constraints:
app:layout_constraintTop_toTopOf="#+id/edit_text_message_input"
app:layout_constraintBottom_toBottomOf="#+id/edit_text_message_input"
I think that you will see mic_container positioned appropriately. You will have to determine if this solves all of your problems or not.
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.