因此,出于某种原因,当我放入广告时,它不会自动填充广告:adSize和ads:adUnitId,我无法选择它们,而我的广告显示的文字显示缺少必需的XML属性"adSize".我也不认为我可以在我的布局中填写xmlns:ads,虽然我可能弄错了.为什么是这样?
我的渐变
// 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.2' 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 }
第二个build.gradle
apply plugin: 'com.android.application' android { compileSdkVersion 25 buildToolsVersion "25.0.0" defaultConfig { applicationId "com.example.matig.adtest" minSdkVersion 15 targetSdkVersion 25 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:25.1.0' testCompile 'junit:junit:4.12' compile 'com.google.firebase:firebase-ads:9.0.2' compile 'com.google.android.gms:play-services-ads:9.0.2' } apply plugin: 'com.google.gms.google-services'
我的布局:
我一步一步地遵循火焰基础教程所以我真的很困惑我做错了什么
将布局与文档中提供的示例进行比较表明您需要添加:
xmlns:ads="http://schemas.android.com/apk/res-auto"
和
ads:adSize="BANNER"