2016-11-16 7 views
1

は、私はこのエラーを取得する:次のクラスが見つかりませんでした: - com.google.android.gms.ads.AdView

The following classes could not be found:
- com.google.android.gms.ads.AdView

私はGoogleがバージョン38にバージョン37とGoogleのリポジトリへのサービスを再生する更新しました

また、私のOnCreate()の私のMainActivityクラスでは、私はCannot resolve symbol 'MobileAds'エラーを受け取ります。私はそれがインポートが欠落していることが原因であることを知っていますが、インポートするクラスは提供されていません。

MobileAds.initialize(getApplicationContext(), "ca-app-pub-3940256099942544~3347511713"); 

XMLファイル:

<?xml version="1.0" encoding="utf-8"?> 
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" 
    xmlns:tools="http://schemas.android.com/tools" 
    xmlns:ads="http://schemas.android.com/apk/lib/com.example.gateway.myapp" 
    android:layout_width="match_parent" 
    android:layout_height="match_parent" 
    android:padding="5dp" 
    tools:context="com.example.gateway.myapp.Class" 
    android:orientation="vertical"> 
    <com.google.android.gms.ads.AdView 
     android:id="@+id/adView" 
     android:layout_width="wrap_content" 
     android:layout_height="wrap_content" 
     ads:adSize="BANNER" 
     ads:adUnitId="@string/banner_ad_unit_id"> 
    </com.google.android.gms.ads.AdView> 
</LinearLayout> 

build.gradle(モジュール):

apply plugin: 'com.android.application' 
android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.3" 

    defaultConfig { 
     applicationId "com.example.gateway.myapp" 
     minSdkVersion 9 
     targetSdkVersion 23 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
} 

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.4.0' 
    compile 'com.android.support:design:23.4.0' 
    compile 'com.google.firebase:firebase-core:9.8.0' 
} 
apply plugin: 'com.google.gms.google-services' 

build.gradle(プロジェクト):あなたの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.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 
} 

答えて

1

com.googleを追加します。 firebase:fiリベース - 広告

dependencies { 
     compile fileTree(dir: 'libs', include: ['*.jar']) 

     compile 'com.google.firebase:firebase-ads:9.8.0' 
    } 

Googleモバイル広告は、今Google Mobile Ads SDK

+0

これは私のエラーを修正、ありがとうございます。 – Alex

0

Admobsグーグルservices.Itを演じることにより、配信Firebase SDKとGoogleモバイル広告の一部に使用できなくなった(FirebaseとSDKを含まない)を更新スタンドアロンSDKで

Reference linkMigrate from the Google project.

関連する問題