我使用的是Android Studio 3.0,
我已经很累解决此问题。应用程序不执行它总是向我显示此错误二进制XML文件第0行:膨胀类ImageView的错误
这是我的main_activity.xml,我更改了使用ConstraintLayout的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:layout_height="match_parent"
tools:context="com.example.razoo.mywages.MainActivity">
<ImageView
android:id="@+id/imageView2"
android:layout_width="wrap_content"
android:layout_height="517dp"
android:contentDescription="@string/button3"
android:scaleType="fitXY"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:src="@drawable/doctor" />
<Button
android:id="@+id/step1btn"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="4dp"
android:background="@color/colorPrimary"
android:onClick="nextPage"
android:text="@string/button3"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintLeft_toLeftOf="parent"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintVertical_bias="0.498"
tools:layout_alignParentEnd="true"
tools:layout_alignParentRight="true"
tools:layout_alignParentTop="true"
/>
<Button
android:id="@+id/button3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_margin="16dp"
android:background="@color/colorPrimary"
android:text="@string/button3"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintRight_toRightOf="parent"
app:layout_constraintTop_toTopOf="parent"
tools:layout_alignParentEnd="true"
tools:layout_alignParentRight="true"
tools:layout_alignParentTop="true" />
主要活动的Java代码
public class MainActivity extends Activity {
Button btn1;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.main_activity);//the error point here
btn1 = (Button) findViewById(R.id.step1btn);
}
public void nextPage(View view){
Intent StartNewActivity = new Intent(MainActivity.this, Main2Activity.class);
startActivity(StartNewActivity);
}
}
这是完整的日志,
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.razoo.mywages/com.example.razoo.mywages.MainActivity}: android.view.InflateException: Binary XML file line #0: Error inflating class android.widget.ImageView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2305)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5272)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)
Caused by: android.view.InflateException: Binary XML file line #0: Error inflating class android.widget.ImageView
at android.view.LayoutInflater.createView(LayoutInflater.java:633)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:387)
at android.app.Activity.setContentView(Activity.java:2188)
at com.example.razoo.mywages.MainActivity.onCreate(MainActivity.java:16)
at android.app.Activity.performCreate(Activity.java:5977)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2258)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5272)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:387)
at android.app.Activity.setContentView(Activity.java:2188)
at com.example.razoo.mywages.MainActivity.onCreate(MainActivity.java:16)
at android.app.Activity.performCreate(Activity.java:5977)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2258)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5272)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)
Caused by: android.content.res.Resources$NotFoundException: Resource "com.example.razoo.mywages:drawable/doctor" (7f060054) is not a Drawable (color or path): TypedValue{t=0x1/d=0x7f060054 a=-1 r=0x7f060054}
at android.content.res.Resources.loadDrawableForCookie(Resources.java:2431)
at android.content.res.Resources.loadDrawable(Resources.java:2371)
at android.content.res.TypedArray.getDrawable(TypedArray.java:749)
at android.widget.ImageView.<init>(ImageView.java:146)
at android.widget.ImageView.<init>(ImageView.java:135)
at android.widget.ImageView.<init>(ImageView.java:131)
at java.lang.reflect.Constructor.newInstance(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:288)
at android.view.LayoutInflater.createView(LayoutInflater.java:607)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:55)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:682)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:741)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:806)
at android.view.LayoutInflater.inflate(LayoutInflater.java:504)
at android.view.LayoutInflater.inflate(LayoutInflater.java:414)
at android.view.LayoutInflater.inflate(LayoutInflater.java:365)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:387)
at android.app.Activity.setContentView(Activity.java:2188)
at com.example.razoo.mywages.MainActivity.onCreate(MainActivity.java:16)
at android.app.Activity.performCreate(Activity.java:5977)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2258)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2365)
at android.app.ActivityThread.access$800(ActivityThread.java:148)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1283)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5272)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:909)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:704)
似乎不完全支持某些SVG源。在活动的onCreate()方法中添加以下行:
AppCompatDelegate.setCompatVectorFromResourcesEnabled(true);
并确保您在XML文件中使用以下属性作为ImageView的属性:app:srcCompact而不是android:src来定义图像。
问题内容: 我按照http://www.techotopia.com/index.php/Using_Fragments_in_Android_- _A_Worked_Example上 的教程创建了一个应用程序,但出现错误。 LogCat: MainActivity.java: activity_main.xml: ToolbarFragment.java: toolbar_fragment.xm
我正在尝试遵循Maps API指南,但我已经出现此错误一段时间了。我已经尝试过: android.view.InflateException:二进制XML文件:inflating类片段错误 这是我的xml代码 这是我的主要活动
问题内容: 这是我的代码: input.xml (布局文件夹) InputFragment.java 我可以正确运行此代码,但是当我更改仿真器的方向时,会出现以下错误。 基本上,该错误定位到以下位置: 这只会在模拟器中发生,而不会在手机中发生。怎么了 问题答案: 检查您的根布局的背景图像-解码位图时,VM内存不足。缩小图像尺寸。
我已经检查了所有类似的问题(这个和其他),但仍然无法找出错误的原因,它在运行时的某个时候一直关闭。。。 ragment.java fragment\u category\u详细信息。xml 错误: 错误似乎来自这一行 我已经尽力了,非常感谢您的帮助。。。
致命异常:java.lang.RuntimeException:无法启动activity ComponentInfo{com.test/com.Activities.ViewActivity}:Android.View.InflateException:二进制XML文件行#29:二进制XML文件行#29:在Android.app.ActivityThread.HandleLaunchActivit
我刚刚实现了我的第四个选项卡到我的应用程序中,已经实现了谷歌地图。在此实现之前,我的应用程序运行良好,但现在当我更改选项卡时,它会崩溃。我在这里看到过类似的问题,但没有一个有答案(实际上有这么多不同的原因和回应这个问题) 下面是fragmentshouts_maps类 查看寻呼机适配器类 这是我的错误日志