Setup AndroidStudio (version 1.4.7 or later)
This page is not available in English.
Please select another language.
このページでは、Mobage Native SDK (Android 版) のセットアップ方法について解説します。
Mobage Native SDK ライブラリをインポートする(Android Studio 版)
Android Studio のメニューバーから [File] -> [Project Structures...] を選択します。
Project Structure ダイアログが開きますので、左上の「+」ボタンをクリックします。
Create New Module ダイアログが開きますので、画面下部にある More Modules の「Import Existing Project」を選択し、[Next] ボタンをクリックします。
Source directory を選択します。右側の [...] ボタンをクリックします。
クリックすると、Source directory 選択画面が表示されますので、[MobageNativeAndroid] プロジェクトを選択し、[OK] ボタンをクリックします。(Mobage Native SDK の Android ライブラリプロジェクトのディレクトリです)
Mobage Native SDK のディレクトリが Source directory ボックスに入りますので、そのまま [Next] ボタンをクリックします。
以下のような画面が表示されますが、そのまま [Finish] ボタンをクリックします。
Project Structure ダイアログに表示が戻ります。Modules に mobageNativeAndroid が追加されるはずですが、もし以下のように追加されていない場合は、一度 \[OK] ボタンをクリックして、再度 Project Structure ダイアログを表示させてみてください。
以下のように mobageNativeAndroid が表示された状態で、① 既存プロジェクトの Module 名(この場合 app)を選択し、②上部の [Dependencies] タブをクリック、③ 左下の [+] ボタンをクリックします。
以下のような選択メニューが表示されますので、[3 Module dependency] をクリックします。
[Choose Module] ダイアログが表示されますので、[:mobageNativeAndroid] を選択し、[OK] ボタンをクリックします。(Module が出てこない時は Android Studio を再起動してみてください)

以上で Mobage Native SDK のインポートが完了しました。
AndroidManifest.xml を設定する
Mobage Native SDK を用いた開発では、Android 端末が元から持っている様々なネイティブ機能を利用、あるいは制限するために、AndroidManifest.xml の中に下記のような設定のための記述を含める必要があります。
- インターネットへアクセスするため、インターネットアクセス許可が必要です。
- 画面の向き変更に対応していないため、Activity に対して画面の向きを固定します。
- Main の Activity については standard モードおよび singleTop モードで起動するように設定します。
- シングルサインオン用に SDK の内部に Activity を保持しているため、この Activity を外部から呼び出せるように設定します。
- ダッシュボード Activity (MobageDashBoardActivity) の設定が必要です。
- application タグの android:icon="@drawable/icon" については変更しないようにお願いします。(デベロッパーサイトに設定した icon ファイルに差し替わります)
- com.mobage.android.TrackingReceiver の設定が必要です。
![]() | MobageDashboardActivity の screenOrientation に landscape を指定することができます。landscape に設定することで Mobage の UI が横画面で開くようになりますので、横画面のアプリでは指定されることを推奨します。 |
下記の箇所は、お使いの環境に合わせて書き換えてください。
${YourActivityName}:
Activity 名 (FQCN: パッケージ名をつけたクラス名) に書き換えてください。
${YourApplicationId}:
Mobage のアプリケーションID に書き換えてください。
![]() | Mobage Native SDK 1.4.7 より com.mobage.android.TrackingReceiver を必ず追加しなければならなくなりました。
|
F.O.X for Mobage について
Mobage Native SDK 1.4.7.4 以降、以下のように F.O.X for Mobage の利用を選択できるようになりました。
- F.O.X for Mobage を利用する場合は、何もせずに通常のインポート手順で問題ありません。
- F.O.X for Mobage を利用しない場合や、アプリケーションで独自に F.O.X を組み込む場合には、MobageNativeAndroid の代わりに MobageNativeAndroidWithoutFOX をインポートしてください。ライブラリの指定も同様です。
Android Market In-app Billing の設定をする
In-App Billing (以下、IAB) は、アプリ内でデジタルコンテンツを販売することを可能にする Google Play(旧Android Market) のサービスです。
IAB 対応のため Proguard を内部で使用します。それに伴い、既存の非公開 API が削除されております。また、アプリケーションを一般公開する際に多マーケットに対応するため、デベロッパーサイトへアップロードされたアプリケーションからパッケージ名を変更致します。
IAB 機能を利用する為には、下記のステップを踏んで下さい。
[1. FQCN でのクラス名の指定]
下記のクラスの参照の際は FQCN (完全修飾名、パッケージ名をつけたクラス名) で記述してください。
- AndroidManifest.xml に記述するクラス
- R クラス (R クラスを参照する全てのプログラムコード中)
[2. リソースファイル名の制限]
下記のアイコンファイル名は SDK が予約しています。予約された名前からファイル名を変更しないでください。
- /res/drawable/icon.png
- /res/drawable-hdpi/icon.png
- /res/drawable-ldpi/icon.png
- /res/drawable-mdpi/icon.png
[3. マーケット情報設定ファイル名の予約]
下記のマーケット情報設定ファイルは、SDK が予約しています。予約されたファイル名と同じ名前のファイルを作成しないでください。
- /assets/billing_config.xml
[4. Intent 起動について]
広告サービス等で、Intent 起動が必要な場合に、com.mobage.android.activity.MobageProxyActivity に設定された Intent Filter は使用しないでください。
About the usage of Advertising ID (Important)
![]() | From Aug 1, 2014 all uploaded applications on Play Store will need to use Advertising ID for advertising purpose due to the policy changes on Google Play. |
The usage of Android’s AdvertisingID (AdID) is required for Ad tracking purpose when using Cross Promotion or our Smartphone R/S plan.
To use the AdID you will need to implement Google Play Services.
How to Import Google Play service SDK
Your application will need to reference the Google Play service SDK to implement the AdID.
See below on how to import Advertising ID into your project.
- Run Android SDK Manager from eclipse
- Check on「Extras」 > 「Google Play service」 and install the package
Select「Import」 -> 「Android」 -> 「Existing Android Code Into Workspace」 and import "${ANDROID_SDK_PATH}/extras/google/google_play_services/libproject/google-play-services_lib"
Do not reference the actual path but select "Copy projects into workspace" so it will copy the library to your workspace
- Go to「Project の Properties」 > 「Android」 > 「Library」 and add "google-play-service_lib" as a Library Project
Add the following to the <application> tag in the AndroidManifest.xml
![]() | Make sure you have confirmed that Google Play Game Services is linked to your App by following Confirming Google Play Game Services. |
Using Proguard with Google Play Game Services implemented
You will need to configure proguard.cfg or proguard-android.txt as below, when using proguard with Google Play Game Services.
Confirming Google Play Game Services
Make sure to confirm that AdvertisingIdClient class on Google Play Game Services library is present by following the instructions below.
- Open apk file with apktool and confirm that "/smali/com/google/android/gms/ads/identifier/AdvertisingIdClient.smali" exists.
Startup the application with SDK installed and confirm on logcat ($adb logcat) that you don't see the following errors.
If you find any issues by confirming above, you can solve these by following the next steps.
- Remove "google-play-services_lib" library link from your project and add "libs/google-play-services.jar from" from "google-play-services_lib" to your project.
- If you are using old versions of Android SDK Tools or Android SDK Build-Tools, you can try lower the "google-play-services_lib" to version 4.
- For Invalid ApplicationInfo or MetaData error , please check that you have added "meta-data" tag for goole play game services.
- For IllegalStateException make sure you have correct value on meta-data.
If you see Invalid ApplicationInfo or MetaData error on logcat make sure you have meta-data and google play game services version writing on your AndroidManifest.
Using ProGuard with Mobage SDK implemented
Make sure to add the following to your proguard-project.txt when using ProGuard.
Using ProGuard with F.O.X for Mobage implemented
Add the following ProGuard settings when implementing F.O.X for Mobage.更新履歴
- 2014/08/20
- Mobage Native SDK 1.4.7 リリースに伴い、新規作成