gpt4 book ai didi

android studio 无法解析 adView 类

转载 作者:行者123 更新时间:2023-11-30 00:50:06 25 4
gpt4 key购买 nike

我正在尝试集成 admob 奖励视频广告。我得到了空白项目。我还根据 this spec 集成了 firebase sdk| .However 当我键入 AdView 时,android studio 看不到它。Package com.google.android.gms.ads 不包含像 AdRequest 这样的广告类MobileAds。我的 gradle 文件:

根:

   // Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.3'
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'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
applicationId "com.rhyboo.net.rewarded_video"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

最佳答案

您似乎错过了指南中的最后一步,即为 Firebase 添加库和您正在使用的各项服务。

只需添加这些行:

compile 'com.google.firebase:firebase-core:10.0.1'
compile 'com.google.firebase:firebase-ads:10.0.1'

到您的 build.gradle 依赖项:

dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:24.2.1'
compile 'com.google.firebase:firebase-core:10.0.1' // new!
compile 'com.google.firebase:firebase-ads:10.0.1' // new!
testCompile 'junit:junit:4.12'
}

这是使用 Firebase 导入 AdMob 的正确方法。你可以看看this video进行演练。

关于android studio 无法解析 adView 类,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41197794/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com