首页 > 解决方案 > Cordova Admob Pro - PLAY_SERVICES_VERSION 错误

问题描述

我正在我的项目上设置 Cordova Admob Pro ( https://github.com/floatinghotpot/cordova-admob-pro ),并且在构建 ( https://build.phonegap.com )时出现错误

错误:

Could not get unknown property 'PLAY_SERVICES_VERSION' for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

我的代码:

function adSetter(){
alert(navigator.userAgent);
var admobid = {};
// select the right Ad Id according to platform
if( /(android)/i.test(navigator.userAgent) ) { 
    admobid = { // for Android
        banner: 'ca-app-pub-6869992474017983/9375997553',
        interstitial: 'ca-app-pub-6869992474017983/1657046752'
    };
} else if(/(ipod|iphone|ipad)/i.test(navigator.userAgent)) {
    admobid = { // for iOS
        banner: 'ca-app-pub-6869992474017983/4806197152',
        interstitial: 'ca-app-pub-6869992474017983/7563979554'
    };
} else {
    admobid = { // for Windows Phone
        banner: 'ca-app-pub-6869992474017983/8878394753',
        interstitial: 'ca-app-pub-6869992474017983/1355127956'
    };
}

if(AdMob) AdMob.createBanner( {
    isTesting:true, //Remove this Before publishing your app
    adId:admobid.banner, 
    position:AdMob.AD_POSITION.BOTTOM_CENTER, 
    autoShow:true} );

}
  function onDeviceReady(){
  alert("device ready");
      adSetter();
  }


window.load=function(){
 document.addEventListener("deviceready", onDeviceReady, false);
}

配置:

<plugin name="cordova-plugin-admobpro" spec="^2.35.3">
    <variable name="PLAY_SERVICES_VERSION" value="16.0.0" />
</plugin>
<engine name="android" spec="~7.1.4" />
<engine name="ios" spec="~4.5.5" />

标签: androidcordovaphonegap

解决方案


推荐阅读