質問をすることでしか得られない、回答やアドバイスがある。

15分調べてもわからないことは、質問しよう!

新規登録して質問してみよう
ただいま回答率
85.50%
Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

Q&A

解決済

2回答

5381閲覧

[Android]AdMob実装でManifest内のmetaタグ(value)にエラーが出ます

k.has

総合スコア34

Android

Androidは、Google社が開発したスマートフォンやタブレットなど携帯端末向けのプラットフォームです。 カーネル・ミドルウェア・ユーザーインターフェイス・ウェブブラウザ・電話帳などのアプリケーションやソフトウェアをひとつにまとめて構成。 カーネル・ライブラリ・ランタイムはほとんどがC言語/C++、アプリケーションなどはJavaSEのサブセットとAndroid環境で書かれています。

0グッド

0クリップ

投稿2016/07/18 22:59

編集2016/07/19 21:19

元々Eclipseで作ったプロジェクトをAdroidStudioにインポートして、AdMobを実装中なのですが、マニフェスト内のmetaタグ(android:value="@integer/google_play_services_version)に以下内容のエラーが出て解決できずに困っております。

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.mois/com.mois.Main}: java.lang.IllegalStateException: The meta-data tag in your app's AndroidManifest.xml does not have the right value. Expected 9256000 but found 4030500. You must have the following declaration within the <application> element: <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" />

Manifestは以下です

<?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.mois" android:versionCode="2" android:versionName="1.1" android:installLocation="preferExternal"> <!-- Include required permissions for Google Mobile Ads to run --> <uses-permission android:name="android.permission.INTERNET" /> <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE" /> <uses-permission android:name="android.permission.ACCESS_WIFI_STATE" /> <uses-permission android:name="android.permission.GET_ACCOUNTS" /> <uses-permission android:name="android.permission.READ_PHONE_STATE" /> <uses-permission android:name="android.permission.RECORD_AUDIO" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> <application android:allowBackup="true" android:icon="@drawable/icon_koukaizou" android:label="@string/app_name" android:name="android.support.multidex.MultiDexApplication"> <!-- This meta-data is required to use Google Play Service --> <meta-data android:name="com.google.android.gms.version" android:value="@integer/google_play_services_version" /> <activity android:name="com.mois.Main" android:label="@string/app_name" android:screenOrientation="landscape" android:theme="@style/MyTheme" > <intent-filter> <action android:name="android.intent.action.MAIN" /> <category android:name="android.intent.category.LAUNCHER" /> </intent-filter> </activity> <activity android:name="com.mois.Play" android:screenOrientation="landscape" android:theme="@style/MyTheme" > </activity> <!-- activity 省略 --> <activity android:name="com.google.android.gms.ads.AdActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize" /> <receiver android:name="com.mois.MyDeviceAdminReceiver" android:permission="android.permission.BIND_DEVICE_ADMIN" > <meta-data android:name="android.app.device_admin" android:resource="@xml/polici" /> <intent-filter> <action android:name="android.app.action.DEVICE_ADMIN_ENABLED" /> </intent-filter> </receiver> </application> </manifest>

gradleは以下です

apply plugin: 'com.android.application' android { compileSdkVersion 24 buildToolsVersion "24.0.0" defaultConfig { applicationId "com.mois" minSdkVersion 14 targetSdkVersion 24 //Enabling multidex support multiDexEnabled true } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt' } } dexOptions { javaMaxHeapSize "2g" } } dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) compile 'com.android.support:appcompat-v7:24.0.0' compile 'com.android.support:support-v4:24.0.0' compile 'com.android.support:multidex:1.0.0' compile 'com.google.android.gms:play-services-ads:9.2.1' } tasks.withType(JavaCompile) { options.encoding = 'UTF-8' }

ソースコー抜粋

import com.google.android.gms.ads.AdView; import com.google.android.gms.ads.AdRequest; public class Main extends Activity{ @Override protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); requestWindowFeature(Window.FEATURE_NO_TITLE); setContentView(R.layout.main); AdView adView = (AdView)this.findViewById(R.id.main_banner); AdRequest adRequest = new AdRequest.Builder().build(); adView.loadAd(adRequest); } }

xmlファイル抜粋

<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:ads="http://schemas.android.com/apk/res-auto" android:layout_width="match_parent" android:layout_height="match_parent" > <LinearLayout android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1.5" > <com.google.android.gms.ads.AdView android:id="@+id/main_banner" android:layout_width="0dp" android:layout_height="wrap_content" android:layout_weight="5" android:gravity="top" android:padding="5dp" ads:adUnitId="ca-app-pub-3940256099942544/6300978111" ads:adSize="BANNER"/> </LinearLayout>

ProjectStructure>app>Dependenciesから最新のライブラリを参照し直したり、一旦Manifestから関連の部分を削除して入力しなおしたりしてみてますがエラーが出ます。SDKManagerから必要なものもインストールできているはずなのですが。

ちなみに新規プロジェクトをテスト的に作って同じように実装するとandroid:value="@integer/google_play_services_versionは9256000をちゃんと指すようになって、ちゃんと広告も出るんですが。。。

ちなみにAndroidStudioはまだ触り始めたばかりで初心者です。
よろしくお願いします。

気になる質問をクリップする

クリップした質問は、後からいつでもMYページで確認できます。

またクリップした質問に回答があった際、通知やメールを受け取ることができます。

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

guest

回答2

0

自己解決

自己解決出来ましたm(_ _)m

Eclipseで開発している時にAdMobを実装していたのですが、AndroidStudioにインポートする際にエラーになった為、関連箇所を削除してインポートしていました。その時にプロジェクトのres>values>intergers.xmlに自動生成されていたgoogle_play_serviceの値が、AndroidStudioの外部ライブラリ参照では上書きされていなかったようで、手入力で書き替えれば済むだけの話でした。

res>values>intergers.xml

xml

1<?xml version="1.0" encoding="utf-8"?> 2<resources> 3 <integer name="google_play_services_version">9256000</integer> 4</resources>

投稿2016/07/20 20:59

k.has

総合スコア34

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

0

Javaソースと XMLソース側もちゃんとなってるんですよね?

投稿2016/07/19 02:16

arutaka

総合スコア29

バッドをするには、ログインかつ

こちらの条件を満たす必要があります。

k.has

2016/07/19 21:21

・・・と、思うのですが。ソースコードとlayoutファイルを追記してみました。
guest

あなたの回答

tips

太字

斜体

打ち消し線

見出し

引用テキストの挿入

コードの挿入

リンクの挿入

リストの挿入

番号リストの挿入

表の挿入

水平線の挿入

プレビュー

15分調べてもわからないことは
teratailで質問しよう!

ただいまの回答率
85.50%

質問をまとめることで
思考を整理して素早く解決

テンプレート機能で
簡単に質問をまとめる

質問する

関連した質問