ionic应用,并显示Admob标语问题

时间:2019-03-25 22:38:04

标签: android angular ionic-framework ionic4

我尝试将Admob插件添加到我的Ionic应用程序中,此后我遇到了问题,因为该依赖项与该依赖项兼容,因此构建失败:

 compile "com.google.android.gms:play-services-base:11.0.4"
 compile "com.google.android.gms:play-services-ads:11.0.4"
 compile "com.google.android.gms:play-services-tagmanager:+"

我尝试手动将版本与cordova-play-services-version-adapter对齐,但每次返回11.0.4时 然后我使用cordova-admob,它添加了一个新的编译器

    compile "com.google.android.gms:play-services-ads:15.0.0"

效果很好,可以构建我的apk 但是终端告诉我有问题

  

“ Cordova Play服务版本适配器”检测到错误。以下
  “ Google Play服务”的依赖项不兼容:    您的版本不兼容,具有以下依赖性    “ Google Play服务”:

     
    
        
  • 'com.google.android.gms:play-services-base:11.0.4'
  •     
  • 'com.google.android.gms:play-services-ads:11.0.4'
  •     
  • 'com.google.android.gms:play-services-tagmanager:+'
  •     
  • 'com.google.firebase:firebase-core:+'
  •     
  • 'com.google.firebase:firebase-messaging:+'
  •     
  • 'com.google.firebase:firebase-config:+'
  •     
  • 'com.google.firebase:firebase-perf:+'
  •     
  • 'com.google.firebase:firebase-messaging:11.6.2'
  •     
  • 'com.google.android.gms:play-services-ads:15.0.0'
  •     
  
     

不存在包含所有这些依赖项的“ Google Play服务”版本。   “ Google Play服务”的所有依赖项必须具有相同的版本。   该应用程序可能无法编译。

我的应用程序中没有横幅或广告

我的build.gradle文件


*
*
*
*
*
*
*
        }
        addSigningProps(cdvReleaseSigningPropertiesFile, signingConfigs.release)
    }
    if (cdvDebugSigningPropertiesFile) {
        addSigningProps(cdvDebugSigningPropertiesFile, signingConfigs.debug)
    }
}

/*
 * WARNING: Cordova Lib and platform scripts do management inside of this code here,
 * if you are adding the dependencies manually, do so outside the comments, otherwise
 * the Cordova tools will overwrite them
 */


dependencies {
    implementation fileTree(dir: 'libs', include: '*.jar')
    // SUB-PROJECT DEPENDENCIES START
    implementation(project(path: ":CordovaLib"))
    compile "com.google.android.gms:play-services-base:11.0.4"
    compile "com.google.android.gms:play-services-ads:11.0.4"
    compile "com.google.android.gms:play-services-tagmanager:+"
    compile "com.google.firebase:firebase-core:+"
    compile "com.google.firebase:firebase-messaging:+"
    compile "com.google.firebase:firebase-config:+"
    compile "com.google.firebase:firebase-perf:+"
    compile "com.android.support:support-annotations:27.+"
    compile "com.android.support:support-v13:27.+"
    compile "me.leolin:ShortcutBadger:1.1.17@aar"
    compile "com.google.firebase:firebase-messaging:11.6.2"
    compile "com.google.android.gms:play-services-ads:15.0.0"
    // SUB-PROJECT DEPENDENCIES END
}

def promptForReleaseKeyPassword() {
    if (!cdvReleaseSigningPropertiesFile) {
        return;
    }
    if ('__unset'.equals(android.signingConfigs.release.storePassword)) {
        android.signingConfigs.release.storePassword = privateHelpers.promptForPassword('Enter key store password: ')
    }
    if ('__unset'.equals(android.signingConfigs.release.keyPassword)) {
        android.signingConfigs.release.keyPassword = privateHelpers.promptForPassword('Enter key password: ');
    }
}

gradle.taskGraph.whenReady { taskGraph ->
    taskGraph.getAllTasks().each() { task ->
      if(['validateReleaseSigning', 'validateSigningRelease', 'validateSigningArmv7Release', 'validateSigningX76Release'].contains(task.name)) {
         promptForReleaseKeyPassword()
      }
    }
}

def addSigningProps(propsFilePath, signingConfig) {
    def propsFile = file(propsFilePath)
    def props = new Properties()
    propsFile.withReader { reader ->
        props.load(reader)
    }

    def storeFile = new File(props.get('key.store') ?: privateHelpers.ensureValueExists(propsFilePath, props, 'storeFile'))
    if (!storeFile.isAbsolute()) {
        storeFile = RelativePath.parse(true, storeFile.toString()).getFile(propsFile.getParentFile())
    }
    if (!storeFile.exists()) {
        throw new FileNotFoundException('Keystore file does not exist: ' + storeFile.getAbsolutePath())
    }
    signingConfig.keyAlias = props.get('key.alias') ?: privateHelpers.ensureValueExists(propsFilePath, props, 'keyAlias')
    signingConfig.keyPassword = props.get('keyPassword', props.get('key.alias.password', signingConfig.keyPassword))
    signingConfig.storeFile = storeFile
    signingConfig.storePassword = props.get('storePassword', props.get('key.store.password', signingConfig.storePassword))
    def storeType = props.get('storeType', props.get('key.store.type', ''))
    if (!storeType) {
        def filename = storeFile.getName().toLowerCase();
        if (filename.endsWith('.p12') || filename.endsWith('.pfx')) {
            storeType = 'pkcs12'
        } else {
            storeType = signingConfig.storeType // "jks"
        }
    }
    signingConfig.storeType = storeType
}

for (def func : cdvPluginPostBuildExtras) {
    func()
}

// This can be defined within build-extras.gradle as:
//     ext.postBuildExtras = { ... code here ... }
if (hasProperty('postBuildExtras')) {
    postBuildExtras()
}
apply plugin: 'com.google.gms.google-services'

这是app.component.ts文件中的admob代码

const bannerConfig: AdMobFreeBannerConfig = {
  // add your config here
  // for the sake of this example we will just use the test config
  id: 'ca-app-pub-5**********70302~27*****190', //my app id 
  isTesting: true,
  autoShow: true
 };
 this.admobFree.banner.config(bannerConfig);

 this.admobFree.banner.prepare()
   .then(() => {
     // banner Ad is ready
     // if we set autoShow to false, then we will need to call the show method here
   })
   .catch(e => console.log(e));``

0 个答案:

没有答案