android studio keeps stopping - Android Studio [closed] - android

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 1 year ago.
Improve this question
I'm getting an Application Has Stopped Error.
I'm just starting out so I don't know much about this.
I looked at other threads but couldn't find anything similar to my code can you help me?
Process: com.example.andromeda, PID: 5300
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.andromeda/com.example.andromeda.MainActivity}: android.view.InflateException: Binary XML file line #22: Binary XML file line #22: Error inflating class EditText
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2778)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2856)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1589)
at android.os.Handler.dispatchMessage(Handler.java:106)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6494)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
Caused by: android.view.InflateException: Binary XML file line #22: Binary XML file line #22: Error inflating class EditText
Caused by: android.view.InflateException: Binary XML file line #22: Error inflating class EditText
Caused by: java.lang.NumberFormatException: For input string: "AndroMeda"
at java.lang.Integer.parseInt(Integer.java:608)
at com.android.internal.util.XmlUtils.convertValueToInt(XmlUtils.java:133)
at android.content.res.TypedArray.getInt(TypedArray.java:375)
at android.widget.TextView.<init>(TextView.java:1265)
at android.widget.EditText.<init>(EditText.java:88)
at android.widget.EditText.<init>(EditText.java:84)
at androidx.appcompat.widget.AppCompatEditText.<init>(AppCompatEditText.java:93)
when the application was run, it gave an error and these red texts appeared, I did not know what to do because I did not understand By the way This is my main activity.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"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
tools:context=".MainActivity">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal">
<TextView
android:id="#+id/textView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="#string/ad" />
<EditText
android:id="#+id/editTextTextPersonName"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:ems="10"
android:hint="#string/soyad"
android:inputType="#string/app_name"
android:text="#string/soyad" />
</LinearLayout>
I think these are the required files

Either remove android:inputType="#string/app_name" or set it to a valid value, such as text. AndroMeda (the apparent value of #string/app_name) is not a valid value for inputType.

replace android:inputType="#string/app_name"
with
android:inputType="text"

Related

Fragment testing error: android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class <unknown>

I am trying to test a fragment, following these instructions: https://developer.android.com/training/basics/fragments/testing
However I am getting the following crash when calling launchFragmentInContainer from my test.
Stacktrace:
android.view.InflateException: Binary XML file line #16: Binary XML file line #16: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #16: Error inflating class <unknown>
Caused by: java.lang.reflect.InvocationTargetException
at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
...
at android.view.LayoutInflater.$$robo$$android_view_LayoutInflater$createView(LayoutInflater.java:647)
...
at com.myapp.poll.PollHomeFragment.onCreateView(PollHomeFragment.kt:31)
...
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 13: TypedValue{t=0x2/d=0x7f0301b1 a=-1}
at android.content.res.TypedArray.getDrawableForDensity(TypedArray.java:946)
at android.content.res.TypedArray.getDrawable(TypedArray.java:930)
at android.view.View.__constructor__(View.java:5010)
at android.view.View.<init>(View.java)
at android.widget.TextView.<init>(TextView.java)
...
at com.myapp.poll.PollHomeFragment.onCreateView(PollHomeFragment.kt:31)
Here's the layout:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout 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"
android:gravity="center"
android:orientation="vertical"
tools:context=".poll.PollActivity">
<TextView
android:id="#+id/tvEmail"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
tools:text="asdf#asdf.com" />
<TextView <!-- This is line 16 -->
android:id="#+id/tvViewPoll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:minHeight="48dp"
android:text="View Poll" />
<TextView
android:id="#+id/tvCreatePoll"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="?attr/selectableItemBackground"
android:gravity="center"
android:minHeight="48dp"
android:text="Create Poll" />
OK, from an educated guess based on the stacktrace, I tried removing android:background="?attr/selectableItemBackground" and this resolves the issue.
It appears that ?attr/selectableItemBackground is perhaps not compatible with FragmentScenario or this is a framework bug.
I submitted a bug on the issue tracker: https://issuetracker.google.com/issues/144629519
Update from Google:
Status: Won't Fix (Intended Behavior) The default theme does not have
an app defined attribute ?attr/selectableItemBackground (as Fragment
has no dependency on AppCompat, MDC, etc)
It sounds like you should be passing the correct theme to
FragmentScenario:
launchFragmentInContainer<PollHomeFragment>(themeResId = R.style.Theme_YourTheme)
In Java one also has to pass the theme to the FragmentScenario. Else the Fragment will not know about the current theme and will eventually complain that one should set an AppCompat theme ...
FragmentScenario<SomeFragment> scenario = FragmentScenario.launchInContainer(
SomeFragment.class,
Bundle.EMPTY,
R.style.Theme_Custom,
null
);
For me, using "android:?attr/selectableItemBackground" instead, solved the problem

Android: Error inflating class <unknown> caused by: missing Theme.AppCompat theme [duplicate]

This question already has answers here:
Android "You need to use a Theme.AppCompat theme (or descendant) with the design library"
(3 answers)
Theme Material Android: You need to use a Theme.AppCompat theme (or descendant) with the design library [duplicate]
(3 answers)
"You need to use a Theme.AppCompat theme (or descendant) with the design library" error
(3 answers)
Closed 3 years ago.
today, I have encountered this problem:
I am trying to use a custom TabLayout inside a RecyclerView item. Note that this same component has been used in other parts of the app without issue (never in RecyclerView tho).
The item I am trying to inflate only contains the TabLayout:
<layout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools">
<android.support.constraint.ConstraintLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<my.package.CustomTabLayout
android:id="#+id/tabs"
android:layout_width="match_parent"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="parent">
<android.support.design.widget.TabItem
android:id="#+id/tab1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/text1" />
<android.support.design.widget.TabItem
android:id="#+id/tab2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="#string/text2" />
</my.package.CustomTabLayout>
</android.support.constraint.ConstraintLayout>
</layout>
the exception:
android.view.InflateException: Binary XML file line #10: Binary XML file line #10: Error inflating class <unknown>
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class <unknown>
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance0(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:334)
at android.view.LayoutInflater.createView(LayoutInflater.java:647)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:790)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:730)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:863)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:824)
at android.view.LayoutInflater.inflate(LayoutInflater.java:515)
at android.view.LayoutInflater.inflate(LayoutInflater.java:423)
at android.databinding.DataBindingUtil.inflate(DataBindingUtil.java:126)
at android.databinding.DataBindingUtil.inflate(DataBindingUtil.java:95)
at my.package.recycler.MyAdapter.onCreateViewHolder(MyAdapter.kt:25)
at my.package.recycler.MyAdapter.onCreateViewHolder.onCreateViewHolder(MyAdapter.kt:16)
[...]
Caused by: java.lang.IllegalArgumentException: You need to use a Theme.AppCompat theme (or descendant) with the design library.
at android.support.design.widget.ThemeUtils.checkAppCompatTheme(ThemeUtils.java:33)
at android.support.design.widget.TabLayout.<init>(TabLayout.java:298)
at android.support.design.widget.TabLayout.<init>(TabLayout.java:292)
at my.package.CustomTabLayout.<init>(CustomTabLayout.java:23)
in the adatper I am basically doing this: (can't show the whole code)
DataBindingUtil.inflate(LayoutInflater.from(MyApplication.getContext()), R.layout.tabs_item, parent, false)
there are other inflations in the the adapter, all working correctly.
I can't understand why it's working if used in activity directly but not in RecyclerView
Any idea?

java.lang.ClassNotFoundException: Didn't find class "androidx.core.view.ViewPager" on path

I just migrated my project to androidx and i am getting an inflation error for inflating viewpager component...I replaced android.support.v4.view.ViewPager with androidx.viewpager.widget.ViewPager
This my xml file
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:padding="#dimen/_1dp"
android:layout_height="wrap_content"
android:background="#color/banner_border_color">
<androidx.viewpager.widget.ViewPager
android:id="#+id/vp_slider"
android:layout_width="match_parent"
android:layout_height="#dimen/_140dp"
android:background="#drawable/thumb_new_background" />
<RelativeLayout
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="bottom">
<TextView
android:id="#+id/tv_banner_view_more"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_marginLeft="#dimen/_16dp"
android:background="#drawable/drawable_btn_curved"
android:paddingBottom="#dimen/_6dp"
android:paddingLeft="#dimen/_8dp"
android:paddingRight="#dimen/_8dp"
android:paddingTop="#dimen/_6dp"
android:visibility="gone"
android:text="#string/text_view_more"
android:textColor="#color/c_white"
android:textSize="#dimen/_8sp" />
</RelativeLayout>
</FrameLayout>
The Error i'm getting :
Caused by: android.view.InflateException: Binary XML file line #329: Binary XML file line #8: Error inflating class androidx.core.view.ViewPager
Caused by: android.view.InflateException: Binary XML file line #8: Error inflating class androidx.core.view.ViewPager
Caused by: java.lang.ClassNotFoundException: Didn't find class "androidx.core.view.ViewPager" on path: DexPathList[
I figure out problem,
When we merger to androidx then android studio convert viewpager, swipe to refresh layout and some other views to androidx.core for example viewpager its looks like androidx.core.view.ViewPager but correct is androidx.viewpager.widget.ViewPager please check in your xml layouts and see there is right component is added or not if there is androidx.core then check for right one and replace it.
And also import dependency
implementation 'com.google.android.material:material:1.1.0-alpha08
You need to below dependencies in your build.gradle file
implementation 'com.google.android.material:material:1.1.0
You need to add below dependencies in your build.gradle file
implementation 'com.google.android.material:material:1.4.0
I think you need to Invalidate caches and restart
Go to File > Invalidate caches/Restart > ** Invalidate
Then rebuild project

Error inflating class TextView?

I am trying to display an AlertDialog but I am getting below error because of the TextView (code is given below). The dialog works fine when I comment out this TextView code.
Here's the TextView code,
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter OTP"
android:textSize="20dp"
android:padding="#dimen/min_padding"/>
Here's the Logcat error,
android.view.InflateException: Binary XML file line #0: Binary XML file line #0: Error inflating class TextView
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class TextView
Caused by: java.lang.UnsupportedOperationException: Can't convert value at index 14 to dimension: type=0x4
Check the value of min_padding
You should create dimens.xml in the values folder .And min_padding has value .
Like this .
<resources>
<dimen name="min_padding">10dp</dimen>
</resources>
Id is missing in textView
I think you are not accessing valid id
<TextView
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Enter OTP"
android:textSize="20dp"
android:id="#+id/textview"
android:padding="5dp"/>

Android - Resources$NotFoundException

I have an App with over 100.000 Users. But on some devices (~50) I get a strange exception. The stack traces says, that there is an drawable not found.
Here is the stack trace:
java.lang.RuntimeException: Unable to start activity ComponentInfo{mindmApp.the.big.bang.theory.quiz/mindmApp.the.big.bang.theory.quiz.GameNormalActivity}: android.view.InflateException: Binary XML file line #237: Error inflating class
...
Caused by: android.view.InflateException: Binary XML file line #237: Error inflating class
at android.view.LayoutInflater.createView(LayoutInflater.java:606)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:653)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:678)
...
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:586)
... 28 more
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/textviewxml_joker.xml from drawable resource ID #0x7f02003d
at android.content.res.Resources.loadDrawable(Resources.java:1956)
at android.content.res.TypedArray.getDrawable(TypedArray.java:601)
at android.view.View.(View.java:2841)
at android.widget.TextView.(TextView.java:580)
at android.widget.TextView.(TextView.java:573)
I have no idea why this drawable (it's a xml-file) is not found.
The binary XML file line #237 is:
<TextView
android:id="#+id/textViewSkip"
android:layout_width="0px"
android:layout_height="wrap_content"
android:layout_marginLeft="4dp"
android:layout_weight="1"
android:background="#drawable/textviewxml_joker"
android:gravity="center"
android:text="#string/tvSkip"
android:textAppearance="?android:attr/textAppearanceMedium"
android:textColor="#color/color_textview"
android:textSize="22sp" />
And here is the textviewxml_joker.xml file:
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item
android:drawable="#drawable/textview_joker_pressed"
android:state_pressed="true"/>
<item android:drawable="#drawable/textview_joker"/>
</selector>
Have anybody an idea t osolve this problem?
Best Regards!
If your textviewxml_joker.xml file isn't in drawable, but rather in a drawable-* folder, then those few devices that get the error may not meet the conditions to use the drawable-* folder.
Put it in drawable as well and it should fix it.
This could also happen if the resource you are referring to (lets call it ResA) is in-turn referring to a resource which is missing (lets call it ResB).
Android will raise the ResourceNotFoundException for ResA even though whats really missing is ResB. Such is life!
In my case, ResB was defined in the values-swxxxdp but not in values. Hence I was getting this exception on phones but not on tablets.
If you have multiple resource folders, make sure that Android finds your drawable xml for every possible qualifier combination (Providing Resources). Looking at the device types that have this error might give you a hint where to look.

Categories

Resources