请帮我解决此崩溃报告无法确定原因。它只发生在联想手机上,适用于所有其他手机。
STACK_TRACE = java.lang.RuntimeException:无法启动活动ComponentInfo {com.somenewapp / com.somenewapp.CategoryActivity}:android.view.InflateException:二进制XML文件行#26:二进制XML文件行#26:错误膨胀android.app.A活动时,在Android.app.A活动,活动,移动活动(ActivityThread.java:2606)的android.app.A活动,活动,移动活动(ActivityThread.java:2626),android.app上的android.app.ActivityThread.-wrap11(ActivityThread.java)。 ActivityThread $ H.handleMessage(ActivityThread.java:1475)位于android.app.AooT.Thread.main的android.os.Handler.dispatchMessage(Handler.java:111)android.os.Looper.loop(Looper.java:207) (ActivityThread.java:5740)位于com.android.internal.os的com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:905)的java.lang.reflect.Method.invoke(Native Method) .ZygoteInit.main(ZygoteInit.java:766)引起:android.view.InflateException:二进制XML文件行#26:二进制XML文件行#26:错误使类膨胀android.app.ActivityThread的android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1113)android.app.Activity.performCreate(Activity.java:6543)的com.somenewapp.CategoryActivity.onCreate(CategoryActivity.java:30) .performLaunchActivity(ActivityThread.java:2513)... 9 more android.view.InflateException:二进制XML文件行#26:二进制XML文件行#26:在com.somenewapp.CategoryActivity.onCreate(CategoryActivity.java: 30)在Android.app.A活动中的android.app.Asetrumentation.Ap响应(Activity.java:1113)android.app.A活动。 app.ActivityThread.handleLaunchActivity(ActivityThread.java:2626)位于android.app.Handler上android.app.ActivityThread $ H.handleMessage(ActivityThread.java:1475)的android.app.ActivityThread.-wrap11(ActivityThread.java)。 dispatchMessage(Handler.java:111)在android.os.Looper.loop(Looper.java:207)在android .app.ActivityThread.main(ActivityThread.java:5740)at com.android.internal.os.ZygoteInit $ MethodAndArgsCaller.run(ZygoteInit.java:905)at com的java.lang.reflect.Method.invoke(Native Method) .android.internal.os.ZygoteInit.main(ZygoteInit.java:766)
这是我的onCreate方法。
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (Build.VERSION.SDK_INT > 20) {
Window window = getWindow();
window.addFlags(WindowManager.LayoutParams.FLAG_DRAWS_SYSTEM_BAR_BACKGROUNDS);
window.clearFlags(WindowManager.LayoutParams.FLAG_TRANSLUCENT_STATUS);
window.addFlags(WindowManager.LayoutParams.FLAG_SECURE);
window.setStatusBarColor(Color.BLACK);
}
setContentView(R.layout.activity_category); //this is line 30
}
这是我的activity_category.xml
<?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:background="@drawable/india_bg"
tools:context="com.somenewapp.CategoryActivity">
<ImageView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:contentDescription="@string/content_description"
android:src="@color/transparent_green"/>
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_centerInParent="true"
android:layout_marginEnd="@dimen/large_marg"
android:layout_marginLeft="@dimen/large_marg"
android:layout_marginRight="@dimen/large_marg"
android:layout_marginStart="@dimen/large_marg"
android:orientation="vertical">
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/content_description"
android:src="@drawable/india_1024"
android:scaleType="centerCrop"
android:adjustViewBounds="true"/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/narr_marg"
android:contentDescription="@string/content_description"
android:src="@drawable/import_yarn_from_india_1024"
android:scaleType="centerCrop"
android:adjustViewBounds="true"/>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginEnd="@dimen/narr_marg"
android:layout_marginLeft="@dimen/narr_marg"
android:layout_marginRight="@dimen/narr_marg"
android:layout_marginStart="@dimen/narr_marg"
android:layout_marginTop="@dimen/narr_marg"
android:background="@color/aluminum"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/narr_marg"
android:contentDescription="@string/content_description"
android:src="@drawable/indian_flag_1947"
android:scaleType="centerCrop"
android:adjustViewBounds="true"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/narr_marg"
android:contentDescription="@string/content_description"
android:src="@drawable/indian_flag"
android:scaleType="centerCrop"
android:adjustViewBounds="true"/>
<View
android:layout_width="match_parent"
android:layout_height="0.5dp"
android:layout_marginEnd="@dimen/narr_marg"
android:layout_marginLeft="@dimen/narr_marg"
android:layout_marginRight="@dimen/narr_marg"
android:layout_marginStart="@dimen/narr_marg"
android:layout_marginTop="@dimen/narr_marg"
android:background="@color/aluminum"
/>
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginTop="@dimen/narr_marg"
android:contentDescription="@string/content_description"
android:src="@drawable/india_new_sec"
android:scaleType="centerCrop"
android:adjustViewBounds="true"/>
</LinearLayout>
</RelativeLayout>
答案 0 :(得分:0)
显然错误是布局的第26行,对应于此ImageView
:
<ImageView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:contentDescription="@string/content_description"
android:src="@drawable/india_1024"
android:scaleType="centerCrop"
android:adjustViewBounds="true"/>
我最好的选择是drawable india_1024
具有某种使其失败的资源限定符,或者是由于内存不足而使该设备失败的巨大图像。可能是前者。
你可以在这个drawable上添加更多信息吗?