2016-05-30 28 views
3

我試圖將谷歌admob集成在我的android工作室應用程序。我收到以下消息在我的日誌(我的格式道歉,將不勝感激的任何援助):谷歌播放服務不是最新的

05-30 01:23:47.389 19555-19555/com.example.livingstonlabs.whatsbest I/Ads: Starting ad request. 
05-30 01:23:47.430 19555-25051/com.example.livingstonlabs.whatsbest W/GooglePlayServicesUtil: Google Play services out of date. Requires 9080000 but found 8489470 
05-30 01:23:47.430 19555-25051/com.example.livingstonlabs.whatsbest W/Ads: Failed to connect to remote ad request service. 
05-30 01:23:47.430 19555-25051/com.example.livingstonlabs.whatsbest W/Ads: Could not start the ad request service. 
05-30 01:23:47.505 19555-19555/com.example.livingstonlabs.whatsbest W/GooglePlayServicesUtil: Google Play services out of date. Requires 9080000 but found 8489470 

我假設我的谷歌播放服務是因爲某些原因過時,但我不明白爲什麼這很是。我會在最後申請插件:'com.google.gms.google-services'「。

的build.gradle(項目)

buildscript { 
    repositories { 
     jcenter() 
    } 
    dependencies { 
     classpath 'com.android.tools.build:gradle:2.1.0' 
     classpath 'com.google.gms:google-services:3.0.0' 


     // NOTE: Do not place your application dependencies here; they belong 
     // in the individual module build.gradle files 
    } 
} 

allprojects { 
    repositories { 
     jcenter() 
    } 
} 

task clean(type: Delete) { 
    delete rootProject.buildDir 
} 


apply plugin: 'com.android.application' 

****的build.gradle(模塊:APP)****

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.3" 

    defaultConfig { 
     applicationId "com.example.livingstonlabs.whatsbest" 
     minSdkVersion 16 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.4.0' 
    compile 'com.google.firebase:firebase-core:9.0.0' 
    compile 'com.google.firebase:firebase-database:9.0.0' 
    compile 'com.google.firebase:firebase-ads:9.0.0' 
    compile 'com.google.android.gms:play-services:9.0.0' 


} 
apply plugin: 'com.google.gms.google-services' 

回答

0

這意味着這款手機的安裝谷歌的遊戲比您在清單中指定的版本低。

您需要更新手機的Google Play服務。

+1

我不明白這是怎麼可能的,因爲我在模擬器上運行它。 –

+0

@JonahLivinston使用Genymotion模擬器,因爲你可以更新谷歌的播放服務 – Ronen

0

您需要更新Google Play服務應用程序。您可以使用GoogleApiAvailability獲取Intent以啓動恢復過程。 GoogleApiAvailability用於驗證設備上的Google Play Services APK是否可用並且是最新的。

您可能希望在運行時檢查GooglePlayServices是否在設備上保持最新狀態。如果沒有,只需顯示相應的errorDialog,它將提示用戶更新它。

Integer resultCode = GooglePlayServicesUtil.isGooglePlayServicesAvailable(getActivity()); 
if (resultCode == ConnectionResult.SUCCESS) { 
    //Do what you want 
} else { 
    Dialog dialog = GooglePlayServicesUtil.getErrorDialog(resultCode, getActivity(), 0); 
    if (dialog != null) { 
     //This dialog will help the user update to the latest GooglePlayServices 
     dialog.show(); 
    } 
} 

檢查文檔以獲得更多信息:https://developers.google.com/android/guides/setup#add_google_play_services_to_your_project

+1

感謝您的回覆,我知道這是基本的,但我如何更新谷歌播放服務應用程序。 ger顯示它安裝時沒有可用的更新,我正在模擬器上運行它(有必要在此模擬器上進行更新,我必須這樣做) –

+0

我運行此代碼,這次在模擬器上打開應用程序時,它促使我更新谷歌播放服務。當我點擊更新它允許我開始第一個活動,但仍然沒有顯示廣告,我得到了關於谷歌播放服務過時的消息 –

0

我今天也有類似的問題。

進入SDK管理器並在'SDK Platform'選項卡下選擇android 6.0。在面板的右下方,點擊「顯示包詳細信息」

enter image description here

現在,下部分爲6.0選擇「谷歌的API」和「谷歌API的系統映像(用於圖像您正在使用)。選擇這兩個對象後重新啓動你的模擬器,它會更新修復。