Im my app I want to use this NumberPicker:
https://github.com/SimonVT/android-numberpicker
I've copied the .jar file from this project, build the path in Eclipse, and imported it at my MainActivity class.
My xml file has the following code:
<net.simonvt.widget.NumberPicker
android:id="#+id/numberPicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
But I am getting this error at LogCat:
11-21 15:12:41.486: E/AndroidRuntime(6315): java.lang.RuntimeException: Unable to start activity ComponentInfo{xxxxxxxx.MainActivity}: android.view.InflateException: Binary XML file line #138: Error inflating class net.simonvt.widget.NumberPicker
11-21 15:12:41.486: E/AndroidRuntime(6315): Caused by: android.view.InflateException: Binary XML file line #138: Error inflating class net.simonvt.widget.NumberPicker
11-21 15:12:41.486: E/AndroidRuntime(6315): at net.simonvt.widget.NumberPicker.<init>(NumberPicker.java:532)
What is happening?
Thank you!
You have to add your lib form java build path. just right click the properties and then find java build path to add your jar.
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:custom="http://schemas.android.com/apk/res/net.simonvt.widget.NumberPicker"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical" >
<net.simonvt.widget.NumberPicker
android:id="#+id/numberPicker"
android:layout_width="wrap_content"
android:layout_height="wrap_content" />
</LinearLayout
Try this.
Related
After migration to AndroidX my app crashes after calling Snackbar.make() method. The error looks like
Caused by: android.view.InflateException: Binary XML file line #2: Error inflating class android.support.design.internal.SnackbarContentLayout
Caused by: java.lang.ClassNotFoundException: Didn't find class "android.support.design.internal.SnackbarContentLayout"
It's strange that internal Snackbar method make() is still trying to access SnackbarContentLayout class in old support package instead new material's one. Please advice what I'm doing wrong.
UPDATE
Finally I found a solution. There is a custom layout in my project which overrides
Snackbar's design_layout_snackbar_include and it had wrong class in root view tag:
<view
xmlns:android="http://schemas.android.com/apk/res/android"
class="android.support.design.internal.SnackbarContentLayout"
android:theme="#style/ThemeOverlay.AppCompat.Dark"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
I changed it to com.google.android.material.snackbar.SnackbarContentLayout
ensure that your project is set up to migrate old packages to Androidx by including this in your gradle.properties file:
android.useAndroidX=true
android.enableJetifier=true
Im trying to use an Android component I found on Github. Using the sample project inside the repository I integrated the component into my app but everytime I run it I get the error: android.view.InflateException: Binary XML file line #8: Error inflating class com.yalantis.flip.sample.views.FontTextView. This FontTextView has been used in the sample project which runs just fine. Im not sure what im doing wrong as I have also copied and pasted their layouts. I thought my images were the problem but I used the original pictures used in the sample application and it still crashed.
Here is the text from my logcat:
`android.view.InflateException: Binary XML file line #8: Error inflating class com.yalantis.flip.sample.views.FontTextView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:764)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:813)
at android.view.LayoutInflater.inflate(LayoutInflater.java:511)
at android.view.LayoutInflater.inflate(LayoutInflater.java:415)
at cc.tungait.voiture.activities.MainActivity$CarsAdapter.getPage(MainActivity.java:117)
at com.yalantis.flipviewpager.adapter.BaseFlipAdapter$MergeAdapter.getView(BaseFlipAdapter.java:124)
at com.yalantis.flipviewpager.view.FlipViewPager.setAdapter(FlipViewPager.java:468)
at com.yalantis.flipviewpager.adapter.BaseFlipAdapter.getView(BaseFlipAdapter.java:72)`
The XML is exactly what's in the sample project:
`
<com.yalantis.flip.sample.views.FontTextView
style="#style/TextView.Nickname"
android:id="#+id/nickname" />
<LinearLayout
android:layout_below="#+id/nickname"
android:id="#+id/interestsPrimary"
style="#style/LinearLayout.Interests">
<com.yalantis.flip.sample.views.FontTextView
style="#style/TextView.Interest"
android:id="#+id/interest_1" />
<com.yalantis.flip.sample.views.FontTextView
style="#style/TextView.Interest"
android:id="#+id/interest_2" />
<com.yalantis.flip.sample.views.FontTextView
style="#style/TextView.Interest"
android:id="#+id/interest_3" />
</LinearLayout>
<LinearLayout
android:layout_below="#+id/interestsPrimary"
android:id="#+id/interestsSecondary"
android:layout_marginTop="5dp"
style="#style/LinearLayout.Interests">
<com.yalantis.flip.sample.views.FontTextView
android:id="#+id/interest_4"
style="#style/TextView.Interest" />
<com.yalantis.flip.sample.views.FontTextView
android:id="#+id/interest_5"
style="#style/TextView.Interest" />
</LinearLayout>
`
You have to change the package name of your FontTextView in your XML like package_name.FontTextView.
Like below
<LinearLayout
android:layout_below="#+id/interestsPrimary"
android:id="#+id/interestsSecondary"
android:layout_marginTop="5dp"
style="#style/LinearLayout.Interests">
<package_name.FontTextView
android:id="#+id/interest_4"
style="#style/TextView.Interest" />
<package_name.FontTextView
android:id="#+id/interest_5"
style="#style/TextView.Interest" />
You have to match the same package name as in your Project.
Try it and let me know if it worked for you
I am creating an app in VS 2015 using Xamarin and when running it I get this error
Android.Views.InflateException: Binary XML file line #1: Error inflating class android.widget.RelativeLayout
This is my 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"
android:background="#drawable/food" />
I have the Food.jpg in the drawable folder as it shows up in VS when I select design.
Thanks
I'm trying to use TextInputLayout in my XML, and I'm meeting this error :
java.lang.RuntimeException: Unable to start activity ComponentInfo{fr.jechange.moncompte/fr.jechange.moncompte.SignUpActivity}: android.view.InflateException: Binary XML file line #36: Error inflating class android.support.design.widget.TextInputLayout
[...]
Caused by: android.view.InflateException: Binary XML file line #36: Error inflating class android.support.design.widget.TextInputLayout
[...]
Caused by: java.lang.NoClassDefFoundError: Failed resolution of: Landroid/support/design/R$styleable;
I've imported the design library, and the support-v7-appcompat library. And I'm using the Theme.AppCompat.Light.NoActionBar theme.
The XML in which I'm using the Text Input Layout contains just something like that:
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:res="http://schemas.android.com/apk/res-auto"
style="#style/matchParent">
<android.support.design.widget.TextInputLayout
android:id="#+id/input"
android:layout_width="match_parent"
android:layout_height="wrap_content">
<EditText
android:inputType="text"
android:layout_width="match_parent"
android:layout_height="wrap_content" />
</android.support.design.widget.TextInputLayout>
</RelativeLayout>
if you are calling layout(containg TextInputLayout) from activity then
nothing just use YouActivityClassName.this in place of getApplicationcontext or YourApplicationClassName.getcontext() or other where you are passing context
I had the same issue fixed here.
Make sure you don't have any other support library import v4 and v7. You can use only the design-support library. Also you should make sure your theme "matchParent" inherit from Theme.AppCompat for all the platform you trying to run.
My issue was only on Lollipop because of the values-21/style.xml.
Hope it will help.
I have added the library to my project.
Then in XML file I am trying to add the HorizontalListView as the following
<com.devsmart.android.ui.HorizontialListView
android:id="#+id/horizontalList"
android:layout_width="284dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_marginTop="10dp"
android:background="#ddd" />
But it gives the following Exception
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.golfer/com.golfer.WeatherScreen}: android.view.InflateException: Binary XML file line #256: Error inflating class com.devsmart.android.ui.HorizontialListView
Caused by: android.view.InflateException: Binary XML file line #256: Error inflating class com.devsmart.android.ui.HorizontialListView
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.devsmart.android.ui.HorizontialListView" on path: DexPathList[[zip file "/data/app/com.golfer-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.golfer-1, /vendor/lib, /system/lib]]
I have followed the instructions on this site
Any one having any idea about it? Any help?
Replace com.devsmart.android.ui.HorizontialListView by the name of your package +name of the class.
Something like this: com.example.android.MyHorizontalView where com.example.android is the name of your package and MyHorizontalView is the name of the class (that you created).
EDIT
From this post and android developer, you are probably missing a line to declare the namespace of the view. Try adding a line like this one
xmlns:widget="http://schemas.android.com/apk/res/com.mypackage"
In the parent layout (below the line xmlns:android="http://schemas.android.com/apk/res/android")
You can try it the following way,
Add devsmartlib.jar to the libs folder.
Then go to Java Build Path - > Libraries and Add JAR devsmartlib.jar to the project.
Did you add the Lib to your Dependencies? If not, add it!
Edit
Eclipse:
Right-Click on Project-> Build Path-> Configure Build Path-> Libraries-> Check if lib is in there, if not -> add Library.....