Java 原因:android.view.InflateException在android应用程序中膨胀类时出错
我已经开发了一个应用程序一周了,一切都很顺利。我在测试我开发的应用程序的3台设备中没有任何一台出现问题。但现在我只是在这三台设备中的一台上运行了这个应用程序,一切都糟透了。最奇怪的是,该应用程序在其他两台设备上都能正常工作,但在第三台设备上,它在第一次调用onCreate()时崩溃。我真的不知道我做错了什么,因为它在我的一台设备上不起作用。这是我的密码 Manifest.xmlJava 原因:android.view.InflateException在android应用程序中膨胀类时出错,java,android,inflate-exception,Java,Android,Inflate Exception,我已经开发了一个应用程序一周了,一切都很顺利。我在测试我开发的应用程序的3台设备中没有任何一台出现问题。但现在我只是在这三台设备中的一台上运行了这个应用程序,一切都糟透了。最奇怪的是,该应用程序在其他两台设备上都能正常工作,但在第三台设备上,它在第一次调用onCreate()时崩溃。我真的不知道我做错了什么,因为它在我的一台设备上不起作用。这是我的密码 Manifest.xml <?xml version="1.0" encoding="utf-8"?> <manifest x
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="myapp.miquel.mqlapps.hombresmujeresapp">
<meta-data
android:name="ADMOB_PUBLISHER_ID"
android:value="here_goes_my_real_admob_id" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="ndroid.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:exported="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/AppTheme">
<!--
ATTENTION: This was auto-generated to add Google Play services to your project for
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information.
-->
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name=".TestActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".ResultActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".MenuActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SettingsActivity"
android:label="@string/title_activity_settings"
android:screenOrientation="portrait" />
<activity
android:name=".GenderChoiceActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".AboutAppActivity"
android:label="@string/title_activity_about_app"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".MQLAppsIniActivity"
android:label="@string/app_name">
</activity>
</application>
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="myapp.miquel.mqlapps.hombresmujeresapp.ResultActivity"
android:background="#bbdefb">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<Button
style="@style/ButtonInitTest"
android:layout_width="wrap_content"
android:layout_height="75dp"
android:text="Iniciar test"
android:id="@+id/initTest"
android:layout_marginTop="45dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
style="@style/ButtonSettings"
android:layout_width="wrap_content"
android:layout_height="75dp"
android:text="Ajustes"
android:id="@+id/ajustes"
android:layout_below="@+id/initTest"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="62dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
style="@style/ButtonAbout"
android:layout_width="wrap_content"
android:layout_height="75dp"
android:text="Sobre la App"
android:id="@+id/sobreApp"
android:layout_below="@+id/ajustes"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="62dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</RelativeLayout>
活动菜单.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="myapp.miquel.mqlapps.hombresmujeresapp">
<meta-data
android:name="ADMOB_PUBLISHER_ID"
android:value="here_goes_my_real_admob_id" />
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="ndroid.permission.READ_PHONE_STATE" />
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<application
android:allowBackup="true"
android:exported="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:theme="@style/AppTheme">
<!--
ATTENTION: This was auto-generated to add Google Play services to your project for
App Indexing. See https://g.co/AppIndexing/AndroidStudio for more information.
-->
<meta-data
android:name="com.google.android.gms.version"
android:value="@integer/google_play_services_version" />
<activity
android:name=".TestActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".ResultActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".MenuActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SettingsActivity"
android:label="@string/title_activity_settings"
android:screenOrientation="portrait" />
<activity
android:name=".GenderChoiceActivity"
android:label="@string/app_name"
android:screenOrientation="portrait">
</activity>
<activity
android:name=".AboutAppActivity"
android:label="@string/title_activity_about_app"
android:screenOrientation="portrait" >
</activity>
<activity
android:name=".MQLAppsIniActivity"
android:label="@string/app_name">
</activity>
</application>
</manifest>
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout 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:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="myapp.miquel.mqlapps.hombresmujeresapp.ResultActivity"
android:background="#bbdefb">
<RelativeLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true">
<Button
style="@style/ButtonInitTest"
android:layout_width="wrap_content"
android:layout_height="75dp"
android:text="Iniciar test"
android:id="@+id/initTest"
android:layout_marginTop="45dp"
android:layout_alignParentTop="true"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
style="@style/ButtonSettings"
android:layout_width="wrap_content"
android:layout_height="75dp"
android:text="Ajustes"
android:id="@+id/ajustes"
android:layout_below="@+id/initTest"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="62dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
<Button
style="@style/ButtonAbout"
android:layout_width="wrap_content"
android:layout_height="75dp"
android:text="Sobre la App"
android:id="@+id/sobreApp"
android:layout_below="@+id/ajustes"
android:layout_alignParentLeft="true"
android:layout_alignParentStart="true"
android:layout_marginTop="62dp"
android:layout_alignParentRight="true"
android:layout_alignParentEnd="true" />
</RelativeLayout>
</RelativeLayout>
这是菜单活动中的onCreate()中的setContentView()调用
如果您能抽出时间检查我的代码并告诉我是否做错了,我将非常高兴。这是迄今为止我一直面临的最奇怪的麻烦。提前谢谢
嗯,人们,我似乎对一个我甚至没有的9补丁源图像有问题。我所有的绘图文件都是.xml或.png文件,但根本不是.9.png文件。这太奇怪了。好吧,各位,我似乎对一个我甚至没有的9补丁源映像有问题。我所有的绘图都是.xml。问题变得越来越离奇。我甚至已经从.xml文件中删除了所有的小部件,并且不断抛出错误。不知道出了什么问题。很明显,您的一个可绘制图像不是正确的9补丁图像:“需要有效的9补丁源图像”我注意到了这一点,但这意味着什么?什么是9补丁源映像?9补丁映像是可扩展映像。您可以在这里找到一些文档:在您的可绘制图像中查看扩展名为“.9.png”的图像,谢谢您的回答!无论如何,这很奇怪,因为我从.xml中删除了任何可绘制的调用,并且错误一直被抛出。我也没有任何可绘制的扩展名“.9.png”,或者至少我没有看到这个扩展名
FATAL EXCEPTION: main
Process: myapp.miquel.mqlapps.hombresmujeresapp, PID: 13239
java.lang.RuntimeException: Unable to start activity ComponentInfo{myapp.miquel.mqlapps.hombresmujeresapp/myapp.miquel.mqlapps.hombresmujeresapp.MenuActivity}: android.view.InflateException: Binary XML file line #43: Error inflating class android.support.v7.internal.widget.ActionBarContextView
Caused by: android.view.InflateException: Binary XML file line #43: Error inflating class android.support.v7.internal.widget.ActionBarContextView
Caused by: java.lang.reflect.InvocationTargetException
Caused by: java.lang.RuntimeException: org.xmlpull.v1.XmlPullParserException: <internal>: <nine-patch> requires a valid 9-patch source image
at myapp.miquel.mqlapps.hombresmujeresapp.MenuActivity.onCreate(MenuActivity.java:30)