首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >广告横幅空间不足

广告横幅空间不足
EN

Stack Overflow用户
提问于 2015-10-06 09:37:19
回答 1查看 396关注 0票数 0

我试图添加一个admob横幅。它在所有屏幕大小很大的设备上都很好,但是当我尝试在屏幕分辨率很小的设备上运行它时,广告就不会出现。

在logcat中我看到:

I/GMPM: App测量正在启动 E/GMPM: getGoogleAppId失败,状态: 10 E/GMPM:上传是不可能的。App测量禁用

W/GooglePlayServicesUtil: Google Play服务过时。需要8115000,但找到6599034 E/GooglePlayServicesUtil: GooglePlayServices由于错误2而不可用

W/Ads:没有足够的空间显示广告。需要320x50 dp,但只有288x420 dp。

这是main.xml

代码语言:javascript
运行
复制
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:ads="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="fill_parent"
android:layout_height="match_parent"
android:background="@drawable/gradient"
android:paddingBottom="@dimen/activity_vertical_margin"
android:paddingLeft="@dimen/activity_horizontal_margin"
android:paddingRight="@dimen/activity_horizontal_margin"
android:paddingTop="@dimen/activity_vertical_margin"
tools:context="com.nesususu.nes.app.onResume">

<LinearLayout
    android:id="@+id/linearLayout20"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentEnd="false"
    android:layout_alignParentRight="false"
    android:layout_alignParentTop="true"
    android:gravity="top|center_horizontal"
    android:nestedScrollingEnabled="false"
    android:orientation="vertical">

    <TextView
        android:id="@+id/timeField2"
        android:layout_width="match_parent"
        android:layout_height="match_parent"
        android:layout_alignParentBottom="true"
        android:layout_centerHorizontal="true"
        android:layout_gravity="top|center_horizontal"
        android:layout_marginBottom="73dp"
        android:gravity="center"
        android:maxLines="1"
        android:padding="12dp"
        android:shadowColor="@color/bright_foreground_disabled_material_dark"
        android:shadowDx="0"
        android:shadowDy="0"
        android:shadowRadius="24"
        android:text="00:00:00"
        android:textAppearance="?android:attr/textAppearanceMedium"
        android:textColor="#06ff00"
        android:textSize="40sp"
        android:textStyle="normal|bold"
        android:theme="@style/Animation.AppCompat.DropDownUp" />

</LinearLayout>

<LinearLayout
    android:layout_width="match_parent"
    android:layout_height="86dp"
    android:layout_above="@+id/linearLayout16"
    android:layout_alignParentLeft="true"
    android:layout_alignParentStart="true"
    android:gravity="center"
    android:orientation="horizontal">


    <Button
        android:id="@+id/btnExit"
        android:layout_width="91dp"
        android:layout_height="86dp"
        android:layout_margin="1dp"
        android:background="@drawable/btnexitcode"
        android:gravity="center" />
</LinearLayout>

<LinearLayout
    android:id="@+id/linearLayout16"
    android:layout_width="fill_parent"
    android:layout_height="wrap_content"
    android:layout_alignParentBottom="true"
    android:layout_centerHorizontal="true"
    android:orientation="horizontal">

    <com.google.android.gms.ads.AdView
        android:id="@+id/adView"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_alignParentBottom="true"
        android:layout_below="@+id/linearLayout16"
        android:layout_centerHorizontal="true"
        android:layout_weight="1"
        ads:adSize="BANNER"
        ads:adUnitId="@string/banner_ad_unit_id"></com.google.android.gms.ads.AdView>
</LinearLayout>
</RelativeLayout>

构建应用程序

代码语言:javascript
运行
复制
apply plugin: 'com.android.application'

android {
    compileSdkVersion 22
    buildToolsVersion "22.0.1"
    defaultConfig {
        applicationId 'com.nesususu.nes.app'
        minSdkVersion 15
        targetSdkVersion 22
        versionCode 3
        versionName "1.2"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    compile 'com.android.support:appcompat-v7:22.2.1'
    compile 'com.google.android.gms:play-services:8.1.0'
}

我试图将广告移动到相对布局,硬编码宽度,但结果是一样的。我测试过的设备是Xperia和三星Galaxy,它们都工作得很好。但三星(SamsungSM-G360H)等一些手机不愿展示这则广告。最后一个的分辨率是480×800,所以它应该有足够的空间。

EN

回答 1

Stack Overflow用户

发布于 2015-10-09 10:28:57

getGoogleAppId失败,状态: 10

我也犯了同样的错误,我用这个解决了他:

您应该配置google-services.json文件并下载这里

例如,您可以检查如何集成登录按钮这里

W/GooglePlayServicesUtil: Google Play服务过时。需要8115000,但找到6599034

您正在使用play-services:8.1.0,我认为它用于sdk版本23。你有targetSdkVersion 22。信息这里

W/Ads:没有足够的空间显示广告。需要320x50 dp,但只有288x420 dp。

回答这里

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/32966586

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档