Resources$NotFoundException: Resource ID - android

I am trying to figure this issue but I don't understand why my Vector/png drawable is missing when I put them all in respective directory/folder.
Here is the below logs.
Fatal Exception: android.view.InflateException: Binary XML file line #42 in com.ex.abc:layout/my_layout: Binary XML file line #42 in com.ex.abc:layout/my_layout: Error inflating class <unknown>
Caused by android.content.res.Resources$NotFoundException: Resource ID #0x7f0800aa
at android.content.res.ResourcesImpl.getValue(ResourcesImpl.java:295)
at android.content.res.Resources.getValue(Resources.java:1516)
at androidx.appcompat.widget.ResourceManagerInternal.c(ResourceManagerInternal.java:19)
at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:235)
at androidx.appcompat.widget.ResourceManagerInternal.getDrawable(ResourceManagerInternal.java:2)
at androidx.appcompat.content.res.AppCompatResources.getDrawable(AppCompatResources.java:4)
at com.google.android.material.resources.MaterialResources.getDrawable(MaterialResources.java:13)
at com.google.android.material.button.MaterialButton.<init>(MaterialButton.java:87)
at java.lang.reflect.Constructor.newInstance0(Constructor.java)
at java.lang.reflect.Constructor.newInstance(Constructor.java:343)
at android.view.LayoutInflater.createView(LayoutInflater.java:873)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1061)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:1016)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1178)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1139)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1181)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1139)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:1181)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:1139)
at android.view.LayoutInflater.inflate(LayoutInflater.java:696)
at android.view.LayoutInflater.inflate(LayoutInflater.java:548)
at com.ex.abc.databinding.MyLayoutBinding.a(MyLayoutBinding.java:4)
at com.ex.abc.fragments.BSDialog.Q(BSDialog.java:6)
at androidx.fragment.app.Fragment.b0(Fragment.java:20)
at androidx.fragment.app.DialogFragment.performCreateView(DialogFragment.java)
at androidx.fragment.app.FragmentStateManager.createView(FragmentStateManager.java:223)
at androidx.fragment.app.FragmentStateManager.moveToExpectedState(FragmentStateManager.java:154)
at androidx.fragment.app.FragmentManager.executeOpsTogether(FragmentManager.java:1069)
at androidx.fragment.app.FragmentManager.removeRedundantOperationsAndExecute(FragmentManager.java:91)
at androidx.fragment.app.FragmentManager.execPendingActions(FragmentManager.java:74)
at androidx.fragment.app.FragmentManager$5.run(FragmentManager.java:3)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:257)
at android.app.ActivityThread.main(ActivityThread.java:8218)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:626)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1015)
Here is my layout file snippet code and at line 49 its drawable
<?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:id="#+id/messageBehaviorView"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:padding="16dp"
app:behavior_hideable="true"
app:behavior_peekHeight="0dp">
<HorizontalScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp">
<LinearLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="5dp"
android:orientation="horizontal">
<FrameLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="0dp"
android:layout_marginEnd="10dp"
android:background="#afafaf">
<Spinner
android:id="#+id/spColorStyle"
style="#style/spinner"
android:contentDescription="#string/style" />
</FrameLayout>
<com.google.android.material.button.MaterialButton
android:id="#+id/btnAngle"
style="#style/ButtonStyle.Circle.Small"
android:layout_marginStart="0dp"
android:layout_marginEnd="10dp"
android:contentDescription="#string/rotate"
app:icon="#drawable/ic_arrow_angle" />
</LinearLayout>
</HorizontalScrollView>
My Vector code
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24"
android:viewportHeight="24"
android:tint="#FFFFFF">
<path
android:fillColor="#android:color/white"
android:pathData="M12,20c-4.41,0 -8,-3.59 -8,-8s3.59,-8 8,-8s8,3.59 8,8S16.41,20 12,20M12,22c5.52,0 10,-4.48 10,-10c0,-5.52 -4.48,-10 -10,-10C6.48,2 2,6.48 2,12C2,17.52 6.48,22 12,22L12,22zM11,12l0,4h2l0,-4h3l-4,-4l-4,4H11z"/>
</vector>
I don't understand some android devices not able to use this resource and cause issue. My crashlytics error log for last 30 days.

Related

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

Floating Action Button forcing image to bottom right corner instead of center

I am using the Floating Action Button with an image and after a recent Android Studio update, the image is no longer centered and sits in the bottom right corner
I never changed any of the code regarding the image nor the button, but am curious as to how I can get this to be centered again.
Here is what I have for my button:
<android.support.design.widget.FloatingActionButton
android:id="#+id/expandButton"
android:layout_width="44dp"
android:layout_height="44dp"
android:layout_alignParentEnd="true"
android:layout_below="#id/imageFrame"
android:layout_marginBottom="-22dp"
android:layout_marginEnd="#dimen/item_margin"
android:layout_marginTop="-22dp"
android:background="#color/orange"
app:backgroundTint="#color/orange"
app:borderWidth="0dp"
app:srcCompat="#drawable/ic_expand" />
And here is the image:
<?xml version="1.0" encoding="utf-8"?>
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="512dp"
android:height="512dp"
android:viewportWidth="512"
android:viewportHeight="512">
<path
android:fillColor="#color/white"
android:pathData="M64.9 127c-14.9-14.9-39.1-14.9-54 0s-14.9 39.1 0 54l218 218c14.9 14.9 39.1 14.9 54 0l218-218c14.9-14.9 14.9-39.1 0-54-14.9-14.9-39.1-14.9-54 0l-191 191.2L64.9 127z" />
</vector>
As I states, I never changed anything with these two parts and now all of the sudden the image is forced to the bottom right. How can I get the image to center on the button?
I have tried your code. What I did was changed few attributes.
For FloatingActionButton.
try changing this
android:layout_width="44dp"
android:layout_height="44dp"
to this
android:layout_width="wrap_content"
android:layout_height="wrap_content"
For ic_expand
Change this
android:viewportWidth="512"
android:viewportHeight="512"
to this
android:viewportWidth="24.0"
android:viewportHeight="24.0"
Let me know if this works.
[EDIT] This is my code.
activity_main.xml
<?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"
tools:context=".MainActivity"
android:gravity="center">
<android.support.design.widget.FloatingActionButton
android:id="#+id/expandButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="-22dp"
android:layout_marginBottom="-22dp"
app:borderWidth="0dp"
app:srcCompat="#drawable/ic_expand_more_black_24dp" />
</RelativeLayout>
ic_expand_more_black_24dp.xml
<vector
android:height="512dp"
android:viewportHeight="24"
android:viewportWidth="24"
android:width="512dp"
xmlns:android="http://schemas.android.com/apk/res/android">
<path android:fillColor="#FF000000"
android:pathData="M16.59,8.59L12,13.17 7.41,8.59 6,10l6,6 6,-6z"/>
</vector>
Here is image
set
android:layout_width="wrap_content"
android:layout_height="wrap_content"
Please try below code :
<android.support.design.widget.FloatingActionButton
android:id="#+id/expandButton"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="#dimen/fab_margin"
app:srcCompat="#drawable/ic_expand"
app:backgroundTint="#color/orange"/>
I hope its work for you.

Fatal Error: You must supply a layout_width attribute

I'm very very new to android programming and while trying to run this simple program I get the error: "Unfortunately your app stopped".
So I went and looked in the Logcat file and this is where, I think, the problem is:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: org.example.tictactoe, PID: 3202
java.lang.RuntimeException: Unable to start activity ComponentInfo{org.example.tictactoe/org.example.tictactoe.MainActivity}: java.lang.RuntimeException: Binary XML file line #2: You must supply a layout_width attribute.
But looking at my files I don't see where It's missing.
This are the files .xml which I used:
activity_main.xml:
<FrameLayout
xmlns:android="http://schemas.android.com/apk/lib/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:clipChildren="false"
tools:context=".TicTacToeActivity">
<fragment
android:id="#+id/main_fragment"
android:name="org.example.tictactoe.MainFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
tools:layout="#layout/fragment_main"/>
</FrameLayout>
fragment_main.xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/lib/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="#drawable/menu_background"
android:elevation="#dimen/elevation_high"
android:orientation="vertical"
android:padding="#dimen/menu_padding"
tools:context=".TicTacToeActivity">
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="#dimen/menu_space"
android:text="#string/long_app_name"
android:textAppearance="?android:textAppearanceLarge"
android:textSize="#dimen/menu_text_size"
/>
<Button
android:id="#+id/continue_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_margin="#dimen/menu_button_margin"
android:padding="#dimen/menu_button_padding"
android:text="#string/continue_label"
/>
<Button
android:id="#+id/new_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="#dimen/menu_button_margin"
android:padding="#dimen/menu_button_padding"
android:text="#string/new_game_label"
/>
<Button
android:id="#+id/about_button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="#dimen/menu_button_margin"
android:padding="#dimen/menu_button_padding"
android:text="#string/about_label"
/>
</LinearLayout>
menu_background:
<shape
xmlns:android="http://schemas.android.com/apk/lib/android"
android:shape="rectangle">
<stroke
android:width="#dimen/stroke_width"
android:color="#color/border_color"/>
<solid android:color="#color/field_color"/>
<corners android:radius="#dimen/corner_radius"/>
</shape>
I cannot find where the layout_width attribute is missing.
There are blank spaces in your layout. For example, in fragment_main.xml:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/lib/android "
xmlns:tools="http://schemas.android.com/tools "
Use Find and Replace for " or in your layout.
UPDATE
You have another error in the following xml:
You can't use class="org.example.tictactoe.MainFragment". But you need to use android:name attribute. So, it should be:
<fragment
android:id="#+id/main_fragment"
android:name="org.example.tictactoe.MainFragment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center"
tools:layout="#layout/fragment_main"/>
Found another problem in your xml code. Use xmlns:android="http://schemas.android.com/apk/res/android" instead of xmlns:android="http://schemas.android.com/apk/lib/android".
You have a space in "wrap_content " for layout_width and layout_height in MainFragment.
Remove android:layout_gravity="#layout/fragment_main" from activity_main.xml
android:layout_gravity requires specific parameters android:layout_gravity Reference Link
Fragments reference

Is that right to make android.view.InflateException by using Vector drawables in android:background: line in a ImageView

I am facing android.view.InflateException in my app for some particular devices, in others phone it works fine. But i don't know why. Many others says that this problem occurs for drawable vector image. I am using vector image in android:background= "" line. is that make this InflateException.
<RelativeLayout
android:id="#+id/nameLayoutMain"
android:layout_width="wrap_content"
android:layout_height="120dp"
android:background="#drawable/shadow_164949">
<ImageView
android:layout_width="80dp"
android:layout_height="400dp"
android:background="#drawable/draw_phone"
android:id="#+id/im1"
android:layout_alignParentTop="true" />
<ImageView
android:layout_width="80dp"
android:layout_height="50dp"
app:srcCompat="#drawable/ic_phone"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_toLeftOf="#+id/linearLayoutName"
android:layout_toStartOf="#+id/linearLayoutName" />
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:id="#+id/linearLayoutName"
android:gravity="center_vertical"
android:layout_alignBottom="#+id/im1"
android:layout_toRightOf="#+id/im1"
android:layout_toEndOf="#+id/im1">
<TextView
android:id="#+id/txtPhoneShow"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/my_phone_number"
android:textSize="18sp"
android:layout_alignParentTop="true"
android:layout_alignLeft="#+id/txtPhone"
android:layout_alignStart="#+id/txtPhone" />
<TextView
android:id="#+id/txtPhone"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="01612548792"
android:textColor="#color/toolbar1"
android:textSize="20sp"
android:textStyle="bold"
android:layout_below="#+id/txtPhoneShow"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginLeft="20dp"
android:layout_marginStart="20dp" />
</RelativeLayout>
</RelativeLayout>
Make sure you have added vectorDrawables.useSupportLibrary = true inside defaultConfig in app/build.gradle.
Like
defaultConfig {
vectorDrawables.useSupportLibrary = true
....
}
EDIT 1
In order to support vector in API less then 21. Also add this in onCreate method of Activity before setContentView.
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
Use color code replace of color name from color.xml in your drawable vector xml like below;
<vector xmlns:android="http://schemas.android.com/apk/res/android"
android:width="24dp"
android:height="24dp"
android:viewportWidth="24.0"
android:viewportHeight="24.0">
<path
android:fillColor="#4396e6"
android:pathData="M21,19V5c0,-1.1 -0.9,-2 -2,-2H5c-1.1,0 -2,0.9 -2,2v14c0,1.1 0.9,2 2,2h14c1.1,0 2,-0.9 2,-2zM8.5,13.5l2.5,3.01L14.5,12l4.5,6H5l3.5,-4.5z"/>

Error inflating layout DSLV library

When I am launching my application, I am getting the error:
04-29 10:20:15.655: E/AndroidRuntime(24548): android.view.InflateException: Binary XML file line #2: Error inflating class com.mobeta.android.dslv.DragSortListView
Here is my XML file:
<?xml version="1.0" encoding="utf-8"?>
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:dslv="http://schemas.android.com/apk/res-auto"
android:id="#android:id/list"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:paddingTop="7dp"
android:paddingBottom="0dp"
android:paddingLeft="0dp"
android:layout_margin="0dp"
android:dividerHeight="5dp"
dslv:drag_enabled="true"
dslv:collapsed_height="2dp"
dslv:drag_scroll_start="0.33"
dslv:max_drag_scroll_speed="0.5"
dslv:float_alpha="0.6"
dslv:slide_shuffle_speed="0.3"
dslv:track_drag_sort="false"
dslv:use_default_controller="true"
dslv:sort_enabled="false"
dslv:remove_enabled="true"
dslv:remove_mode="flingRemove"
android:background="#E5E5E5" />
Does anyone know whats causing the issue? When I attempt to specify the full url "http://schemas.android.com/apk/res/com.mobeta.android.demodslv", the project does not compile.
change xmlns:dslv="http://schemas.android.com/apk/res-auto"
to below line
xmlns:dslv="http://schemas.android.com/apk/lib/com.mobeta.android.dslv"

Categories

Resources