ERROR: Failed to resolve: viewpager - how to fix that? - android

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'

Related

I am trying to import a ConstraintLayout to my xml file

I am getting an error:No enum constant com.android.manifmerger.AttributeOperationType.CONTEXT.
when I am trying to use ConstraintLayout
enter image description here
Here is my xml file:
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context=".MainActivity">
<EditText
android:id="#+id/inputFirstName"
android:layout_width="398dp"
android:layout_height="47dp"
android:layout_margin="10dp"
android:layout_marginEnd="188dp"
android:layout_marginBottom="21dp"
android:hint="Enter your first name"
android:minHeight="48dp"
app:layout_constraintBottom_toTopOf="#+id/inputLastName"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.848" />
<EditText
android:id="#+id/inputLastName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="135dp"
android:hint="Enter your last name"
android:minHeight="48dp"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<Button
android:id="#+id/btnUploadData"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginHorizontal="8dp"
android:layout_marginStart="8dp"
android:layout_marginTop="56dp"
android:layout_marginEnd="8dp"
android:text="#string/save_data"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/inputLastName" />
<Button
android:id="#+id/btnReadData"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="44dp"
android:layout_marginEnd="8dp"
android:text="#string/retrieve_data"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/btnUploadData"
app:layout_constraintVertical_bias="0.0" />
<TextView
android:id="#+id/textViewResultTitle"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginStart="104dp"
android:layout_marginTop="43dp"
android:text="FireStore data :"
android:textSize="24sp"
android:textStyle="bold"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/btnReadData" />
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="10dp"
android:layout_marginStart="8dp"
android:layout_marginTop="48dp"
android:text=""
android:textSize="16sp"
android:textStyle="bold"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="#+id/textViewResultTitle"
app:layout_constraintVertical_bias="0.081" />
</androidx.constraintlayout.widget.ConstraintLayout>
When I tried to use ConstraintLayout I deleted a and put instead
This is what I found on the forums. It didn't work so I decided to return and put in it "androidx.constraintlayout.widget.ConstraintLayout" but it also gave me an error. So I don't know how to fix it. Maybe it is because of that my xml file is in the manifest folder: enter image description here
Here is my dependencies in build.gradle (:app):
build.gradle (:app) File
plugins {
id 'com.android.application'
id 'org.jetbrains.kotlin.android'
id 'com.google.gms.google-services'
}
android {
namespace 'com.example.myapplication'
compileSdk 32
defaultConfig {
applicationId "com.example.myapplication"
minSdk 19
targetSdk 32
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'
}
buildFeatures {
viewBinding true
}
}
dependencies {
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.5.1'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation platform('com.google.firebase:firebase-bom:31.1.0')
implementation 'com.google.firebase:firebase-analytics-ktx'
implementation 'com.google.firebase:firebase-firestore-ktx:24.1.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
// To use constraintlayout in compose
implementation("androidx.constraintlayout:constraintlayout-compose:1.0.1")
}
According to your screenshot, you've replaced your AndroidManifest.xml's contents with layout XML. That file is extremely important and you'll get all kinds of errors if you try to build without a valid one!
You need to revert it and then create a layout file (in the res/layout folder) for the layout XML you're trying to use

resource android:attr/android:progressBarStyle not found

I've got this error when I tried to build my project after I updated Android Studio to the lastest version. I am getting below error:
C:\Users\YaCn.gradle\caches\transforms-2\files-2.1\5502c0022567bdcff063e0fb4352b137\folioreader-0.3.3\res\layout\progress_dialog.xml:10:
AAPT: error: resource android:attr/android:progressBarStyle not found.
that XML :
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent">
<LinearLayout android:id="#+id/layout_loading"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center">
<ProgressBar android:id="#+id/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/android:progressBarStyle"/>
<TextView android:id="#+id/label_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:textSize="18sp"
android:textColor="#android:color/white"
android:text="#string/loading"/>
</LinearLayout>
</RelativeLayout>
build gradle file :
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.admin.hashtab"
minSdkVersion 16
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
manifestPlaceholders = [manifestApplicationId : "${applicationId}",
onesignal_app_id : "654bcb8c-90a6-4012-924a-e18e5787a7de",
onesignal_google_project_number: "3520309722"]
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility = 1.8
targetCompatibility = 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:27.1.0'
implementation 'com.android.support:design:27.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
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'
implementation 'com.loopj.android:android-async-http:1.4.9'
implementation 'com.android.support:recyclerview-v7:27.1.0'
implementation 'com.android.support:cardview-v7:27.1.0'
implementation 'com.wang.avi:library:2.1.3'
implementation 'com.makeramen:roundedimageview:2.3.0'
implementation 'de.hdodenhof:circleimageview:2.2.0'
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'uk.co.chrisjenx:calligraphy:2.3.0'
implementation 'com.google.android.gms:play-services-ads:12.0.1'
implementation 'com.google.android.gms:play-services-gcm:12.0.1'
implementation 'com.google.android.gms:play-services-analytics:12.0.1'
implementation 'com.onesignal:OneSignal:3.+#aar'
implementation 'com.google.firebase:firebase-core:12.0.1'
implementation 'com.github.ornolfr:rating-view:0.1.2#aar'
implementation project(path: ':library')
implementation project(path: ':SmoothCheckBox-master')
implementation 'com.github.barteksc:android-pdf-viewer:2.8.2'
implementation 'com.folioreader:folioreader:0.3.3'
implementation 'com.android.support:multidex:1.0.3'
implementation 'com.lmntrx.android.library.livin.missme:missme:0.1.5'
}
// Add to the bottom of the file
apply plugin: 'com.google.gms.google-services'
Try adding this to your dependency
implementation "com.folioreader:folioreader:0.5.4"//this is just the updated version as of now
implementation 'com.android.support:multidex:1.0.3' // ( for androidx)
configurations.matching { it.name == '_internal_aapt2_binary' }.all {
config -> config.resolutionStrategy.eachDependency {
details -> details.useVersion("3.3.2-5309881")
}
}
You have used wrong syles.Just change your style to:
style="?android:attr/progressBarStyle"
instead of
style="?android:attr/android:progressBarStyle"
Make a new file in layout, name it progress_dialog.xml and paste this code.
<LinearLayout android:id="#+id/layout_loading"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:gravity="center"
xmlns:android="http://schemas.android.com/apk/res/android">
<ProgressBar
android:id="#+id/loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
style="?android:attr/progressBarStyle" />
<TextView
android:id="#+id/label_loading"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:textSize="18sp"
android:textColor="#android:color/white"
android:text="#string/loading" />
</LinearLayout>

Caused by: java.lang.IllegalArgumentException: couldn't make a guess for com.example.example.databinding.ContentClassApplicationMyClass1Binding

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

android.support.v7.widget.Toolbar not found (Android Studio)

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!

Android MapBox inflating error

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.

Categories

Resources