相关疑难解决方法(0)

Google Play服务的AdMob会执行不受欢迎的自动滚动操作

我正在使用Google Play服务版本13中的AdMob.我意识到,当我将广告放入其中时ScrollView,AdMob会在从服务器成功获取广告后尝试执行不需要的自动滚动.

package com.example.admob_bug;

import com.google.android.gms.ads.AdRequest;
import com.google.android.gms.ads.AdSize;
import com.google.android.gms.ads.AdView;

import android.os.Bundle;
import android.app.Activity;
import android.view.Menu;
import android.widget.LinearLayout;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        // Create the adView.
        adView = new AdView(this);
        adView.setAdUnitId("a151b03485063e0");
        adView.setAdSize(AdSize.BANNER);

        // Lookup your LinearLayout assuming it's been given
        // the attribute android:id="@+id/mainLayout".
        LinearLayout layout = (LinearLayout)findViewById(R.id.advertisement);

        // Add the adView to it.
        layout.addView(adView);

        // Initiate a generic request.
        AdRequest adRequest = new AdRequest.Builder().build();

        // Load the …
Run Code Online (Sandbox Code Playgroud)

android admob google-play-services

8
推荐指数
1
解决办法
2042
查看次数

遇到AdMobs问题

从AdMobs开始,我遇到了一些奇怪的问题.

第一个问题

当我尝试通过此代码添加我的横幅时:

        layout = (RelativeLayout) findViewById(R.id.adprincipal);
    adView = new AdView(this);
    adView.setAdUnitId("my unit id");
    adView.setAdSize(AdSize.BANNER);
    AdRequest adRequest = new AdRequest.Builder()  
    .addTestDevice("my device")  
    .build();
    // Load the adView with the ad request.
    adView.loadAd(adRequest);
    layout.addView(adView);
Run Code Online (Sandbox Code Playgroud)

如果我设置了大小AdSize.SMART_BANNER,我什么也得不到,但是我得到了一个测试横幅AdSize.BANNER但是ANYWAY(甚至是BANNER和SMART_BANNER)这是我从LogCat获得的:

当横幅时

12-30 04:41:00.380:W/ResourceType(27407):getEntry失败,因为entryIndex 13超出类型entryCount 5

12-30 04:41:00.380:W/ResourceType(27407):无法在包0中输入0x7f0b000d(t = 10 e = 13)(错误-2147483647)

12-30 04:41:00.380:E/GooglePlayServicesUtil(27407):找不到Google Play服务资源.检查项目配置以确保包含资源.

12-30 04:41:00.400:W/ResourceType(27407):getEntry失败,因为entryIndex 13超出类型entryCount 5

12-30 04:41:00.400:W/ResourceType(27407):无法在包0中输入0x7f0b000d(t = 10 e = 13)(错误-2147483647)

12-30 04:41:00.400:E/GooglePlayServicesUtil(27407):找不到Google Play服务资源.检查项目配置以确保包含资源.

12-30 04:41:02.111:I/GATE(27407):DEV_ACTION_COMPLETED

12-30 04:41:02.111:I/Ads(27407):广告已完成加载.

当SMART_BANNER

12-30 04:48:27.476:W/ResourceType(29507):getEntry失败,因为entryIndex 13超出类型entryCount 5

12-30 04:48:27.476:W/ResourceType(29507):无法在包0中输入0x7f0b000d(t = 10 …

android admob google-play-services

5
推荐指数
1
解决办法
1万
查看次数

Android Studio AdMob与Google Play服务集成

我正在尝试将admob功能添加到我的应用程序中.我做了一切,但我错过了一些关键点.

这是我的评价:

apply plugin: 'android'

android {
compileSdkVersion 19
buildToolsVersion '19.0.1'

defaultConfig {
    minSdkVersion 13
    targetSdkVersion 19
    versionCode 1
    versionName "1.0"
}
buildTypes {
    release {
        runProguard false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-    rules.txt'
        }
    }
}

dependencies {
    compile 'com.android.support:appcompat-v7:+'
    compile 'com.google.android.gms:play-services:+'
    compile fileTree(dir: 'libs', include: ['*.jar', '*.aar'])
}
Run Code Online (Sandbox Code Playgroud)

这是广告视图的XML布局部分

`<com.google.ads.AdView
    xmlns:ads="http://schemas.android.com/apk/lib/com.google.ads"
    android:id="@+id/adView"
    android:layout_width="match_parent"
    android:layout_height="wrap_content"
    ads:adUnitId="ca-app-pub-8644867804576560/1489221139"
    ads:adSize="SMART_BANNER"
    ads:testDevices="*******50664**2"
    ads:loadAdOnCreate="true"/>`
Run Code Online (Sandbox Code Playgroud)

这些元标记和必要的权限将添加到Manifest.xml中

<meta-data android:name="com.google.android.gms.version"
        android:value="@integer/google_play_services_version"/>

<activity android:name="com.google.android.gms.ads.AdActivity"
        android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
Run Code Online (Sandbox Code Playgroud)

最后这是崩溃时刻的logcat.

02-16 12:50:31.941    8898-8898/com.exampl.deneme E/AndroidRuntime? FATAL EXCEPTION: main
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.exampl.deneme/com.exampl.deneme.MainActivity}: android.view.InflateException: …
Run Code Online (Sandbox Code Playgroud)

android admob google-play-services android-studio

4
推荐指数
1
解决办法
6057
查看次数