当我运行项目时,当我单击登录按钮时,它停止运行。 我收到以下错误:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.user.aarogya, PID: 29045
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.user.aarogya/com.example.user.aarogya.Home}: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class ImageView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2488)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2548)
at android.app.ActivityThread.access$1100(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1399)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5613)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
Caused by: android.view.InflateException: Binary XML file line #11: Binary XML file line #11: Error inflating class ImageView
at android.view.LayoutInflater.inflate(LayoutInflater.java:543)
at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.user.aarogya.Home.onCreate(Home.java:11)
at android.app.Activity.performCreate(Activity.java:6362)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2441)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2548)
at android.app.ActivityThread.access$1100(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1399)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5613)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
Caused by: android.view.InflateException: Binary XML file line #11: Error inflating class ImageView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:786)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:708)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:839)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:802)
at android.view.LayoutInflater.inflate(LayoutInflater.java:519)
at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.user.aarogya.Home.onCreate(Home.java:11)
at android.app.Activity.performCreate(Activity.java:6362)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2441)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2548)
at android.app.ActivityThread.access$1100(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1399)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5613)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
Caused by: android.content.res.Resources$NotFoundException: Resource ID #0x7f060055
at android.content.res.Resources.getValue(Resources.java:1369)
at android.content.res.MiuiResources.getValue(MiuiResources.java:146)
at android.support.v7.widget.AppCompatDrawableManager.loadDrawableFromDelegates(AppCompatDrawableManager.java:328)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:193)
at android.support.v7.widget.AppCompatDrawableManager.getDrawable(AppCompatDrawableManager.java:186)
at android.support.v7.content.res.AppCompatResources.getDrawable(AppCompatResources.java:100)
at android.support.v7.widget.AppCompatImageHelper.loadFromAttributes(AppCompatImageHelper.java:58)
at android.support.v7.widget.AppCompatImageView.<init>(AppCompatImageView.java:77)
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:750)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:708)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:839)
at android.view.LayoutInflater.rInflateChildren(LayoutInflater.java:802)
at android.view.LayoutInflater.inflate(LayoutInflater.java:519)
at android.view.LayoutInflater.inflate(LayoutInflater.java:427)
at android.view.LayoutInflater.inflate(LayoutInflater.java:374)
at android.support.v7.app.AppCompatDelegateImplV9.setContentView(AppCompatDelegateImplV9.java:287)
at android.support.v7.app.AppCompatActivity.setContentView(AppCompatActivity.java:139)
at com.example.user.aarogya.Home.onCreate(Home.java:11)
at android.app.Activity.performCreate(Activity.java:6362)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1108)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2441)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2548)
at android.app.ActivityThread.access$1100(ActivityThread.java:154)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1399)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5613)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:774)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:652)
我自己在xml上设计了UI组件,但仍显示此错误。该应用程序运行良好,但是一旦我单击登录按钮,该应用程序便停止工作。这是active_Home.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:id="@+id/bac"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@drawable/blue"
tools:context=".Home">
<ImageView
android:id="@+id/imageView"
android:layout_width="160dp"
android:layout_height="125dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentTop="true"
android:layout_marginStart="23dp"
android:layout_marginLeft="23dp"
android:layout_marginTop="64dp"
android:background="@color/white"
app:srcCompat="@drawable/camera"
android:contentDescription="TODO" />
<Button
android:id="@+id/camera"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageView"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_marginStart="59dp"
android:layout_marginLeft="59dp"
android:layout_marginTop="30dp"
android:text="@string/camera" />
<ImageView
android:id="@+id/imageView2"
android:layout_width="159dp"
android:layout_height="125dp"
android:layout_alignParentTop="true"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginTop="64dp"
android:layout_marginEnd="17dp"
android:layout_marginRight="17dp"
android:background="@color/white"
app:srcCompat="@drawable/community"
android:contentDescription="TODO" />
<Button
android:id="@+id/community"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_below="@+id/imageView2"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_marginTop="35dp"
android:layout_marginEnd="40dp"
android:layout_marginRight="40dp"
android:text="COMMUNITY" />
<ImageView
android:id="@+id/imageView3"
android:layout_width="165dp"
android:layout_height="131dp"
android:layout_alignParentStart="true"
android:layout_alignParentLeft="true"
android:layout_alignParentBottom="true"
android:layout_marginStart="18dp"
android:layout_marginLeft="18dp"
android:layout_marginBottom="140dp"
android:background="@color/white"
app:srcCompat="@drawable/complaints"
android:contentDescription="TODO" />
<Button
android:id="@+id/complaints"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_marginBottom="80dp"
android:text="COMPLAINTS" />
<ImageView
android:id="@+id/imageView4"
android:layout_width="128dp"
android:layout_height="132dp"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:layout_alignParentBottom="true"
android:layout_marginEnd="36dp"
android:layout_marginRight="36dp"
android:layout_marginBottom="135dp"
android:background="@color/white"
app:srcCompat="@drawable/geot"
android:contentDescription="TODO" />
<Button
android:id="@+id/geotag"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignBottom="@+id/complaints"
android:layout_marginBottom="1dp"
android:text="@string/geotag"
tools:ignore="RelativeOverlap" />
<TextView
android:id="@+id/textView2"
android:layout_width="184dp"
android:layout_height="39dp"
android:layout_alignParentStart="true"
android:layout_alignParentTop="true"
android:text="@string/home"
android:textSize="25sp"
android:textStyle="bold"
android:layout_alignParentLeft="true" />
</RelativeLayout>
当我运行不带代码的xml文件时,即为空,它将调用它。但是使用下面的代码却没有。 让我知道是否需要更多代码。
答案 0 :(得分:0)
所有图像可能在可绘制文件夹中不可用。确保还将图像包括在v21和v24文件夹中。