Not enough space to show ad. Needs 360x50 dp, but only has 360x0 dp

-1

My application crashes the second time i open it. and am I getting the error "Not enough space to show ad. Needs 360x50 dp, but only has 360x0 dp.". Below is the layout used for displaying ad.My first activity does not use adview. When i exit from first activity, and open app again its working fine. My second activity also has adview in it and also an exit option. When i exit from second activity(layout is given below), and open app again, it crashes.Since the issue arises only when i exit from second activity. i suspect that adview is behind the crash, but am not sure.

<?xml version="1.0" encoding="utf-8"?>
<android.support.constraint.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:context="com.sunplus.suniq.activity.FresherActivity"
    tools:showIn="@layout/activity_fresher">

    <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <ListView
            android:id="@+id/simpleListView"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:divider="@color/material_blue_grey_800"
            android:dividerHeight="1dp"
            android:footerDividersEnabled="false" />

        <com.google.android.gms.ads.AdView
            xmlns:ads="http://schemas.android.com/apk/res-auto"
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_alignParentBottom="true"
            ads:adSize="BANNER"
            ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
        </com.google.android.gms.ads.AdView>

    </LinearLayout>

</android.support.constraint.ConstraintLayout>

This is what logcat shows.(somehow the original error changed in logcat, but on execution issue is same). On closing the app, and opening it again it crashes.

W/ResourceType: No package identifier when getting value for resource number 0x00000258
W/ImageView: Unable to find resource: 600
             android.content.res.Resources$NotFoundException: Resource ID #0x258
                 at android.content.res.ResourcesImpl.getValueForDensity(ResourcesImpl.java:224)
                 at android.content.res.Resources.getDrawableForDensity(Resources.java:876)
                 at android.content.res.Resources.getDrawable(Resources.java:819)
                 at android.content.Context.getDrawable(Context.java:605)
                 at android.widget.ImageView.resolveUri(ImageView.java:915)
                 at android.widget.ImageView.setImageResource(ImageView.java:477)
                 at com.android.volley.toolbox.ImageLoader$1.onResponse(ImageLoader.java:112)
                 at com.android.volley.toolbox.ImageLoader.get(ImageLoader.java:229)
                 at com.android.volley.toolbox.ImageLoader.get(ImageLoader.java:191)
                 at com.android.volley.toolbox.ImageLoader.get(ImageLoader.java:182)
                 at com.sunplus.suniq.adapter.CustomAdapter.getView(CustomAdapter.java:80)
                 at android.widget.AbsListView.obtainView(AbsListView.java:2365)
                 at android.widget.ListView.measureHeightOfChildren(ListView.java:1408)
                 at android.widget.ListView.onMeasure(ListView.java:1315)
                 at android.view.View.measure(View.java:22071)
                 at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
                 at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
                 at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
                 at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
                 at android.view.View.measure(View.java:22071)
                 at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:1028)
                 at android.view.View.measure(View.java:22071)
                 at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
                 at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:739)
                 at android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:91)
                 at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:1361)
                 at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:809)
                 at android.view.View.measure(View.java:22071)
                 at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1059)
                 at android.view.View.measure(View.java:22071)
                 at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
                 at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
                 at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:141)
                 at android.view.View.measure(View.java:22071)
                 at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
                 at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
                 at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
                 at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
                 at android.view.View.measure(View.java:22071)
                 at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
                 at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
                 at android.view.View.measure(View.java:22071)
                 at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
                 at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
                 at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
                 at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
                 at android.view.View.measure(View.java:22071)
                 at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
                 at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
                 at com.android.internal.policy.DecorView.onMeasure(DecorView.java:724)
                 at android.view.View.measure(View.java:22071)
                 at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2422)
                 at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1504)
                 at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1761)
                 at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1392)
                 at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6752)
                 at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
                 at android.view.Choreographer.doCallbacks(Choreographer.java:723)
                 at android.view.Choreographer.doFrame(Choreographer.java:658)
                 at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
                 at android.os.Handler.handleCallback(Handler.java:790)
                 at android.os.Handler.dispatchMessage(Handler.java:99)
                 at android.os.Looper.loop(Looper.java:164)
                 at android.app.ActivityThread.main(ActivityThread.java:6494)
                 at java.lang.reflect.Method.invoke(Native Method)
                 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
W/ResourceType: No package identifier when getting value for resource number 0x00000258
W/ImageView: Unable to find resource: 600
             android.content.res.Resources$NotFoundException: Resource ID #0x258
                 at android.content.res.ResourcesImpl.getValueForDensity(ResourcesImpl.java:224)
                 at android.content.res.Resources.getDrawableForDensity(Resources.java:876)
                 at android.content.res.Resources.getDrawable(Resources.java:819)
                 at android.content.Context.getDrawable(Context.java:605)
                 at android.widget.ImageView.resolveUri(ImageView.java:915)
                 at android.widget.ImageView.setImageResource(ImageView.java:477)
                 at com.android.volley.toolbox.ImageLoader$1.onResponse(ImageLoader.java:112)
                 at com.android.volley.toolbox.ImageLoader.get(ImageLoader.java:229)
                 at com.android.volley.toolbox.ImageLoader.get(ImageLoader.java:191)
                 at com.android.volley.toolbox.ImageLoader.get(ImageLoader.java:182)
                 at com.sunplus.suniq.adapter.CustomAdapter.getView(CustomAdapter.java:80)
                 at android.widget.AbsListView.obtainView(AbsListView.java:2365)
                 at android.widget.ListView.measureHeightOfChildren(ListView.java:1408)
                 at android.widget.ListView.onMeasure(ListView.java:1315)
                 at android.view.View.measure(View.java:22071)
                 at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
                 at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
                 at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
                 at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
                 at android.view.View.measure(View.java:22071)
                 at android.support.constraint.ConstraintLayout.onMeasure(ConstraintLayout.java:1028)
                 at android.view.View.measure(View.java:22071)
                 at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
                 at android.support.design.widget.CoordinatorLayout.onMeasureChild(CoordinatorLayout.java:739)
                 at android.support.design.widget.HeaderScrollingViewBehavior.onMeasureChild(HeaderScrollingViewBehavior.java:91)
                 at android.support.design.widget.AppBarLayout$ScrollingViewBehavior.onMeasureChild(AppBarLayout.java:1361)
                 at android.support.design.widget.CoordinatorLayout.onMeasure(CoordinatorLayout.java:809)
                 at android.view.View.measure(View.java:22071)
                 at android.support.v4.widget.DrawerLayout.onMeasure(DrawerLayout.java:1059)
                 at android.view.View.measure(View.java:22071)
                 at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
                 at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
                 at android.support.v7.widget.ContentFrameLayout.onMeasure(ContentFrameLayout.java:141)
                 at android.view.View.measure(View.java:22071)
                 at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
                 at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
                 at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
                 at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
                 at android.view.View.measure(View.java:22071)
                 at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
                 at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
                 at android.view.View.measure(View.java:22071)
                 at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
                 at android.widget.LinearLayout.measureChildBeforeLayout(LinearLayout.java:1514)
                 at android.widget.LinearLayout.measureVertical(LinearLayout.java:806)
                 at android.widget.LinearLayout.onMeasure(LinearLayout.java:685)
                 at android.view.View.measure(View.java:22071)
                 at android.view.ViewGroup.measureChildWithMargins(ViewGroup.java:6602)
                 at android.widget.FrameLayout.onMeasure(FrameLayout.java:185)
                 at com.android.internal.policy.DecorView.onMeasure(DecorView.java:724)
                 at android.view.View.measure(View.java:22071)
                 at android.view.ViewRootImpl.performMeasure(ViewRootImpl.java:2422)
                 at android.view.ViewRootImpl.measureHierarchy(ViewRootImpl.java:1504)
                 at android.view.ViewRootImpl.performTraversals(ViewRootImpl.java:1761)
                 at android.view.ViewRootImpl.doTraversal(ViewRootImpl.java:1392)
                 at android.view.ViewRootImpl$TraversalRunnable.run(ViewRootImpl.java:6752)
W/ImageView:     at android.view.Choreographer$CallbackRecord.run(Choreographer.java:911)
                 at android.view.Choreographer.doCallbacks(Choreographer.java:723)
                 at android.view.Choreographer.doFrame(Choreographer.java:658)
                 at android.view.Choreographer$FrameDisplayEventReceiver.run(Choreographer.java:897)
                 at android.os.Handler.handleCallback(Handler.java:790)
                 at android.os.Handler.dispatchMessage(Handler.java:99)
                 at android.os.Looper.loop(Looper.java:164)
                 at android.app.ActivityThread.main(ActivityThread.java:6494)
                 at java.lang.reflect.Method.invoke(Native Method)
                 at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:438)
                 at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:807)
D/DynamitePackage: Instantiating com.google.android.gms.ads.ChimeraAdManagerCreatorImpl
I/Ads: Starting ad request.
I/Ads: This request is sent from a test device.
I/zygote: JIT allocated 67KB for compiled code of void android.view.View.<init>(android.content.Context, android.util.AttributeSet, int, int)
I/Choreographer: Skipped 33 frames!  The application may be doing too much work on its main thread.
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
I/Ads: Scheduling ad refresh 70000 milliseconds from now.
I/DynamiteModule: Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:280
                  Selected remote version of com.google.android.gms.ads.dynamite, version >= 280
I/Ads: Ad finished loading.
W/zygote: Attempt to remove non-JNI local reference, dumping thread
W/zygote: Attempt to remove non-JNI local reference, dumping thread
I/zygote: Do full code cache collection, code=469KB, data=292KB
I/zygote: After code cache collection, code=389KB, data=233KB
          JIT allocated 56KB for compiled code of void android.view.View.<init>(android.content.Context, android.util.AttributeSet, int, int)
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
W/zygote: Attempt to remove non-JNI local reference, dumping thread
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
W/zygote: Attempt to remove non-JNI local reference, dumping thread
W/zygote: Attempt to remove non-JNI local reference, dumping thread
W/zygote: Attempt to remove non-JNI local reference, dumping thread
W/zygote: Attempt to remove non-JNI local reference, dumping thread
W/zygote: Attempt to remove non-JNI local reference, dumping thread
W/zygote: Attempt to remove non-JNI local reference, dumping thread
W/zygote: Attempt to remove non-JNI local reference, dumping thread
W/zygote: Attempt to remove non-JNI local reference, dumping thread
W/zygote: Attempt to remove non-JNI local reference, dumping thread
W/zygote: Attempt to remove non-JNI local reference, dumping thread
W/zygote: Attempt to remove non-JNI local reference, dumping thread
W/zygote: Attempt to remove non-JNI local reference, dumping thread
W/zygote: Attempt to remove non-JNI local reference, dumping thread
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
D/OpenGLRenderer: endAllActiveAnimators on 0xe6adc700 (MenuPopupWindow$MenuDropDownListView) with handle 0xd30ff080
D/EGL_emulation: eglMakeCurrent: 0xf00b21e0: ver 3 1 (tinfo 0xf008fa30)
I/Process: Sending signal. PID: 28712 SIG: 9
Application terminated.
android
android-layout
admob
asked on Stack Overflow May 26, 2018 by A Koul • edited May 26, 2018 by A Koul

2 Answers

0

You need to give weight to listview if you want static banner at bottom of any linear layout.

<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:orientation="vertical">

        <ListView
            android:id="@+id/simpleListView"
            android:layout_width="fill_parent"
            android:layout_height="0dp"
            android:divider="@color/material_blue_grey_800"
            android:dividerHeight="1dp"
            android:layout_weight="1" 
            android:footerDividersEnabled="false" />

        <com.google.android.gms.ads.AdView
            xmlns:ads="http://schemas.android.com/apk/res-auto"
            android:id="@+id/adView"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content"
            android:layout_centerHorizontal="true"
            android:layout_alignParentBottom="true"
            ads:adSize="BANNER"
            ads:adUnitId="ca-app-pub-3940256099942544/6300978111">
        </com.google.android.gms.ads.AdView>

    </LinearLayout>

hope this may help you.

answered on Stack Overflow May 26, 2018 by Amrish Kakadiya
0
<?xml version="1.0" encoding="utf-8"?>
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    app:layout_behavior="@string/appbar_scrolling_view_behavior"
    tools:showIn="@layout/activity_fresher">

    <ListView
        android:id="@+id/simpleListView"
        android:layout_width="fill_parent"
        android:layout_height="wrap_content"
        android:layout_above="@+id/adView"
        android:divider="@color/material_blue_grey_800"
        android:dividerHeight="1dp"
        android:footerDividersEnabled="false" />


    <com.google.android.gms.ads.AdView xmlns:ads="http://schemas.android.com/apk/res-auto"
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        ads:adSize="BANNER"
        ads:adUnitId="ca-app-pub-3940256099942544/6300978111"></com.google.android.gms.ads.AdView>

</RelativeLayout>

Use this in your layout, This will solve your issue completely.

Hope it Works

answered on Stack Overflow May 26, 2018 by Sandeep Parish

User contributions licensed under CC BY-SA 3.0