问题
my app is crashing when I am inserting an image and I am not getting log report too when I am writing android:background="@drawable/logo"
my app is crashing
<?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"
android:id="@+id/rootLayout"
android:background="@drawable/logo"
tools:context="com.android.spotsdialog.MainActivity">
</RelativeLayout>
回答1:
The problem is you probably testing on lower API version then API24. So it will throw ResourceNotFoundException
cause drawable does not exists for it .
So You have to have a copy of it normal drawable folder drawable . Or in all drawable-v24, drawable-v21 and drawable . put the drawable in all folder most importantly in drawable
.
drawable
drawable-v21
drawable-v24
回答2:
please put crashing text or you can replace this code
<?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"
tools:context="com.android.spotsdialog.MainActivity"
android:layout_width="match_parent"
android:layout_height="match_parent">
<ImageView
android:id="@+id/rootLayout"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:src="@drawable/logo"
/>
</RelativeLayout >
来源:https://stackoverflow.com/questions/49462502/app-is-crashing-when-i-am-inserting-background-image