2016-12-17 51 views
1

我試圖整合admob激勵視頻ads.I得到空白project.Also我已經整合了firebase sdk根據this spec。但是,當我鍵入AdView類android studio沒有看到它。包裝com.google.android.gms.ads不包含廣告類像AdRequestMobileAds。我gradle這個文件:android studio無法解析adView類

根:

// 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' 

回答

1

看起來你錯過了指導,這是增加對火力地堡庫和您使用的個別服務的最後一步。

只需添加這些行:

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' 
} 

這與火力地堡導入AdMob廣告的正確方法。您可以查看this video進行演練。

+1

該死的,我確定我有這些依賴關係。現在我已經在控制檯中有'I/FirebaseInitProvider:FirebaseApp初始化成功'注意事項了。我不需要再導入Google Play服務。謝謝! – undefined

0

忘了補充compile 'com.google.android.gms:play-services:10.0.1'到應用程序級相關模塊

+0

這會讓您獲得Google Play服務,這與Firebase不同。不過,它也包含Mobile Ads SDK,其中包含AdView類。 – RedBrogdon

相關問題