teratail header banner
teratail header banner
質問するログイン新規登録

質問編集履歴

1

ソースコード、xmlファイルを追記しました。

2016/07/19 21:19

投稿

k.has
k.has

スコア34

title CHANGED
@@ -1,1 +1,1 @@
1
- [Android]Manifest内のmetaタグ(@integer/google_play_services_version)エラーが出ます
1
+ [Android]AdMob実装でManifest内のmetaタグ(value)エラーが出ます
body CHANGED
@@ -2,7 +2,7 @@
2
2
 
3
3
  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" />
4
4
 
5
- マニフェストは以下です
5
+ Manifestは以下です
6
6
  ```
7
7
  <?xml version="1.0" encoding="utf-8"?>
8
8
  <manifest xmlns:android="http://schemas.android.com/apk/res/android"
@@ -109,7 +109,51 @@
109
109
  }
110
110
  ```
111
111
 
112
+ ソースコー抜粋
113
+ ```
114
+ import com.google.android.gms.ads.AdView;
115
+ import com.google.android.gms.ads.AdRequest;
112
116
 
117
+ public class Main extends Activity{
118
+
119
+ @Override
120
+ protected void onCreate(Bundle savedInstanceState) {
121
+ super.onCreate(savedInstanceState);
122
+ requestWindowFeature(Window.FEATURE_NO_TITLE);
123
+ setContentView(R.layout.main);
124
+
125
+ AdView adView = (AdView)this.findViewById(R.id.main_banner);
126
+ AdRequest adRequest = new AdRequest.Builder().build();
127
+ adView.loadAd(adRequest);
128
+ }
129
+ }
130
+ ```
131
+
132
+ xmlファイル抜粋
133
+ ```
134
+ <FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
135
+ xmlns:ads="http://schemas.android.com/apk/res-auto"
136
+ android:layout_width="match_parent"
137
+ android:layout_height="match_parent" >
138
+
139
+ <LinearLayout
140
+ android:layout_width="match_parent"
141
+ android:layout_height="0dp"
142
+ android:layout_weight="1.5" >
143
+
144
+ <com.google.android.gms.ads.AdView
145
+ android:id="@+id/main_banner"
146
+ android:layout_width="0dp"
147
+ android:layout_height="wrap_content"
148
+ android:layout_weight="5"
149
+ android:gravity="top"
150
+ android:padding="5dp"
151
+ ads:adUnitId="ca-app-pub-3940256099942544/6300978111"
152
+ ads:adSize="BANNER"/>
153
+ </LinearLayout>
154
+
155
+ ```
156
+
113
157
  ProjectStructure>app>Dependenciesから最新のライブラリを参照し直したり、一旦Manifestから関連の部分を削除して入力しなおしたりしてみてますがエラーが出ます。SDKManagerから必要なものもインストールできているはずなのですが。
114
158
 
115
159
  ちなみに新規プロジェクトをテスト的に作って同じように実装するとandroid:value="@integer/google_play_services_versionは9256000をちゃんと指すようになって、ちゃんと広告も出るんですが。。。