Reputation: 181
My app is crashing on some devices my minimum API level is set to 16 and when i am testing my app on different devices then its crashing without any detailed error below is details of error
Error:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cbcwebs.app.wincoin/com.cbcwebs.app.wincoin.SplashScreen}: android.view.InflateException: Binary XML file line #10: Error inflating class ImageView
On line Number 32 on My Splash Screen Class
and this is line one 32 (setContentView(R.layout.activity_splash_screen);)
My Activity Code
public class SplashScreen extends AppCompatActivity {
private static final int RC_SIGN_IN = 123;
private FirebaseAuth mAuth;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_splash_screen);
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.setStatusBarColor(Color.WHITE);
}
mAuth = FirebaseAuth.getInstance();
FirebaseUser currentUser = mAuth.getCurrentUser();
if(currentUser == null) {
List<AuthUI.IdpConfig> providers = Arrays.asList(
new AuthUI.IdpConfig.PhoneBuilder().build());
startActivityForResult(
AuthUI.getInstance()
.createSignInIntentBuilder()
.setTheme(R.style.AppTheme)
.setAvailableProviders(providers)
.build(),
RC_SIGN_IN);
}else {
checkUserExist();
}
and My Layout XML
<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.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:layout_width="match_parent"
android:background="#fff"
android:layout_height="match_parent"
tools:context=".SplashScreen">
<ImageView
android:id="@+id/imageView"
android:layout_width="186dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintHorizontal_bias="0.498"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.421"
android:src="@drawable/wincoin"
app:srcCompat="@drawable/wincoin" />
</android.support.constraint.ConstraintLayout>
Full Error
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cbcwebs.app.wincoin/com.cbcwebs.app.wincoin.SplashScreen}: android.view.InflateException: Binary XML file line #10: Error inflating class ImageView
FATAL EXCEPTION: main
Process: com.cbcwebs.app.wincoin, PID: 11121
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cbcwebs.app.wincoin/com.cbcwebs.app.wincoin.SplashScreen}: android.view.InflateException: Binary XML file line #10: Error inflating class ImageView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2176)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2226)
at android.app.ActivityThread.access$700(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1397)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:137)
at android.app.ActivityThread.main(ActivityThread.java:4998)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:777)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:593)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #10: Error inflating class ImageView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.cbcwebs.app.wincoin.SplashScreen.onCreate(SplashScreen.java:32)
at android.app.Activity.performCreate(Activity.java:5243)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2140)
... 11 more
Caused by: android.content.res.Resources$NotFoundException: Resource is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f0800ec a=-1 r=0x7f0800ec}
at android.content.res.Resources.loadDrawable(Resources.java:2068)
at android.content.res.TypedArray.getDrawable(TypedArray.java:602)
at android.widget.ImageView.<init>(ImageView.java:129)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:71)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:67)
at android.support.v7.app.AppCompatViewInflater.createImageView(AppCompatViewInflater.java:181)
at android.support.v7.app.AppCompatViewInflater.createView(AppCompatViewInflater.java:105)
at android.support.v7.app.AppCompatDelegateImplV9.createView(AppCompatDelegateImplV9.java:1035)
at android.support.v7.app.AppCompatDelegateImplV9.onCreateView(AppCompatDelegateImplV9.java:1092)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:684)
... 21 more
Upvotes: 2
Views: 862
Reputation: 51
Use app:srcCompat="@drawable/wincoin"
instead of android:src="@drawable/wincoin"
in your ImageView layout in all Layout files.
Upvotes: 2
Reputation: 21
I had same problem my app would crash on older versions of android. and was getting android.view.Inflateexception, after some searches found that my drawable had only v24 files, and was not supporting older API versions, I solved it by creating new drawable resource file with the same file name that of the v24 files, Android studio automatically create a folder and move both files to that folder. Next step just copy data from v24 files and paste it in the file without v24 files. Thats it.
Upvotes: 1