我的应用程序在(Oneplus 3)等高端设备上运行顺畅,但在低端设备中崩溃。试图降低图像的分辨率,删除列表视图,但仍然,崩溃继续。发布错误日志以及我的XML。我认为错误是在这个xml文件中没有其他问题。我是android的新手。 。请帮助我。
01-29 01:51:39.252 22876-22876/com.instagram.satyajit.instagramclone
E/AndroidRuntime: Exception
01-29 01:51:39.282 22876-22876/com.instagram.satyajit.instagramclone E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.instagram.satyajit.instagramclone, PID: 22876
android.view.InflateException: Binary XML file line #0: Error inflating class <unknown>
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at com.android.internal.policy.impl.PhoneLayoutInflater.onCreateView(PhoneLayoutInflater.java:56)
at android.view.LayoutInflater.onCreateView(LayoutInflater.java:669)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:694)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at com.instagram.satyajit.instagramclone.HomeFragments.Home.onCreateView(Home.java:45)
at android.support.v4.app.Fragment.performCreateView(Fragment.java:2354)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1419)
at android.support.v4.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1740)
at android.support.v4.app.FragmentManagerImpl.moveToState(FragmentManager.java:1809)
at android.support.v4.app.BackStackRecord.executeOps(BackStackRecord.java:799)
at android.support.v4.app.FragmentManagerImpl.executeOps(FragmentManager.java:2580)
at android.support.v4.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2367)
at android.support.v4.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2322)
at android.support.v4.app.FragmentManagerImpl.execSingleAction(FragmentManager.java:2199)
at android.support.v4.app.BackStackRecord.commitNowAllowingStateLoss(BackStackRecord.java:651)
at android.support.v4.app.FragmentPagerAdapter.finishUpdate(FragmentPagerAdapter.java:145)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1236)
at android.support.v4.view.ViewPager.populate(ViewPager.java:1084)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1614)
at android.view.View.measure(View.java:16653)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:847)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16653)
at android.support.v4.view.ViewPager.onMeasure(ViewPager.java:1630)
at android.view.View.measure(View.java:16653)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5131)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16653)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5131)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:139)
at android.view.View.measure(View.java:16653)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5131)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16653)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5131)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at android.view.View.measure(View.java:16653)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5131)
at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1404)
at android.widget.LinearLayout.measureVertical(LinearLayout.java:695)
at android.widget.LinearLayout.onMeasure(LinearLayout.java:588)
at android.view.View.measure(View.java:16653)
at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:5131)
at android.widget.FrameLayout.onMeasure(FrameLayout.java:310)
at com.android.internal.policy.impl.PhoneWindow$DecorView.onMeasure(PhoneWindow.java:2295)
at android.view.View.measure(View.java:16653)
at android.vi
01-29 01:51:49.872 22876-22876/com.instagram.satyajit.instagramclone I/Process: Sending signal. PID: 22876 SIG: 9
Home.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">
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content">
<android.support.v7.widget.Toolbar
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="1">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="horizontal"
android:layout_marginRight="12dp"
android:gravity="center">
<ImageView
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="0.50"
android:src="@drawable/ic_camera" />
<ImageView
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="4"
android:src="@drawable/instawrittenlogo"/>
<ImageView
android:layout_width="0dp"
android:layout_height="40dp"
android:layout_weight="0.50"
android:src="@drawable/ic_near_me_black_24dp"/>
</LinearLayout>
</android.support.v7.widget.Toolbar>
</android.support.design.widget.AppBarLayout>
<View
android:layout_width="match_parent"
android:layout_height="1dp"
android:background="@drawable/bottom_shadow" />
<ListView
android:layout_width="match_parent"
android:layout_height="0dp"
android:layout_weight="9"
android:id="@+id/listView"></ListView>
</LinearLayout>
答案 0 :(得分:0)
听起来像内存问题或较低版本的兼容性
使用诸如的内存工具 谷歌镀铬内存快照 adb shell dumpsys meminfo com.example.appname
为了兼容性,您可以尝试降低gradle中的sdk版本
答案 1 :(得分:0)
您的应用使用了多少内存?每个设备都有自己的最大允许内存,正在运行的应用程序可以使用您可以使用以下代码行来检查正在运行的特定设备的最大限制。对于旧设备,此数字较低,而较新设备的数字较高,原因显而易见。
Runtime rt = Runtime.getRuntime();
long maxMemory = rt.maxMemory();
Log.i("Android", "maxMemory:" + Long.toString(maxMemory / 1000000) + "Mb");
这将返回您的应用可以使用的最大RAM量,以兆字节为单位。然后,您可以轻松地将此数字与Android Studio中Android Profiler部分中显示的数字进行比较。从那里你应该能够找出问题所在。