我不时在我的应用程序中出现异常,显然只发生在2部联想手机中(S850和B8080 - 使用Android 4.4)。我不拥有这些手机;这是我在Google Play控制台中看到的信息。它在所有其他设备上运行良好,包括使用Android 4.4的其他设备。
该异常似乎没有给出问题的确切细节,Android Studio也没有在这段代码或布局中给出任何警告。
我已经检查了其他线程,它们似乎是不同的问题,主要是关于“二进制XML文件行”的例外情况,这个消息在我的案例中没有出现。
有任何提示进行调试吗?
例外:
java.lang.RuntimeException:
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2198)
at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2248)
at android.app.ActivityThread.access$800 (ActivityThread.java:138)
at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1199)
at android.os.Handler.dispatchMessage (Handler.java:102)
at android.os.Looper.loop (Looper.java:136)
at android.app.ActivityThread.main (ActivityThread.java:5054)
at java.lang.reflect.Method.invokeNative (Method.java)
at java.lang.reflect.Method.invoke (Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:788)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:604)
at dalvik.system.NativeStart.main (NativeStart.java)
Caused by: android.view.InflateException:
at android.view.LayoutInflater.createView (LayoutInflater.java:620)
at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate (LayoutInflater.java:755)
at android.view.LayoutInflater.rInflate (LayoutInflater.java:758)
at android.view.LayoutInflater.inflate (LayoutInflater.java:492)
at android.view.LayoutInflater.inflate (LayoutInflater.java:397)
at android.view.LayoutInflater.inflate (LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.generateLayout (PhoneWindow.java:3097)
at com.android.internal.policy.impl.PhoneWindow.installDecor (PhoneWindow.java:3226)
at com.android.internal.policy.impl.PhoneWindow.setContentView (PhoneWindow.java:298)
at android.app.Activity.setContentView (Activity.java:1929)
at org.dreamcoder.nightearth.MainActivity.onCreate (MainActivity.java:32)
at android.app.Activity.performCreate (Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1110)
at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2162)
MainActivity片段:
@Override
protected void onCreate(Bundle savedInstanceState)
{
Log.i("MainActivity", "onCreate");
setContentView(R.layout.activity_main_banner);
// Analytics
AnalyticsHandler.init(this, AnalyticsHandler.ScreenName.MainActivity);
// Initialise the ads
Log.i("MainActivity", "Initialising Ads");
AdsHandler.CreateBanner(this);
super.onCreate(savedInstanceState);
}
第32行是setContentView(R.layout.activity_main_banner);
布局如下:
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent" android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
android:paddingBottom="@dimen/activity_vertical_margin"
android:orientation="vertical"
tools:context=".MainActivity">
<!-- The main content view -->
<!--<WebView
android:id="@+id/webView"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginTop="0dp"
android:scrollbars="none"/>-->
<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:id="@+id/fragment_container"
android:layout_width="fill_parent"
android:layout_height="0dp"
android:layout_weight="1"
android:layout_marginTop="0dp" />
<!-- The ad -->
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
ads:adSize="SMART_BANNER"
ads:adUnitId="@string/banner_ad_unit_id" />
<!-- The backup ad -->
<LinearLayout
android:id="@+id/imageButtonContainer"
android:orientation="horizontal"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:weightSum="1.0"
android:visibility="gone">
<!-- Some text -->
<TextView
android:layout_weight="1"
android:layout_width="0dip"
android:layout_height="wrap_content"
android:text="@string/removeads"
android:id="@+id/textView"
android:layout_gravity="center"
android:gravity="center"
android:layout_margin="1dp"
android:textIsSelectable="true" />
<!-- Google Play image -->
<ImageButton
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:id="@+id/imageButton"
android:src="@drawable/android_app_on_google_play"
android:cropToPadding="true"
android:scaleType="fitCenter"
android:adjustViewBounds="true"
android:background="@android:color/transparent"
android:layout_gravity="center"
android:layout_margin="1dp"
android:clickable="false"
android:focusable="false"
android:maxHeight="70dp"
android:maxWidth="180dp" />
</LinearLayout>
</LinearLayout>