为什么应用程序会在此活动中崩溃?

时间:2018-04-12 09:48:41

标签: android admob

在某些设备上,当用户按下导致必须加载此广告的活动的按钮时,该应用会崩溃。

这是来自应用程序崩溃的设备(带有4.2 android的coolpad):

java.lang.RuntimeException: 
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2358)
  at android.app.ActivityThread.handleLaunchActivity (ActivityThread.java:2410)
  at android.app.ActivityThread.access$600 (ActivityThread.java:169)
  at android.app.ActivityThread$H.handleMessage (ActivityThread.java:1380)
  at android.os.Handler.dispatchMessage (Handler.java:107)
  at android.os.Looper.loop (Looper.java:194)
  at android.app.ActivityThread.main (ActivityThread.java:5463)
  at java.lang.reflect.Method.invokeNative (Native Method)
  at java.lang.reflect.Method.invoke (Method.java:525)
  at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run (ZygoteInit.java:854)
  at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:621)
  at dalvik.system.NativeStart.main (Native Method)
Caused by: android.view.InflateException: 
  at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:704)
  at android.view.LayoutInflater.rInflate (LayoutInflater.java:746)
  at android.view.LayoutInflater.rInflate (LayoutInflater.java:749)
  at android.view.LayoutInflater.rInflate (LayoutInflater.java:749)
  at android.view.LayoutInflater.rInflate (LayoutInflater.java:749)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:489)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:396)
  at android.view.LayoutInflater.inflate (LayoutInflater.java:352)
  at android.support.v7.app.AppCompatDelegateImplV9.setContentView (AppCompatDelegateImplV9.java:292)
  at android.support.v7.app.AppCompatActivity.setContentView (AppCompatActivity.java:140)
  at com.akademos.user.secondtry.QuizActivity.onCreate (QuizActivity.java:52)
  at android.app.Activity.performCreate (Activity.java:5122)
  at android.app.Instrumentation.callActivityOnCreate (Instrumentation.java:1151)
  at android.app.ActivityThread.performLaunchActivity (ActivityThread.java:2322)
Caused by: android.content.res.Resources$NotFoundException: 
  at android.content.res.Resources.loadDrawable (Resources.java:2098)
  at android.content.res.TypedArray.getDrawable (TypedArray.java:601)
  at android.view.View.<init> (View.java:3380)
  at android.widget.TextView.<init> (TextView.java:608)
  at android.widget.Button.<init> (Button.java:107)
  at android.support.v7.widget.AppCompatButton.<init> (AppCompatButton.java:66)
  at android.support.v7.widget.AppCompatButton.<init> (AppCompatButton.java:62)
  at android.support.v7.app.AppCompatViewInflater.createView (AppCompatViewInflater.java:109)
  at android.support.v7.app.AppCompatDelegateImplV9.createView (AppCompatDelegateImplV9.java:1029)
  at android.support.v7.app.AppCompatDelegateImplV9.onCreateView (AppCompatDelegateImplV9.java:1087)
  at android.support.v4.view.LayoutInflaterCompatHC$FactoryWrapperHC.onCreateView (LayoutInflaterCompatHC.java:47)
  at android.view.LayoutInflater.createViewFromTag (LayoutInflater.java:675)
Caused by: org.xmlpull.v1.XmlPullParserException: 
  at android.graphics.drawable.Drawable.createFromXmlInner (Drawable.java:881)
  at android.graphics.drawable.Drawable.createFromXml (Drawable.java:822)
  at android.content.res.Resources.loadDrawable (Resources.java:2094)

以下是可能导致问题的xml:

<pl.droidsonroids.gif.GifImageView
        android:id="@+id/load"
        android:layout_centerInParent="true"
        android:layout_width="90dp"
        android:layout_height="90dp"
        android:src="@drawable/load"
        android:visibility="visible"
        />

1 个答案:

答案 0 :(得分:1)

InflateException表示无法创建XML布局。这通常是由错误的XML语法/错误参数引起的。

Resources$NotFoundException表示系统无法找到某些资源。也许您正在使用旧版Android不支持的View元素。如果可能,请包含您尝试显示的视图的XML布局。