Error inflating class TextInputEditText - android

I'm trying to use TextInputEditText in my XML, and I'm meeting this error :
Caused by: android.view.InflateException: Binary XML file line #15:
Error inflating class android.support.design.widget.TextInputEditText
Caused by: java.lang.ClassNotFoundException: Didn't find class
"android.support.design.widget.TextInputEditText" on path:
DexPathList[[zip file "/data/app/thanhnguyen.com.familysharinglocation-
1/base.apk"],nativeLibraryDirectories=
[/data/app/thanhnguyen.com.familysharinglocation-1/lib/arm64,
/system/lib64, /vendor/lib64]]
Here my xml :
<android.support.design.widget.TextInputLayout
android:id="#+id/fullName"
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<android.support.design.widget.TextInputEditText
android:hint="#string/fullName"
android:inputType="textCapWords"
android:layout_width="match_parent"
android:layout_height="wrap_content"/>
</android.support.design.widget.TextInputLayout>
My dependency :
compile 'com.android.support:design:23.0.1'
compile 'com.android.support:appcompat-v7:23.0.1'

You need to using the support library version which is >= 24.1.0 because TextInputEditText is added in version 24.1.0. Read more at TextInputEditText
So, you can use the following:
compile 'com.android.support:design:25.3.1'

Make sure you have added support design dependency first in build.gradle
Copy this TextInputLayout in your xml
<android.support.design.widget.TextInputLayout
android:id="#+id/userPhoneNumber"
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_marginTop="20dp"
android:clipToPadding="false"
android:gravity="bottom"
android:paddingTop="4dp"
android:textColorHint="#color/whiteTextColor"
>
<EditText
android:layout_width="match_parent"
android:layout_height="50dp"
android:layout_gravity="bottom"
android:background="#color/silveryBackground"
android:hint="#string/enterMobileNumber"
android:inputType="number"
android:maxLength="10"
android:paddingLeft="17dp"
android:paddingRight="17dp"
android:paddingTop="10dp"
android:singleLine="true"
android:textColor="#color/textColor"
android:textColorHint="#color/whiteTextColor"/>
</android.support.design.widget.TextInputLayout>

Related

Error inflating class com.google.android.material.appbar.AppBarLayout with AppCompat/Material theme

I don't really know what exactly I am missing but I am getting the same inflate exception error even with an Appcomat theme.
logcat:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.aasha/com.example.aasha.MainActivity}: android.view.InflateException: Binary XML file line #23: Binary XML file line #23: Error inflating class com.google.android.material.appbar.AppBarLayout
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3139)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3282)
at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78)
at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108)
at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1970)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:214)
at android.app.ActivityThread.main(ActivityThread.java:7156)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:494)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:975)
Caused by: android.view.InflateException: Binary XML file line #23: Binary XML file line #23: Error inflating class com.google.android.material.appbar.AppBarLayout
Caused by: android.view.InflateException: Binary XML file line #23: Error inflating class com.google.android.material.appbar.AppBarLayout
layout:
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:tools="http://schemas.android.com/tools"
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto">
<androidx.constraintlayout.widget.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#drawable/chat_good_things">
<androidx.coordinatorlayout.widget.CoordinatorLayout
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:orientation="vertical"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintBottom_toTopOf="#id/message_box">
<com.google.android.material.appbar.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<androidx.appcompat.widget.Toolbar
android:id="#+id/toolbar"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#android:color/transparent"
app:layout_scrollFlags="scroll|enterAlways">
....
</androidx.appcompat.widget.Toolbar>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_behavior="#string/appbar_scrolling_view_behavior">
<androidx.recyclerview.widget.RecyclerView
android:id="#+id/chat_recycler_view"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:padding="10dp"
android:clipToPadding="false"
app:layout_anchor="#id/toolbar"
app:layout_anchorGravity="bottom"
android:layout_gravity="bottom"/>
</androidx.core.widget.NestedScrollView>
</androidx.coordinatorlayout.widget.CoordinatorLayout>
<LinearLayout
android:id="#+id/message_box"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal"
android:padding="10dp"
android:background="#android:color/black"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent" >
<ImageButton
android:id="#+id/image_send_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:srcCompat="#drawable/ic_image_add" />
<EditText
android:id="#+id/message_type_box"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:padding="10dp"
android:layout_weight="1"
android:layout_gravity="center"
android:focusableInTouchMode="true"
android:textIsSelectable="true"
android:hint="Type a message..."
android:inputType="text" />
<ImageButton
android:id="#+id/message_send_button"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
app:srcCompat="#drawable/ic_message_send"/>
</LinearLayout>
<ProgressBar
android:id="#+id/progress_bar"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:visibility="visible"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintBottom_toBottomOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</layout>
theme:
<style name="Theme.Aasha" parent="Theme.MaterialComponents.DayNight.NoActionBar">
<!-- Primary brand color. -->
<item name="colorPrimary">#color/purple_500</item>
<item name="colorPrimaryVariant">#color/purple_700</item>
<item name="colorOnPrimary">#color/white</item>
<!-- Secondary brand color. -->
<item name="colorSecondary">#color/teal_200</item>
<item name="colorSecondaryVariant">#color/teal_700</item>
<item name="colorOnSecondary">#color/black</item>
<!-- Status bar color. -->
<item name="android:statusBarColor" tools:targetApi="l">?attr/colorPrimaryVariant</item>
<!-- Customize your theme here. -->
</style>
gradle:
implementation 'com.google.android.material:material:1.4.0'
// androidx
implementation 'androidx.core:core-ktx:1.7.0'
implementation 'androidx.appcompat:appcompat:1.4.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.2'
implementation "androidx.recyclerview:recyclerview:1.2.1"
implementation "androidx.navigation:navigation-fragment-ktx:$navigation_version"
implementation "androidx.navigation:navigation-ui-ktx:$navigation_version"
implementation 'de.hdodenhof:circleimageview:3.1.0'
testImplementation 'junit:junit:4.+'
androidTestImplementation 'androidx.test.ext:junit:1.1.3'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.4.0'
}
I searched and came across this StackOverflow, tried all the solutions that include:
Invalidate Caches/Restart with no luck. Refactor -> Migrate to AndroidX that says No usages found for the project.
I was puzzled and made a separate project with the same single layout that run without any issues but I am unable to differentiate and find the fault here. Please help!
Don't forget to use Theme.MaterialComponents.Light.NoActionBar (or any Theme.MaterialComponents.*.NoActionBar really) as your parent AppTheme in style.xml
implementation 'com.google.android.material:material:1.0.0'
classpath 'com.android.tools.build:gradle:3.2.0'
change Gradle and material design to latest version
I was using SplashScreenApi which is from androidx.core.splashscreen.SplashScreen library.
I knew that I have to call installSplashScreen() before setContentView() in my MainAcitivty() but what I didn't know was that it should be called even before any viewBinding initialization. It went somehow unnoticed for days for someone inexperienced like me. The app was running smoothly and everything was working well until any material design tag implementation.
Before:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
binding = ActivityMainBinding.inflate(layoutInflater)
installSplashScreen()
setContentView(binding.root)
...
}
After:
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
installSplashScreen()
binding = ActivityMainBinding.inflate(layoutInflater)
setContentView(binding.root)
...
}
That was so stupid of me :(. It took me a while cause the logcat was always pointing the setContentView()

Error inflating class ImageButton Stops app from starting

My app fails to start because of Error inflating class ImageButton, Because of this the phone says "app has stopped" Etc.
I am using firebase test lab to debug the problem
the Errors occur on samsung devices specifically A20, s7 Edge , s7(tested with firebase same problem)
I am new to android and have tried many solutions from google and SO none have worked sofar
Here is the error report on firebase
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.smartpractice.smartpracticesmartapp/com.smartpractice.myapplication.MainActivity}: android.view.InflateException: Binary XML file line #117: Binary XML file line #117: Error inflating class ImageButton
FATAL EXCEPTION: main
Process: com.smartpractice.smartpracticesmartapp, PID: 26921
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.smartpractice.smartpracticesmartapp/com.smartpractice.myapplication.MainActivity}: android.view.InflateException: Binary XML file line #117: Binary XML file line #117: Error inflating class ImageButton
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3253)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3349)
at android.app.ActivityThread.access$1100(ActivityThread.java:221)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1794)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:7224)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1230)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1120)
Caused by: android.view.InflateException: Binary XML file line #117: Binary XML file line #117: Error inflating class ImageButton
at android.view.LayoutInflater.inflate(LayoutInflater.java:551)
at android.view.LayoutInflater.inflate(LayoutInflater.java:429)
at android.view.LayoutInflater.inflate(LayoutInflater.java:380)
at androidx.appcompat.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at androidx.appcompat.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.smartpractice.myapplication.MainActivity.onCreate(MainActivity.java:14)
at android.app.Activity.performCreate(Activity.java:6876)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1135)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3206)
... 9 more
Caused by: android.view.InflateException: Binary XML file line #117: Error inflating class ImageButton
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:794)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:716)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:847)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:855)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:810)
at android.view.LayoutInflater.inflate(LayoutInflater.java:527)
... 17 more
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f070089
at android.content.res.Resources.getValue(Resources.java:2558)
at androidx.appcompat.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:331)
at androidx.appcompat.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:198)
at androidx.appcompat.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:191)
at androidx.appcompat.content.res.AppCompatResources.getDrawable(AppCompatResources.java:102)
at androidx.appcompat.widget.AppCompatImageHelper.loadFromAttributes(AppCompatImageHelper.java:59)
at androidx.appcompat.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:79)
at androidx.appcompat.widget.AppCompatImageButton.<init>(AppCompatImageButton.java:69)
at androidx.appcompat.app.AppCompatViewInflater.createImageButton(AppCompatViewInflater.java:202)
at androidx.appcompat.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:122)
at androidx.appcompat.app.AppCompatDelegateImpl.createView(AppCompatDelegateImpl.java:1266)
at androidx.appcompat.app.AppCompatDelegateImpl.onCreateView(AppCompatDelegateImpl.java:1316)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:758)
Here is the 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"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/relativeLayout4"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/ic_launcher_background"
tools:context=".MainActivity">
<com.google.android.flexbox.FlexboxLayout
android:id="#+id/flexboxLayout"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
app:alignContent="stretch"
app:alignItems="stretch"
app:flexWrap="wrap"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.863"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="#+id/guideline7">
<TextView
android:id="#+id/textView"
android:layout_width="match_parent"
android:layout_height="48dp"
android:fontFamily="#font/nunito"
android:gravity="center_horizontal"
android:text="#string/welcome_to_smartpractice"
android:textSize="24sp"
app:fontFamily="#font/nunito"
app:layout_alignSelf="baseline"
tools:layout_editor_absoluteY="100dp"
tools:targetApi="jelly_bean" />
<TextView
android:id="#+id/textView7"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/colorPrimaryDark"
android:gravity="center_horizontal|fill_vertical"
android:text="#string/docsharesmart"
android:textColor="#color/ic_launcher_background"
app:layout_alignSelf="flex_end"
tools:layout_editor_absoluteY="16dp" />
</com.google.android.flexbox.FlexboxLayout>
<com.google.android.flexbox.FlexboxLayout
android:layout_width="0dp"
android:layout_height="0dp"
android:layout_marginStart="8dp"
android:layout_marginLeft="8dp"
android:layout_marginTop="4dp"
android:layout_marginEnd="8dp"
android:layout_marginRight="8dp"
android:layout_marginBottom="8dp"
app:alignContent="center"
app:alignItems="stretch"
app:flexDirection="row"
app:flexWrap="nowrap"
app:justifyContent="space_between"
app:layout_constraintBottom_toTopOf="#+id/guideline7"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
<ImageView
android:id="#+id/imageView3"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="#string/logo1"
app:layout_alignSelf="center"
app:srcCompat="#drawable/smartpractice_logo_02"
tools:layout_editor_absoluteX="0dp"
tools:layout_editor_absoluteY="-46dp" />
<ImageButton
android:id="#+id/LoginScreen"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#null"
android:contentDescription="#string/loginscreen"
app:layout_alignSelf="center"
app:layout_wrapBefore="false"
app:srcCompat="#drawable/ic_more_vert_black_24dp"
tools:layout_editor_absoluteX="248dp"
tools:layout_editor_absoluteY="134dp" />
</com.google.android.flexbox.FlexboxLayout>
<com.google.android.flexbox.FlexboxLayout
android:id="#+id/flexboxLayout2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="8dp"
android:layout_marginTop="8dp"
android:layout_marginEnd="8dp"
android:layout_marginBottom="8dp"
app:alignContent="stretch"
app:alignItems="stretch"
app:flexWrap="wrap"
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/flexboxLayout"
app:layout_constraintVertical_bias="0.146">
Here is line 117 from the error
<ImageButton
android:id="#+id/UploadButton"
android:layout_width="300dp"
android:layout_height="209dp"
android:background="#android:color/transparent"
app:layout_constraintTop_toBottomOf="#+id/flexboxLayout"
app:srcCompat="#drawable/upload_files_upload"
android:contentDescription="#string/todo" />
</com.google.android.flexbox.FlexboxLayout>
<androidx.constraintlayout.widget.Guideline
android:id="#+id/guideline7"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:orientation="horizontal"
app:layout_constraintGuide_begin="185dp" />
</androidx.constraintlayout.widget.ConstraintLayout>
It means upload_files_upload is not found in drawble folder, well this can be a case, where your file may present in drawable-24 but not in drawble folder, in that case this problem still arise. The point is your file must be in all drawble folder.
The reason for your error is that the upload_files_upload is not in your drawable folder :
<ImageButton
android:id="#+id/UploadButton"
android:layout_width="300dp"
android:layout_height="209dp"
android:background="#android:color/transparent"
app:layout_constraintTop_toBottomOf="#+id/flexboxLayout"
app:srcCompat="#drawable/upload_files_upload"// this line
android:contentDescription="#string/todo" />
I have solved The Issue I changed app:srcCompat="#drawable/upload_files_upload"// to android:src="#drawable/upload_files_upload"
So the problem was by app:srcCompat I changed it to Android:src and it works fine now

How to fix 'Error inflating class EditText' in Android XML Layout

I am getting following error for the line #30 i.e. first line of first EditText in the provided code. This XML is basically associated with an Activity. The error is while binding XML inside activity
setContentView(R.layout.activity_login)
The error is as follows:
Caused by android.view.InflateException: Binary XML file line #30: Binary XML file line #30: Error inflating class EditText
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImpl.setContentView(AppCompatDelegateImpl.java:469)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:140)
at com.pockethcm.greytrix.test.LoginActivity.onCreate(LoginActivity.kt:39)
at android.app.Activity.performCreate(Activity.java:6268)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1110)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2370)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2477)
at android.app.ActivityThread.-wrap11(ActivityThread.java)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1345)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:148)
at android.app.ActivityThread.main(ActivityThread.java:5468)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:781)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:671)
I have tried couple of things explained in other answers but none of them actually helped me. I am not using any drawable resource for that EditText.
<?xml version="1.0" encoding="utf-8"?>
<ScrollView
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:background="#drawable/login_bg"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.pockethcm.greytrix.test.LoginActivity"
>
<LinearLayout
android:layout_gravity="center_vertical"
android:gravity="center_vertical"
android:paddingStart="#dimen/_20sdp"
android:paddingEnd="#dimen/_20sdp"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:id="#+id/login_layout">
<de.hdodenhof.circleimageview.CircleImageView
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="#+id/profile_image"
android:layout_width="match_parent"
android:layout_height="96dp"
android:src="#drawable/pocketlogosplash"
app:civ_border_width="2dp"
app:civ_circle_background_color="#color/colorWhite"
app:civ_border_color="#bcbcbc"/>
<EditText
android:layout_width="match_parent"
android:backgroundTint="#color/colorWhite"
android:layout_height="wrap_content"
android:hint="Company Code"
android:textColorHint="#color/colorWhite"
android:layout_marginTop="20dp"
android:drawableStart="#drawable/ic_store_white_24dp"
android:drawablePadding="10dp"
android:textColor="#color/colorWhite"
android:id="#+id/company_code"
android:imeOptions="actionNext"
android:maxLines="1"
android:singleLine="true"/>
<EditText
android:layout_width="match_parent"
android:backgroundTint="#color/colorWhite"
android:layout_height="wrap_content"
android:hint="Employee Code"
android:textColorHint="#color/colorWhite"
android:layout_marginTop="20dp"
android:drawableStart="#drawable/ic_person_black_24dp"
android:drawablePadding="10dp"
android:textColor="#color/colorWhite"
android:id="#+id/employee_code"
android:drawableTint="#color/colorWhite"
android:imeOptions="actionNext"
android:maxLines="1"
android:singleLine="true"/>
</LinearLayout>
</ScrollView>
EditText widget should load normally but the activity is crashing with error above.
Providing additional info:
compileSdkVersion 28
minSdkVersion 21
targetSdkVersion 28
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.3.31"
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
You should set left drawable programmatically if its vector for pre kitkat.
company_code.setCompoundDrawablesWithIntrinsicBounds(AppCompatResources.getDrawable(this,R.drawable.ic_store_white_24dp), null, null, null);```
Which android version you are using, I think you use Vector Drawable in EditText, But Vector Drawable support after KitKat.

Android Studio Facebook SDK - Error inflating class com.facebook.login.widget.LoginButton

Hi to all i'm trying to add the facebook login avaible in the facebook sdk (i'm using the 4.16.0 ver) but i got this error
android.view.InflateException: Binary XML file line #0: Binary XML
file line #0: Error inflating class
com.facebook.login.widget.LoginButton
Caused by: android.view.InflateException: Binary XML file line #0:
Error inflating class com.facebook.login.widget.LoginButton
i'm already read here but it did not work for me i post here my build.gradle file
Thank's to all!
<?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"
xmlns:tools="http://schemas.android.com/tools"
android:id="#+id/layoutLogin"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#color/cardview_light_background"
android:orientation="vertical">
<ImageView
android:id="#+id/imageView4"
android:layout_width="match_parent"
android:layout_height="456dp"
android:contentDescription="imm"
android:src="#drawable/lloyd_thumbs" />
<Space
android:layout_width="match_parent"
android:layout_height="25dp" />
<Button
android:id="#+id/log_or_reg"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="#color/cardview_shadow_end_color"
android:text="Loggati e/o Registrati" />
<com.facebook.login.widget.LoginButton
android:id="#+id/login_button"
android:layout_width="344dp"
android:layout_height="54dp"
android:layout_gravity="center_horizontal"
android:layout_marginBottom="30dp"
android:layout_marginTop="30dp" />
</LinearLayout>
edit: the problem is only when I try to inflate the activity, if I use intent I don't have any problem
This is probably because you haven't initialised the Facebook SDK.
Initiate that in the application class as below.
public class AppController extends Application {
#Override
public void onCreate() {
super.onCreate();
FacebookSdk.sdkInitialize(this);
}
}
If you have the same problem, try this.
in your buil.gradle file add this
compile 'com.android.support:multidex:1.0.0'
and add in default config this
default config{
//other stuff
multiDexEnabled true
//other stuff
}
and in yuor application add this MultiDex.install(this);
Thank's myself for answer!

Error inflating class AppCompatButton due to a missing attribute in TypedArray

I have two v4 Fragments in one v7 AppCompatActivity. One fragmet has AppCompatImageButton, the other AppCompatButton. The first one inflates just fine, the other fails with a cryptic error
android.view.InflateException: Binary XML file line #70: Binary XML file line #70: Error inflating class android.support.v7.widget.AppCompatButton
caused by java.lang.UnsupportedOperationException: Failed to resolve attribute at index 5: TypedValue. Both fragments are inflated from the same activity and use the same theme. The only difference is that one button is AppCompatImageButton with just an icon, the other AppCompatButton with an icon and text.
The XML file line #70 is the line where AppCompatButton is defined.
I guess the problem is due to a missing attribute in the Theme, the one at index 5, but how do I find what's at index 5? I tried adding/removing android:tint and android:background, it made no difference.
Here is the relevant piece of the trace:
android.view.InflateException: Binary XML file line #70: Binary XML file line #70: Error inflating class android.support.v7.widget.AppCompatButton
at android.view.LayoutInflater.inflate(LayoutInflater.java:539)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at co.tinode.tindroid.TopicInfoFragment.onCreateView(TopicInfoFragment.java:42)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2192)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1299)
Caused by:
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 5: TypedValue{t=0x2/d=0x1010433 a=2 r=0x7f0d0029}
at android.content.res.TypedArray.getColorStateList(TypedArray.java:482)
at android.widget.TextView.<init>(TextView.java:1043)
at android.widget.Button.<init>(Button.java:109)
at android.widget.Button.<init>(Button.java:105)
at android.support.v7.widget.AppCompatButton.<init>(AppCompatButton.java:66)
at android.support.v7.widget.AppCompatButton.<init>(AppCompatButton.java:62)
at java.lang.reflect.Constructor.newInstance(Native Method) 
at android.view.LayoutInflater.createView(LayoutInflater.java:619) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764) 
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:704) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:835) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
at android.view.LayoutInflater.rInflate(LayoutInflater.java:838) 
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:798) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:515) 
at android.view.LayoutInflater.inflate(LayoutInflater.java:423) 
at co.tinode.tindroid.TopicInfoFragment.onCreateView(TopicInfoFragment.java:43) 
The code at TopicInfoFragment.java:43 is just
return inflater.inflate(R.layout.fragment_topic_info, container, false);
Here is the layout for the Fragment that fails (button on the bottom):
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
xmlns:tools="http://schemas.android.com/tools"
android:padding="#dimen/activity_padding"
android:orientation="vertical"
tools:context="co.tinode.tindroid.TopicInfoFragment">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="4dp">
<android.support.v7.widget.AppCompatImageView
android:id="#+id/imageAvatar"
android:layout_width="#dimen/avatar_size_large"
android:layout_height="#dimen/avatar_size_large"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginLeft="8sp"
android:layout_marginStart="8sp"
android:clickable="true"
android:contentDescription="#string/avatar"
android:src="#drawable/ic_group"/>
<TextView
android:id="#+id/topicTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/dialog_item_padding"
android:layout_toLeftOf="#id/imageAvatar"
android:layout_toStartOf="#id/imageAvatar"
android:maxLines="2"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textIsSelectable="true"/>
<TextView
android:id="#+id/topicSubtitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="#id/topicTitle"
android:layout_marginTop="#dimen/dialog_item_padding"
android:ellipsize="end"
android:maxLines="1"
android:textIsSelectable="true"/>
</RelativeLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dip"
android:layout_marginBottom="#dimen/activity_vertical_margin"
android:layout_marginTop="#dimen/activity_vertical_margin"
android:background="#66000000"/>
<TextView
android:id="#+id/membersTitle"
style="#style/sectionTitleStyle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="#dimen/dialog_item_padding"
android:text="#string/group_members"
/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
>
<!-- THIS BUTTON FAILS TO INFLATE -->
<android.support.v7.widget.AppCompatButton
android:id="#+id/buttonAddMember"
android:contentDescription="#string/add_member"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:drawableLeft="#drawable/ic_person_add"
android:drawableStart="#drawable/ic_person_add"
android:text="#string/add_member"
android:drawablePadding="4sp"
android:textColor="#color/colorText"
android:background="?attr/selectableItemBackgroundBorderless"
/>
</LinearLayout>
<ListView
android:id="#id/android:list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:fastScrollAlwaysVisible="true"
android:scrollbarStyle="outsideInset"
android:verticalScrollbarPosition="right"/>
</LinearLayout>
Here is the the layout which inflates just fine in the same activity:
<RelativeLayout
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"
android:background="#drawable/message_view_bkg"
tools:context="co.tinode.tindroid.MessagesFragment">
<android.support.v7.widget.RecyclerView
android:id="#+id/messages_container"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_above="#+id/sendMessagePanel"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:scrollbars="vertical"
app:stackFromEnd="true"
app:reverseLayout="false"/>
<LinearLayout
android:id="#+id/sendMessagePanel"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="4dp"
android:paddingLeft="6sp"
android:paddingStart="6sp"
android:orientation="horizontal"
android:background="#android:color/background_light">
<EditText
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:id="#+id/editMessage"
android:inputType="text"
android:hint="#string/new_message_hint"
android:imeOptions="actionSend"
android:layout_weight="1" />
<!-- This button inflates just fine -->
<android.support.v7.widget.AppCompatImageButton
android:id="#+id/chatSendButton"
android:layout_width="wrap_content"
android:layout_height="match_parent"
android:src="#drawable/ic_send"
android:contentDescription="#string/send_message_button_hint"
android:tint="#android:color/holo_blue_dark"
android:layout_weight="0.1"
android:paddingLeft="4sp"
android:paddingRight="8sp"
android:background="?attr/selectableItemBackgroundBorderless" />
</LinearLayout>
</RelativeLayout>
The theme is quite basic:
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="android:windowNoTitle">true</item>
<item name="windowActionBar">false</item>
<item name="windowActionModeOverlay">true</item>
</style>
Here is the gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion '25.0.0'
defaultConfig {
applicationId "co.tinode.tindroid"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(path: ':tinodesdk')
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:preference-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.googlecode.libphonenumber:libphonenumber:8.4.0'
compile 'com.google.firebase:firebase-messaging:9.6.1'
compile 'com.android.support:recyclerview-v7:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
OK, solved. The problem was with the android:textColor="#color/colorText".
colorText was defined as a reference <color name="colorText">?android:attr/colorPrimary</color>. Once I defined it explicitly, the problem went away.

Categories

Resources