我有一个Galaxy Samsung选项卡10.1“ GT-P7510型号3.2版。我尝试在其上加载应用程序,这给了我Layout inflater错误。这是为什么?这是logcat所说的:
android.view.InflateException: Binary XML file line #12: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:596)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:644)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:669)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:724)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:727)
at android.view.LayoutInflater.inflate(LayoutInflater.java:479)
at android.view.LayoutInflater.inflate(LayoutInflater.java:391)
at android.view.LayoutInflater.inflate(LayoutInflater.java:347)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:245)
at android.app.Activity.setContentView(Activity.java:1786)
at com.businessplan.BusinessPlannerActivity.onCreate(BusinessPlannerActivity.java:64)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1050)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1782)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1834)
at android.app.ActivityThread.access$500(ActivityThread.java:122)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1027)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:132)
at android.app.ActivityThread.main(ActivityThread.java:4126)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:491)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:844)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:602)
at dalvik.system.NativeStart.main(Native Method)
java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:416)
at android.view.LayoutInflater.createView(LayoutInflater.java:576)
android.content.res.Resources$NotFoundException: Resource is not a Drawable …Run Code Online (Sandbox Code Playgroud) 尝试使用片段显示Google地图.使用以下页面作为教程.
我得到异常"错误膨胀类片段".
1)导入jar google-play-services.jar
2)下载并配置了google play services SDK.
3)获得最新的v2 API密钥.
4)在清单中添加了com.google.android.providers.gsf.permission.READ_GSERVICES权限.
5)使用mindsdk = 8和target = 16.
供参考,Androidmanifest.xml:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.example.com.mapsdemo"
android:versionCode="1"
android:versionName="1.0" >
<uses-feature android:glEsVersion="0x00020000" android:required="true"/>
<permission
android:name="com.example.com.mapsdemo.permission.MAPS_RECEIVE"
android:protectionLevel="signature"/>
<uses-permission android:name="com.example.com.mapsdemo.permission.MAPS_RECEIVE"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES"/>
<uses-sdk
android:minSdkVersion="8"
android:targetSdkVersion="16" />
<application
android:allowBackup="true"
android:icon="@drawable/ic_launcher"
android:label="@string/app_name"
android:theme="@style/AppTheme" >
<activity
android:name="com.example.com.mapsdemo.MainActivity"
android:label="@string/app_name" >
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<meta-data
android:name="com.google.android.maps.v2.API_KEY"
android:value="AIzaSyDXPsxWF634gd907NzZKkRkNS0oH9IPWgk"/>
</application>
Run Code Online (Sandbox Code Playgroud)
MainActivity.java
package com.example.com.mapsdemo;
import android.os.Bundle;
import android.app.Activity;
import android.view.Menu; …Run Code Online (Sandbox Code Playgroud) 当RecylerView项目被longClicked时,我正试图为一个简单的PopupMenu膨胀重命名/删除选项.出于某种原因,我mPopup.show()在将xml文件加载到inflater后调用时出现XML膨胀错误.
我在我的应用程序的其他地方使用类似的逻辑来制作PopupMenu并且它工作正常.我甚至尝试从应用程序的一个不相关的部分加载工作的PopupMenu到这个inflater我看到android.view.InflateException: Binary XML file line #17: Failed to resolve attribute at index 1logcat中的相同错误,所以也许XML文件不是问题?
如何让这个PopupMenu充气并展示自己?
致命异常Logcat
05-31 23:02:27.421 19597-20019/? E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.foo, PID: 19597
android.view.InflateException: Binary XML file line #17: Failed to resolve attribute at index 1: TypedValue{t=0x2/d=0x7f01005d a=-1}
Caused by: java.lang.UnsupportedOperationException: Failed to resolve attribute at index 1: TypedValue{t=0x2/d=0x7f01005d a=-1}
at android.content.res.TypedArray.getLayoutDimension(TypedArray.java:761)
at android.view.ViewGroup$LayoutParams.setBaseAttributes(ViewGroup.java:7060)
at android.view.ViewGroup$MarginLayoutParams.<init>(ViewGroup.java:7241)
at android.widget.FrameLayout$LayoutParams.<init>(FrameLayout.java:438)
at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:370)
at android.widget.FrameLayout.generateLayoutParams(FrameLayout.java:369)
at android.view.LayoutInflater.inflate(LayoutInflater.java:505)
at android.view.LayoutInflater.inflate(LayoutInflater.java:426)
at android.support.v7.view.menu.MenuAdapter.getView(MenuAdapter.java:93)
at android.support.v7.view.menu.MenuPopup.measureIndividualMenuWidth(MenuPopup.java:160)
at android.support.v7.view.menu.StandardMenuPopup.tryShow(StandardMenuPopup.java:153) …Run Code Online (Sandbox Code Playgroud) 在三星 Android 13 设备中出现奇怪的崩溃,但这在其他设备上运行良好。最近,我们在 Firebase 崩溃分析中遇到了一起崩溃,下面是崩溃报告。应用程序的目标 API 级别为 33,到目前为止仅在三星 Android 13 设备中报告崩溃。
编辑文本.xml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical">
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/login_input1_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="@color/input_field_text_color"
android:theme="@style/login_floating_text_style">
<com.mobileaware.unified.ui.controls.common.MaEditText
android:id="@+id/login_input1"
style="@style/input_field_validation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:visibility="gone" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/login_input2_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="@color/input_field_text_color"
android:theme="@style/login_floating_text_style">
<com.mobileaware.unified.ui.controls.common.MaEditText
android:id="@+id/login_input2"
style="@style/input_field_validation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:visibility="gone" />
</com.google.android.material.textfield.TextInputLayout>
<com.google.android.material.textfield.TextInputLayout
android:id="@+id/login_input3_wrapper"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:textColorHint="@color/input_field_text_color"
android:theme="@style/login_floating_text_style">
<com.mobileaware.unified.ui.controls.common.MaEditText
android:id="@+id/login_input3"
style="@style/input_field_validation"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:visibility="gone" />
</com.google.android.material.textfield.TextInputLayout>
</LinearLayout>
Run Code Online (Sandbox Code Playgroud)
堆栈跟踪 :
Fatal Exception: android.view.InflateException
Binary XML file line #21 `com.xyz.abc:layout/edit_texts: Attempt to …Run Code Online (Sandbox Code Playgroud) crash android android-layout layout-inflater inflate-exception
我观看了Google IO 2011大会,几乎每篇文章都有关于OutOfMemory异常和InflateException的内容,没有运气,我找不到任何能解决我问题的答案.
如何从包含背景图像的布局中正确清除内存?我觉得如果InflateException后跟OutOfMemory是相关的,因为背景图像没有被正确清除.
所以我得到了:
Android.Views.InflateException:二进制XML文件行#24:错误类膨胀
其次是 :
Java.Lang.OutOfMemoryError:
我很确定这是由我的背景图片引起的.
我简化了我的代码以尽可能地缩小问题范围.
AndroidManifest.xml中
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android">
<uses-sdk android:minSdkVersion="12" android:targetSdkVersion="12" />
<activity />
<application android:theme="@android:style/Theme.NoTitleBar" parent="android:Theme"/>
</manifest>
Run Code Online (Sandbox Code Playgroud)
我补充说parent="android:Theme",这是假设解决问题,没有成功.
SplashScreen.axml
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/SplashScreenView"
android:orientation="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/splash" />
Run Code Online (Sandbox Code Playgroud)
splash是位于我的drawable文件夹中的.png图像.
SplashScreenActivity.cs
[Activity(Label = "My splash screen", MainLauncher = true)]
public class SplashScreenActivity : Activity
{
protected override void OnCreate(Bundle bundle)
{
base.OnCreate(bundle);
SetContentView(Resource.Layout.SplashScreen);
StartNextActivity();
}
private void StartNextActivity()
{
var intent = new Intent(this, typeof(SplashScreenActivity)); …Run Code Online (Sandbox Code Playgroud) 在我的代码中有一个巨大的问题,我在assets\fonts\自定义TextView类中加载我的文件夹中的字体.第一个问题是它在4.0设备上崩溃,但有例外Caused by: java.lang.RuntimeException: native typeface cannot be made.我在这里使用相同的过程:
public class MyTextView extends TextView {
public MyTextView(Context context, AttributeSet attrs, int defStyle) {
super(context, attrs, defStyle);
}
public MyTextView(Context context, AttributeSet attrs) {
super(context, attrs);
}
public MyTextView(Context context) {
super(context);
}
public void setTypeface(Typeface tf, int style) {
if (style == Typeface.BOLD) {
super.setTypeface(Typeface.createFromAsset(
getContext().getAssets(), "fonts/hirakakupronbold.ttf"));
} else if (style == Typeface.ITALIC) {
super.setTypeface(Typeface.createFromAsset(
getContext().getAssets(), "fonts/hirakakupronitalic.ttf"));
} else {
super.setTypeface(Typeface.createFromAsset(
getContext().getAssets(), "fonts/hirakakupron.ttf")); …Run Code Online (Sandbox Code Playgroud) android memory-leaks android-fonts runtimeexception inflate-exception
I have an app which has fragment and image button on that. The problem is it's working on and above 5.0 but not below 5.0. The min sdk version is 17.
Not getting what's wrong here. I am getting 2 exceptions.
One is RuntimeException for image button.
Second is ResourceNotFoundException for fab selector file.
Log : 1st exception --
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.example.siddhi.timetablelayout/com.example.siddhi.timetablelayout.MainActivity}: android.view.InflateException: Binary XML file line #16:
Error inflating class ImageButton
2nd exception --
Caused …
android android-resources inflate-exception binary-xml android-imagebutton
我正在尝试使用ToolBar(Lollipop Widget)使用android.support.v7库.
但是在运行应用程序时遇到错误.
android.view.InflateException: Binary XML file line #7: Error inflating class Toolbar
Run Code Online (Sandbox Code Playgroud)
我的主要目标是navigation drawer使用toolbar.
这是我正在使用的布局文件:
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/frame_container1"
android:layout_width="match_parent"
android:layout_height="match_parent" >
<Toolbar android:id="@+id/toolbar" <------ line #7
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@color/status" ></Toolbar>
<android.support.v4.widget.DrawerLayout
android:id="@+id/drawer_layout"
android:layout_below="@+id/toolbar"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#FFFFFF" >
<!-- Framelayout to display Fragments -->
<RelativeLayout
android:id="@+id/frame_container"
android:layout_width="match_parent"
android:layout_height="match_parent" >
</RelativeLayout>
<!-- Listview to display slider menu -->
<ListView
android:id="@+id/list_slidermenu"
android:layout_width="240dp"
android:layout_height="match_parent"
android:layout_gravity="start"
android:choiceMode="singleChoice"
android:dividerHeight=".02dp"
android:background="#000000"/>
</android.support.v4.widget.DrawerLayout>
</RelativeLayout>
Run Code Online (Sandbox Code Playgroud)
我使用以下代码:
@Override
protected void onCreate(Bundle …Run Code Online (Sandbox Code Playgroud) 当我使用 MapBox 库启动 android 应用程序时,出现异常:
“android.view.InflateException:二进制 XML 文件第 9 行:错误膨胀类 com.mapbox.mapboxsdk.views.MapView”
字段“原因”包含以下文本:
java.lang.ClassNotFoundException:在路径上找不到类“com.mapbox.mapboxsdk.views.MapView”:DexPathList[[zip 文件“/data/app/com.example.my.mymapbox-2/base.apk” ],nativeLibraryDirectories=[/data/app/com.example.my.mymapbox-2/lib/arm, /vendor/lib, /system/lib]]
请帮忙
这是我的代码:
构建.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "com.example.my.mymapbox"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
compile ('com.mapbox.mapboxsdk:mapbox-android-sdk:4.0.0-beta.2@aar'){
transitive=true
}
}
Run Code Online (Sandbox Code Playgroud)
主活动.java
package com.example.my.mymapbox;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
public class MainActivity …Run Code Online (Sandbox Code Playgroud) 我的程序(实际上不是我的,我只是想修复这个错误)在大多数手机上运行正常,但它不能在索尼Xperia P上启动.
当我启动该程序时,会出现以下消息:
应用程序意外停止.
该应用程序在此手机上也没有启动器图标(仅限默认图标).
错误日志说:
java.lang.RuntimeException: unable to start Activity
android.view.InflateException: Binary XML file line #16: error inflating class android.view.ImageView
Run Code Online (Sandbox Code Playgroud)
应用程序调用时出现错误消息:
setContentView(R.layout.menu_0_splash);
Run Code Online (Sandbox Code Playgroud)
我注意到可绘制资源是针对以下分辨率定义的:
1024x600 320x240 400x240 480x320 800x480 854x480
这款手机的电话是960x540,所以我最好的问题是它也应该是dafault资源.
可能是什么问题呢?
布局文件(现在复制/粘贴-d):
<?xml version = "1.0"
encoding = "utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/m0_relativeLayout"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:background="@drawable/gradient_green" >
<ImageView #this is the problematic line
android:id="@+id/arrow_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentRight="true"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="@dimen/m0_arrow_top_margintop"
android:src="@drawable/splash_arrow_top" />
<ImageView
android:id="@+id/arrow_bottom"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_alignParentLeft="true"
android:layout_marginBottom="@dimen/m0_arrow_bottom_marginbottom"
android:src="@drawable/splash_arrow_bottom" />
<ImageView
android:id="@+id/belt_top"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentTop="true"
android:layout_centerHorizontal="true"
android:src="@drawable/splash_belt_top" …Run Code Online (Sandbox Code Playgroud) android ×10
xml ×2
binary-xml ×1
crash ×1
google-maps ×1
java ×1
mapbox ×1
memory-leaks ×1
resolution ×1
sony ×1