質問編集履歴

2

書式の改善

2016/09/27 08:05

投稿

Boemusan
Boemusan

スコア44

test CHANGED
File without changes
test CHANGED
@@ -16,6 +16,8 @@
16
16
 
17
17
 
18
18
 
19
+ ・Android Studio v2.2
20
+
19
21
  ・エミュレータ:
20
22
 
21
23
  Name: AVD_for_Galaxy_Nexus_by_Google

1

書式の改善

2016/09/27 08:05

投稿

Boemusan
Boemusan

スコア44

test CHANGED
File without changes
test CHANGED
@@ -26,8 +26,372 @@
26
26
 
27
27
 
28
28
 
29
+ ###AndroidManifest.xml
30
+
31
+ ```
32
+
33
+ - 省略 -
34
+
35
+
36
+
37
+ <meta-data android:name="com.google.android.gms.version"
38
+
39
+ android:value="@integer/google_play_services_version"/>
40
+
41
+ <!-- Tell Cocos2dxActivity the name of our .so -->
42
+
43
+ <meta-data android:name="android.app.lib_name"
44
+
45
+ android:value="cocos2djs" />
46
+
47
+
48
+
49
+ - 省略 -
50
+
51
+
52
+
53
+ <activity android:name="com.google.android.gms.ads.AdActivity"
54
+
55
+ android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
56
+
57
+
58
+
59
+ - 省略 -
60
+
61
+
62
+
63
+ <uses-permission android:name="android.permission.INTERNET"/>
64
+
65
+ <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
66
+
67
+ - 省略 -
68
+
69
+ </manifest>
70
+
71
+ ```
72
+
73
+
74
+
75
+ ###build.gradle(プロジェクト)
76
+
77
+ ```
78
+
79
+ - 省略 -
80
+
81
+
82
+
83
+ dependencies {
84
+
85
+ classpath 'com.android.tools.build:gradle:2.2.0'
86
+
87
+ classpath 'com.google.gms:google-services:3.0.0'
88
+
89
+ }
90
+
91
+ }
92
+
93
+
94
+
95
+ - 省略 -
96
+
97
+ ```
98
+
99
+
100
+
101
+ ###build.gradle(Module:helloWorld)
102
+
103
+ ```
104
+
105
+ - 省略 -
106
+
107
+
108
+
109
+ dependencies {
110
+
111
+ compile 'com.google.android.gms:play-services-ads:9.6.1'
112
+
113
+ compile fileTree(dir: 'libs', include: ['*.jar'])
114
+
115
+ compile project(':libcocos2dx')
116
+
117
+ }
118
+
119
+
120
+
121
+ apply plugin: 'com.google.gms.google-services'
122
+
123
+ ```
124
+
125
+
126
+
127
+ ###AppActivity.java
128
+
129
+ ```
130
+
131
+ package org.cocos2dx.javascript;
132
+
133
+
134
+
135
+ import org.cocos2dx.lib.Cocos2dxActivity;
136
+
137
+ import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
138
+
139
+ import com.google.android.gms.ads.*;
140
+
141
+ // For JS and JAVA reflection test, you can delete it if it's your own project
142
+
143
+ import android.app.Activity;
144
+
145
+ import android.os.Bundle;
146
+
147
+ import android.app.AlertDialog;
148
+
149
+ import android.content.DialogInterface;
150
+
151
+ // -------------------------------------
152
+
153
+ import org.cocos2dx.javascript.SDKWrapper;
154
+
155
+
156
+
157
+ import android.content.Context;
158
+
159
+ import android.content.Intent;
160
+
161
+ import android.util.Log;
162
+
163
+ import android.view.Gravity;
164
+
165
+ import android.view.View;
166
+
167
+ import android.view.ViewGroup;
168
+
169
+ import android.widget.RelativeLayout;
170
+
171
+
172
+
173
+ public class AppActivity extends Cocos2dxActivity {
174
+
175
+
176
+
177
+ private static AppActivity app = null;
178
+
179
+ private static Activity activity = null;
180
+
181
+ private static AdView adView = null;
182
+
183
+
184
+
185
+ @Override
186
+
187
+ protected void onCreate(Bundle savedInstanceState) {
188
+
189
+ super.onCreate(savedInstanceState);
190
+
191
+ app = this;
192
+
193
+ SDKWrapper.getInstance().init(this);
194
+
195
+
196
+
197
+ }
198
+
199
+
200
+
201
+ @Override
202
+
203
+ public Cocos2dxGLSurfaceView onCreateView() {
204
+
205
+ Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this);
206
+
207
+ // TestCpp should create stencil buffer
208
+
209
+ glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8);
210
+
211
+
212
+
213
+ SDKWrapper.getInstance().setGLSurfaceView(glSurfaceView);
214
+
215
+
216
+
217
+ return glSurfaceView;
218
+
219
+ }
220
+
221
+
222
+
223
+ // For JS and JAVA reflection test, you can delete it if it's your own project
224
+
225
+ public static void showAlertDialog(final String title,final String message) {
226
+
227
+ // Here be sure to use runOnUiThread
228
+
229
+ app.runOnUiThread(new Runnable() {
230
+
231
+ @Override
232
+
233
+ public void run() {
234
+
235
+ AlertDialog alertDialog = new AlertDialog.Builder(app).create();
236
+
237
+ alertDialog.setTitle(title);
238
+
239
+ alertDialog.setMessage(message);
240
+
241
+ alertDialog.show();
242
+
243
+ }
244
+
245
+ });
246
+
247
+ }
248
+
249
+
250
+
251
+
252
+
253
+ //Cocos Creator(JS)から呼ばれるメソッド
254
+
255
+ public static void createAdView()
256
+
257
+ {
258
+
259
+ activity.runOnUiThread(new Runnable() {
260
+
261
+ @Override
262
+
263
+ public void run()
264
+
265
+ {
266
+
267
+ if (adView == null) {
268
+
269
+ adView = new AdView(activity);
270
+
271
+ adView.setAdUnitId("ca-app-pub-3940256099942544/6300978111"); //テスト用広告ID
272
+
273
+ adView.setAdSize(AdSize.BANNER);
274
+
275
+
276
+
277
+ final RelativeLayout relativeLayout = new RelativeLayout(activity);
278
+
279
+ activity.addContentView(relativeLayout,
280
+
281
+ new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
282
+
283
+ relativeLayout.setVerticalGravity(Gravity.BOTTOM);
284
+
285
+ relativeLayout.addView(adView);
286
+
287
+
288
+
289
+ final AdRequest adRequest = new AdRequest.Builder().build();
290
+
291
+ // .addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build; // テスト用IDでも必要なのか不明なので今は使っていません
292
+
293
+ adView.loadAd(adRequest);
294
+
295
+ }
296
+
297
+ }
298
+
299
+ });
300
+
301
+ }
302
+
303
+
304
+
305
+ //Cocos Creator(JS)から呼ばれるメソッド
306
+
307
+ public static void showAdView() {
308
+
309
+ if (activity == null) return;
310
+
311
+
312
+
313
+ if (adView == null) {
314
+
315
+ createAdView();
316
+
317
+ return;
318
+
319
+ }
320
+
321
+
322
+
323
+ activity.runOnUiThread(new Runnable() {
324
+
325
+ @Override
326
+
327
+ public void run() {
328
+
329
+ adView.setVisibility(View.VISIBLE);
330
+
331
+ }
332
+
333
+ });
334
+
335
+ }
336
+
337
+
338
+
339
+ // Cocos Creator(JS)から呼ばれるメソッド(今回はまだ使用していません)
340
+
341
+ public static void hideAdView() {
342
+
343
+ if (activity == null) return;
344
+
345
+ if (adView == null) return;
346
+
347
+
348
+
349
+ activity.runOnUiThread(new Runnable() {
350
+
351
+ @Override
352
+
353
+ public void run() {
354
+
355
+ adView.setVisibility(View.INVISIBLE);
356
+
357
+ }
358
+
359
+ });
360
+
361
+ }
362
+
363
+
364
+
365
+ @Override
366
+
367
+ protected void onResume() {
368
+
369
+ super.onResume();
370
+
371
+ activity = this;
372
+
373
+ SDKWrapper.getInstance().onResume();
374
+
375
+ }
376
+
377
+
378
+
379
+ - 省略 -
380
+
381
+
382
+
383
+ }
384
+
385
+
386
+
387
+ ```
388
+
389
+
390
+
29
391
  #発生している問題・エラーメッセージ
30
392
 
393
+ 以下のエラーメッセージが、AppActivityのcreateAdView内のadView.loadAd(adRequest)で起きています。
394
+
31
395
  ```
32
396
 
33
397
  W/GooglePlayServicesUtil: Cannot find Google Play services package name.
@@ -90,370 +454,6 @@
90
454
 
91
455
 
92
456
 
93
-
94
-
95
- ###AndroidManifest.xml
96
-
97
- ```
98
-
99
- - 省略 -
100
-
101
-
102
-
103
- <meta-data android:name="com.google.android.gms.version"
104
-
105
- android:value="@integer/google_play_services_version"/>
106
-
107
- <!-- Tell Cocos2dxActivity the name of our .so -->
108
-
109
- <meta-data android:name="android.app.lib_name"
110
-
111
- android:value="cocos2djs" />
112
-
113
-
114
-
115
- - 省略 -
116
-
117
-
118
-
119
- <activity android:name="com.google.android.gms.ads.AdActivity"
120
-
121
- android:configChanges="keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize"/>
122
-
123
-
124
-
125
- - 省略 -
126
-
127
-
128
-
129
- <uses-permission android:name="android.permission.INTERNET"/>
130
-
131
- <uses-permission android:name="android.permission.ACCESS_NETWORK_STATE"/>
132
-
133
- - 省略 -
134
-
135
- </manifest>
136
-
137
- ```
138
-
139
-
140
-
141
- ###build.gradle(プロジェクト)
142
-
143
- ```
144
-
145
- - 省略 -
146
-
147
-
148
-
149
- dependencies {
150
-
151
- classpath 'com.android.tools.build:gradle:2.2.0'
152
-
153
- classpath 'com.google.gms:google-services:3.0.0'
154
-
155
- }
156
-
157
- }
158
-
159
-
160
-
161
- - 省略 -
162
-
163
- ```
164
-
165
-
166
-
167
- ###build.gradle(Module:helloWorld)
168
-
169
- ```
170
-
171
- - 省略 -
172
-
173
-
174
-
175
- dependencies {
176
-
177
- compile 'com.google.android.gms:play-services-ads:9.6.1'
178
-
179
- compile fileTree(dir: 'libs', include: ['*.jar'])
180
-
181
- compile project(':libcocos2dx')
182
-
183
- }
184
-
185
-
186
-
187
- apply plugin: 'com.google.gms.google-services'
188
-
189
- ```
190
-
191
-
192
-
193
- ###AppActivity.java
194
-
195
- ```
196
-
197
- package org.cocos2dx.javascript;
198
-
199
-
200
-
201
- import org.cocos2dx.lib.Cocos2dxActivity;
202
-
203
- import org.cocos2dx.lib.Cocos2dxGLSurfaceView;
204
-
205
- import com.google.android.gms.ads.*;
206
-
207
- // For JS and JAVA reflection test, you can delete it if it's your own project
208
-
209
- import android.app.Activity;
210
-
211
- import android.os.Bundle;
212
-
213
- import android.app.AlertDialog;
214
-
215
- import android.content.DialogInterface;
216
-
217
- // -------------------------------------
218
-
219
- import org.cocos2dx.javascript.SDKWrapper;
220
-
221
-
222
-
223
- import android.content.Context;
224
-
225
- import android.content.Intent;
226
-
227
- import android.util.Log;
228
-
229
- import android.view.Gravity;
230
-
231
- import android.view.View;
232
-
233
- import android.view.ViewGroup;
234
-
235
- import android.widget.RelativeLayout;
236
-
237
-
238
-
239
- public class AppActivity extends Cocos2dxActivity {
240
-
241
-
242
-
243
- private static AppActivity app = null;
244
-
245
- private static Activity activity = null;
246
-
247
- private static AdView adView = null;
248
-
249
-
250
-
251
- @Override
252
-
253
- protected void onCreate(Bundle savedInstanceState) {
254
-
255
- super.onCreate(savedInstanceState);
256
-
257
- app = this;
258
-
259
- SDKWrapper.getInstance().init(this);
260
-
261
-
262
-
263
- }
264
-
265
-
266
-
267
- @Override
268
-
269
- public Cocos2dxGLSurfaceView onCreateView() {
270
-
271
- Cocos2dxGLSurfaceView glSurfaceView = new Cocos2dxGLSurfaceView(this);
272
-
273
- // TestCpp should create stencil buffer
274
-
275
- glSurfaceView.setEGLConfigChooser(5, 6, 5, 0, 16, 8);
276
-
277
-
278
-
279
- SDKWrapper.getInstance().setGLSurfaceView(glSurfaceView);
280
-
281
-
282
-
283
- return glSurfaceView;
284
-
285
- }
286
-
287
-
288
-
289
- // For JS and JAVA reflection test, you can delete it if it's your own project
290
-
291
- public static void showAlertDialog(final String title,final String message) {
292
-
293
- // Here be sure to use runOnUiThread
294
-
295
- app.runOnUiThread(new Runnable() {
296
-
297
- @Override
298
-
299
- public void run() {
300
-
301
- AlertDialog alertDialog = new AlertDialog.Builder(app).create();
302
-
303
- alertDialog.setTitle(title);
304
-
305
- alertDialog.setMessage(message);
306
-
307
- alertDialog.show();
308
-
309
- }
310
-
311
- });
312
-
313
- }
314
-
315
-
316
-
317
-
318
-
319
- //Cocos Creator(JS)から呼ばれるメソッド
320
-
321
- public static void createAdView()
322
-
323
- {
324
-
325
- activity.runOnUiThread(new Runnable() {
326
-
327
- @Override
328
-
329
- public void run()
330
-
331
- {
332
-
333
- if (adView == null) {
334
-
335
- adView = new AdView(activity);
336
-
337
- adView.setAdUnitId("ca-app-pub-3940256099942544/6300978111"); //テスト用広告ID
338
-
339
- adView.setAdSize(AdSize.BANNER);
340
-
341
-
342
-
343
- final RelativeLayout relativeLayout = new RelativeLayout(activity);
344
-
345
- activity.addContentView(relativeLayout,
346
-
347
- new RelativeLayout.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
348
-
349
- relativeLayout.setVerticalGravity(Gravity.BOTTOM);
350
-
351
- relativeLayout.addView(adView);
352
-
353
-
354
-
355
- final AdRequest adRequest = new AdRequest.Builder().build();
356
-
357
- // .addTestDevice(AdRequest.DEVICE_ID_EMULATOR).build; // テスト用IDでも必要なのか不明なので今は使っていません
358
-
359
- adView.loadAd(adRequest);
360
-
361
- }
362
-
363
- }
364
-
365
- });
366
-
367
- }
368
-
369
-
370
-
371
- //Cocos Creator(JS)から呼ばれるメソッド
372
-
373
- public static void showAdView() {
374
-
375
- if (activity == null) return;
376
-
377
-
378
-
379
- if (adView == null) {
380
-
381
- createAdView();
382
-
383
- return;
384
-
385
- }
386
-
387
-
388
-
389
- activity.runOnUiThread(new Runnable() {
390
-
391
- @Override
392
-
393
- public void run() {
394
-
395
- adView.setVisibility(View.VISIBLE);
396
-
397
- }
398
-
399
- });
400
-
401
- }
402
-
403
-
404
-
405
- // Cocos Creator(JS)から呼ばれるメソッド(今回はまだ使用していません)
406
-
407
- public static void hideAdView() {
408
-
409
- if (activity == null) return;
410
-
411
- if (adView == null) return;
412
-
413
-
414
-
415
- activity.runOnUiThread(new Runnable() {
416
-
417
- @Override
418
-
419
- public void run() {
420
-
421
- adView.setVisibility(View.INVISIBLE);
422
-
423
- }
424
-
425
- });
426
-
427
- }
428
-
429
-
430
-
431
- @Override
432
-
433
- protected void onResume() {
434
-
435
- super.onResume();
436
-
437
- activity = this;
438
-
439
- SDKWrapper.getInstance().onResume();
440
-
441
- }
442
-
443
-
444
-
445
- - 省略 -
446
-
447
-
448
-
449
- }
450
-
451
-
452
-
453
- ```
454
-
455
-
456
-
457
457
  ###試したこと
458
458
 
459
459
 
@@ -463,5 +463,3 @@
463
463
  AppActivity内の、AdViewやAdActivityの実装があやしいと思うのですが
464
464
 
465
465
  私はAndroidの仕様に詳しくないので、よくわからない状態です・・・。
466
-
467
- 問題のエラーメッセージはAppActivityのcreateAdView内のadView.loadAd(adRequest)で起きています。