新的Google Play服务Admob权限错误

时间:2015-03-24 07:23:54

标签: android admob google-play-services

我正在测试通过Google Play服务实施的新版Google Admob。

除了android清单

之外,这一切都是通过代码完成的,根本没有xml
private Activity   m_activity;
private AdView     m_adview;
private AdRequest  m_adrequest;

public void init_admob() {
    Log.d("--test--admob--", "Admob Init started");

    m_adview = new AdView(m_activity);
    m_adview.setAdUnitId("ca-app-pub-9986005637768452/7524337670");
    m_adview.setAdSize(AdSize.SMART_BANNER);

    Log.d("--test--admob--", "Admob Init finished");

}

public void show_banner() {

    Log.d("--test--admob--", "Admob building add request started");
    m_adrequest = new AdRequest.Builder()
    .addTestDevice(AdRequest.DEVICE_ID_EMULATOR)
    .addTestDevice("TEST DEVICE ID")
    .build();
    Log.d("--test--admob--", "Admob building add request finished ");


    Log.d("--test--admob--", "Admob attempting to show ads");
    m_adview.loadAd(m_adrequest);
    Log.d("--test--admob--", "Admob finished building ads");

}

在我调用show_banner之后,我会收到日志消息,直到

Log.d("--test--admob--", "Admob attempting to show ads");

然后应用程序只会挂起以下错误代码。

Could not find method android.content.pm.PackageManager.getPackageInstaller, referenced from method com.google.android.gms.common.ew.c
W/ActivityManager( 2282): Permission Denial: opening provider com.google.android.gsf.gservices.GservicesProvider from ProcessRecord{42624eb8 1701:com.test.admob/u0a398} (pid=1701, uid=10398) requires com.google.android.providers.gsf.permission.READ_GSERVICES or com.google.android.providers.gsf.permission.WRITE_GSERVICES
W/ActivityManager( 2282): Permission Denial: opening provider com.google.android.gsf.gservices.GservicesProvider from ProcessRecord{42624eb8 1701:com.test.admob/u0a398} (pid=1701, uid=10398) requires com.google.android.providers.gsf.permission.READ_GSERVICES or com.google.android.providers.gsf.permission.WRITE_GSERVICES
W/ActivityManager( 2282): Permission Denial: opening provider com.google.android.gsf.gservices.GservicesProvider from ProcessRecord{42624eb8 1701:com.test.admob/u0a398} (pid=1701, uid=10398) requires com.google.android.providers.gsf.permission.READ_GSERVICES or com.google.android.providers.gsf.permission.WRITE_GSERVICES
W/ActivityManager( 2282): Permission Denial: opening provider com.google.android.gsf.gservices.GservicesProvider from ProcessRecord{42624eb8 1701:com.test.admob/u0a398} (pid=1701, uid=10398) requires com.google.android.providers.gsf.permission.READ_GSERVICES or com.google.android.providers.gsf.permission.WRITE_GSERVICES
V/WebViewChromiumFactoryProvider( 1701): Binding Chromium to main looper Looper (main, tid 1) {422237d8}

android manifest

<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>

<activity android:name="com.google.android.gms.ads.AdActivity" 
    android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" />

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

[编辑] 我忘了提到我也尝试过添加但是也没用。

2 个答案:

答案 0 :(得分:1)

这似乎是Google Play服务4.3版中的错误。 见https://groups.google.com/forum/#!topic/google-admob-ads-sdk/sePctoDJbRg%5B1-25%5D

答案 1 :(得分:0)

将以下权限添加到manifest.xml

<uses-permission android:name="com.google.android.providers.gsf.permission.READ_GSERVICES" />