Using external library: No resource identifier found for attribute - android

I am using BetterSpinner in my app.
When I add the xml of the BetterSpinner to my app I get the following issue:
Namespace 'app' is not bound
I have found a solution here and added the following line to my xml layout:
xmlns:app="http://schemas.android.com/apk/res-auto"
Now there is no parsing issue anymore.
But when I try to run the app I get a compile error:
Error:(32) No resource identifier found for attribute 'met_floatingLabel' in package 'com.example.jublikon'
I have added the dependency like that:
compile ('com.weiwangcn.betterspinner:library-material:1.1.0') {
exclude group: 'com.android.support', module: 'appcompat-v7'
exclude group: 'com.rengwuxian.materialedittext', module: 'library'
}
Why does Android Studio not find the resources of a completely included library by gradle?
My complete xml file:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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="match_parent"
android:layout_weight="10"
android:background="#color/colorPrimary"
android:id="#+id/main">
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_gravity="center"
android:gravity="center"
android:paddingLeft="32dp"
android:layout_weight="3"
android:textStyle="bold"
android:textColor="#android:color/white"
android:paddingRight="32dp"
android:textSize="28sp"
android:text="TITLE"
android:id="#+id/title"/>
<LinearLayout
android:layout_width="fill_parent"
android:layout_height="0dp"
android:orientation="vertical"
android:gravity="center"
android:layout_weight="5">
<com.weiwangcn.betterspinner.library.material.MaterialBetterSpinner
android:id="#+id/spinner2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:hint="MaterialBetterSpinner"
app:met_floatingLabel="normal" />
</LinearLayout>
<TextView
android:layout_width="wrap_content"
android:layout_height="0dp"
android:layout_weight="3"
android:layout_gravity="center"
android:gravity="center"
android:textColor="#android:color/white"
android:paddingLeft="64dp"
android:paddingRight="64dp"
android:textSize="16sp"
android:text="description"
android:id="#+id/description" />
<TextView
android:layout_width="fill_parent"
android:layout_height="64dp" />
</LinearLayout>

According to issue #23 on BetterSpinner Github page:
https://github.com/Lesilva/BetterSpinner/issues/23
You need to have in your dependencies MaterialEditText dependencies.
Did you exclude it like guy in above post?

Related

Recycleview of cardview is not working.How can I fix it?

I am a beginner trying to learn android developement.I try to make a recyclerview using below cardview.But when I try to run It's not working.So,how can I fix it?
The cardview code below:
<?xml version="1.0" encoding="utf-8"?>
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:app="http://schemas.android.com/apk/res-auto"
app:cardCornerRadius="10dp"
android:id="#+id/list_layout"
android:background="#color/white"
android:layout_marginBottom="10dp"
>
<LinearLayout
android:layout_width="2000dp"
android:layout_height="wrap_content"
android:orientation="horizontal"
>
<RadioButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/ratio_button"
/>
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Do the work"
android:textSize="20sp"
android:id="#+id/task"
/>
<Button
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="#+id/delete"
android:backgroundTint="#color/red"
android:text="Delete"
android:visibility="invisible"
/>
</LinearLayout>
</com.google.android.material.card.MaterialCardView>
implementation 'com.android.support:cardview-v7:28.0.0'
After that, Let's try this:
androidx.cardview.widget.CardView
your question is not clear! but after trying your XML file, I believe you're missing material dependencies in your app level Gradle file
implementation 'com.google.android.material:material:1.2.1'
MaterialCardView is part of this library and you should include it in your app's dependencies before using it.

Android Studio, DrawerLayout makes design view go blank

I am new to Android development so excuse me if I ask some dumb questions but I really can't figure out why whenever I switch from a relative layout or linear to a DrawerLayout my design view goes blank and only said "android....DrawerLayout".i loose all of the buttons textfields all of it goes away! I added all of the dependencies necessary to use it. All I need this drawer layout is to add a navigation view to my main screen. I have tried the but it still nothing shows in the design view so I can't really lay things out properly without seeing how it is going to look! Any help will be really appreciated!
enter image description here
<?xml version="1.0" encoding="utf-8"?>
<!-- Use DrawerLayout as root container for activity -->
<android.support.v4.widget.DrawerLayout 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/drawer_layout"
android:layout_width="match_parent"
android:fitsSystemWindows="true"
android:layout_height="match_parent">
<!-- Layout to contain contents of main body of screen (drawer will slide over this) -->
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<android.support.v7.widget.CardView
android:id="#+id/cardView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#CC809fff"
android:padding="10dp">
<ImageView
android:id="#+id/weatherView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:adjustViewBounds="true"
android:clickable="false"
android:contextClickable="true"
android:padding="10dp"
android:src="#drawable/weather" />
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#color/cardview_dark_background"
android:padding="11dp"
android:visibility="visible" />
<TextView
android:id="#+id/textView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="0dp"
android:text="Weather"
android:textColor="#android:color/white"
android:textSize="20dp"
android:textStyle="bold" />
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/cardView2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#CC809fff"
android:padding="10dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="10dp"
android:src="#drawable/news" />
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:outlineAmbientShadowColor="#ff3300
"
android:visibility="visible">
</View>
<TextView
android:id="#+id/textview5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="0dp"
android:text="News"
android:textColor="#ffffff"
android:textSize="20dp"
android:textStyle="bold" />
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/cardView3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#CC000000"
android:padding="5dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="3dp"
android:src="#drawable/events_icon" />
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</View>
<TextView
android:id="#+id/eventsTextfield"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:text="Events"
android:textColor="#color/cardview_light_background"
android:textSize="20dp"
android:textStyle="bold" />
</android.support.v7.widget.CardView>
<android.support.v7.widget.CardView
android:id="#+id/cardView4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:backgroundTint="#CC000000"
android:padding="5dp">
<ImageView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:src="#drawable/trending_icon" />
<View
android:layout_width="wrap_content"
android:layout_height="wrap_content">
</View>
<TextView
android:id="#+id/secondview"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:gravity="center"
android:padding="10dp"
android:text="Hottest"
android:textColor="#color/cardview_light_background"
android:textSize="20dp"
android:textStyle="bold" />
</android.support.v7.widget.CardView>
</LinearLayout>
<!-- Container for contents of drawer - use NavigationView to make configuration easier -->
<android.support.design.widget.NavigationView
android:id="#+id/nav_view"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:fitsSystemWindows="true"
app:menu="#menu/drawer_view" />
</android.support.v4.widget.DrawerLayout>
MY DEPENDENCIES ARE THE FOLLOWING:
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.android.support:support-v4:28.0.0'
}
--------- BUILD.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.4'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Most times this is usually because of Android studio cache issues. You can try to invalidate and restart your Android Studio by going to:
File->Invalide Caches / Restart.
Once you have added all dependencies, this should solve your problem.
I hope this helps.
If you want to use CardView you must include its dependency
Add this dependency
implementation 'com.android.support:cardview-v7:28.0.0'

android.support.v7.widget.AppCompatTextview Failed to instataniate

i am having problem, failed to instantiate one or more classes.Following classes cannot be instantiate .
android.support.v7.widget.AppCompatTextview
There it is my xml file
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="16dp"
android:orientation="horizontal">
<de.hdodenhof.circleimageview.CircleImageView
android:id="#+id/iv_comment_owner_display"
android:layout_width="20dp"
android:layout_height="20dp"
android:src="#drawable/facebook" />
<LinearLayout
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginLeft="16dp"
android:layout_marginRight="16dp"
android:layout_weight="1"
android:orientation="vertical">
<TextView
android:id="#+id/tv_username"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Username"
android:textColor="#android:color/black"
android:textStyle="bold" />
<TextView
android:id="#+id/tv_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:text=""
android:textColor="#android:color/black" />
</LinearLayout>
</LinearLayout>
AppCompatTextView was added in appcompat-v7:22.1.0
Please check you appcompat version. You have to update your gradle file with this.
clean/Rebuild project from Android Studio,it might help.
If it doesn't try to invalidate caches and restart android studio.
If you have not done,
Try adding the dependencies in your build.gradle(Module:App)
please check the version according to your app
dependencies {
compile 'com.android.support:design:25.3.1'
}
Try putting this code in your layout
<android.support.v7.widget.AppCompatTextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="Hello world"
android:textSize="18dp"
/>
because i see no AppCompatTextView in your layout.

class file for android.support.v4.widget.TintableCompoundButton not found

I want to Create a CheckBox, My compile
sdk version is 23,
Target version is 23,
build tool version is 23.0.0,
in gradle I'hv added
compile 'com.android.support:support-v4:23.2.0',
compile 'com.android.support:appcompat-v7:23.2.0'
both and in menifest given the app theme as android:theme="#style/Theme.AppCompat.Light.NoActionBar" and no specific theme to Activity. when I run my code its throwing
InflateException line number #23 at xml file, problem while inflating kind of
Then I decided to convery a simple ChcekBox to android.support.v7.widget.AppCompatCheckBox but on the xml file Preview its showing Rendering Problems The following classes could not be instantiated:
- android.support.v7.widget.AppCompatCheckBox
Exception Details java.lang.ClassNotFoundException: android.support.v4.widget.TintableCompoundButton
and if i try to run it it gives me class file for android.support.v4.widget.TintableCompoundButton not found.
So, Any one faced this issue?
<?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:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/white"
android:orientation="vertical">
<LinearLayout
android:id="#+id/lnv_input"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="#+id/rlv_header"
android:orientation="vertical">
<android.support.v7.widget.AppCompatCheckBox
android:id="#+id/confirmCheckBox"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginLeft="20dp"
android:layout_marginRight="20dp"
android:layout_marginTop="10dp"
android:checked="false"
android:gravity="start"
android:text="#string/personal_confirm_text"
android:textColor="#color/black"
android:textSize="14sp" />
</LinearLayout>
<RelativeLayout
android:id="#+id/rlv_next"
android:layout_width="fill_parent"
android:layout_height="50dp"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="40dp"
android:background="#color/crabfx_light_gray"
android:visibility="gone">
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_alignParentTop="true"
android:background="#color/crabfx_green" />
<TextView
android:id="#+id/tv_next"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true"
android:drawablePadding="10dp"
android:drawableRight="#drawable/discloser"
android:gravity="center_vertical"
android:text="#string/lbl_next"
android:textColor="#color/black"
android:textSize="18sp" />
<View
android:layout_width="fill_parent"
android:layout_height="2dp"
android:layout_alignParentBottom="true"
android:background="#color/crabfx_green" />
</RelativeLayout>
</RelativeLayout>
and below is the theme to Application tag in menifest
android:theme="#style/Theme.AppCompat.Light.NoActionBar"

Android Percent Support Library Blank Screen on Actual Device

I tried using the Percent Support Library as detailed here and here. It works nicely in the Android Studio designer, but when I try to install my app into my phone, nothing is showing but an empty screen. What might the problem be?
Edit:
I've added the following lines in my gradle file dependencies.
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:support-v4:23.0.0'
compile 'com.android.support:design:23.0.0'
compile 'com.android.support:percent:23.0.0'
And here is my fragment layout:
<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:layout_width="match_parent"
android:layout_height="match_parent" tools:context="org.atpms.fairfare.ReportFragment"
android:id="#+id/fragment_report" >
<ProgressBar android:id="#+id/report_progress" style="?android:attr/progressBarStyleLarge"
android:layout_width="wrap_content" android:layout_height="match_parent"
android:layout_marginBottom="8dp" android:visibility="gone"
android:layout_centerHorizontal="true"
android:layout_centerVertical="true" />
<RelativeLayout
android:id="#+id/report_form"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="#+id/reportButton"
android:gravity="center">
<ImageView
android:id="#+id/report_background"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:src="#drawable/report"
android:adjustViewBounds="true" />
<android.support.percent.PercentRelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignTop="#+id/report_background"
android:layout_alignBottom="#+id/report_background"
android:layout_alignLeft="#+id/report_background"
android:layout_alignStart="#+id/report_background"
android:layout_alignRight="#+id/report_background"
android:layout_alignEnd="#+id/report_background">
<EditText
android:id="#+id/plateNumberField"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_widthPercent="58%"
app:layout_heightPercent="14%"
app:layout_marginTopPercent="20%"
app:layout_marginLeftPercent="36%"
android:textColor="#color/plate_number"
android:background="#null"
android:gravity="center"
android:textSize="24sp"
tools:ignore="TextFields"/>
<ImageView
android:id="#+id/meterPictureButton"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_widthPercent="12%"
app:layout_heightPercent="15.5%"
app:layout_marginTopPercent="38%"
app:layout_marginLeftPercent="84%"
android:src="#drawable/camera" />
<ImageView
android:id="#+id/meterPicture"
android:layout_width="0dp"
android:layout_height="0dp"
app:layout_widthPercent="97.2%"
app:layout_heightPercent="42%"
app:layout_marginTopPercent="55.8%"
app:layout_marginLeftPercent="1.6%"
android:scaleType="fitXY"
tools:ignore="ContentDescription" />
</android.support.percent.PercentRelativeLayout>
</RelativeLayout>
<Button
android:id="#+id/reportButton"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="#string/report"
android:layout_alignParentBottom="true"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_marginLeft="30dp"
android:layout_marginRight="30dp"
android:background="#drawable/report_button"
android:textSize="20sp"
android:paddingTop="8dp"
android:paddingBottom="8dp"
android:textColor="#color/button_text"
android:textAllCaps="false"
android:gravity="center"
tools:ignore="UnusedAttribute" />
</RelativeLayout>
</RelativeLayout>
Update:
Ok, I've inflated the exact same layout from an Activity using setContentView, and it works fine. It seems that the problem only arises when I try to use the PercentRelativeLayout in a Fragment layout. It appears that LayoutInflater isn't correctly inflating a layout with PercentRelativeLayout elements, but I'm still unsure and continuing to investigate.
It's not a very nice solution, but I solved this problem by just getting rid of the fragment, and making it a full-blown activity.

Categories

Resources