Importing SDK into Eclipse
This page is not available in English.
Please select another language.
![]() | 本チュートリアルで作成するサンプルコードは Native Tutorial Sample Download からダウンロードできます。 |
Mobage Native SDK を用いた開発を始めるには、初めにライブラリ等の SDK ファイル一式を Eclipse にインポートする必要があります。この章では Eclipse での新規プロジェクト作成と Mobage Native SDK のインポートの方法、 Mobage Native SDK を使用する為の設定を行います。
Eclipse で新規プロジェクトを作成する
Eclipse を起動すると、上のような画面が表示されます。新しいプロジェクトを作成するために "Package Explorer" 上で右クリックをし "New" -> "Android Application Project" を選択します。
"New Android Application - Create a new Android Application" の画面が表示されるので各項目を入力(または選択)してください。
本チュートリアルでは下記のように入力を行いました。
項目 |
設定内容 |
---|---|
Application Name |
MobageExample |
Project Name |
MobageExample |
Package Name |
jp.mbga.a${MOBAGE_APPLICATION_ID} |
Minimum Required SDK |
API 9: Android 2.3 (Gingerbread) |
Target SDK |
API 17: Android 4.2 (Jelly Bean) |
Compile With |
AIP 18: Android 4.3 (Jelly Bean) |
Theme |
None |
![]() | "${MOBAGE_APPLICATION_ID}" : Mobage のアプリケーションIDに書き換えてください。 |
設定をを行い "Next >" を選択すると "New Android Application - Configure Project" の画面が表示されます。
本チュートリアルでは
- Create activity
- Create Project in Workspace
にチェックを入れて "Next >" を選択すると "Create Activity" の画面が表示されます。
"Blank Activity" を選択して "Next >" を押すと下の画面が表示されます。
"Finish" を選択すると Project が作成が完了します。
以上でプロジェクトの作成が完了しました。
Mobage Native SDK の導入
Mobage Native SDK をプロジェクトに導入します。
Mobage Native SDK ライブラリをインポートする
Eclipse 上 で Mobage Native SDK アプリケーション開発を行うために Eclipse の Android Project にて Mobage Native SDK 関連のライブラリを追加します。"Package Explorer" 上で右クリックをし "Import..." を選択してください。
Import 画面が表示されたら "Android" -> "Existing Android Code Into Workspace" を選択し "Next >" をクリックします。
"Import Projects" 画面に遷移するので "Browse..." をクリックすると、追加するファイルを選択する画面に遷移しますので Mobage Native SDK の "android/MobageNativeAndroid" を選択して右下の "開く" を押します。
再び "Import Projects" 画面に遷移するので "Projects:" で先程選択した "MobageNativeAndroid" にチェックが入っている事を確認し "Copy projects into workspace" にチェックを入れて "Finish" を選択してください。
これで、Mobage Native SDK ライブラリのインポートが完了しました。
![]() | android-support-v4.jar が Native SDK 内のものと競合する場合がありますので、その際はゲーム側の android-support-v4.jar を削除して下さい。 |
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 をインポートしてください。ライブラリの指定も同様です。
Mobage Native SDK ライブラリのリンクを追加する
ライブラリのインポートが完了したら、次にライブラリをプロジェクトにリンクします。"MobageExample" を右クリックし "Properties" を選択してください。
"Properties for MobageExample" 画面が開きますので左ペインの "Android" を選択します。
この時点では "Library" に何も追加されていない状態なので "Library" -> "Add" を選択し、"MobageNativeAndroid" の追加を行います。
"Library" に "MobageNativeAndroid" が追加された事を確認し、"OK" を押して "Properties for MobageExample" 画面を閉じてください。
まだ、この時点では "MobageNativeAndroid" のライブラリが生成されていませんので "MobageNativeAndroid" プロジェクトを右クリックし "Build Project" を選択してください。
以上で Mobage Native SDK ライブラリのインポートが完了しました。
AndroidManifest.xml の編集
Mobage Native SDK の機能をアプリケーションで使用する為に "AndroidManifest.xml" の修正を行います。下記のように AndroidManifest.xml を修正してください。
![]() |
|
![]() | Mobage Native SDK 1.4.7 以降、もし Install Referrer を他の Receiver に転送したい場合は、以下のように記載して下さい。
|
icon ファイル名の変更
AndroidManifest.xml の
で発生するエラーを解決する為に "res/drawable-xxxx" 以下にある "ic_launcher.png" を "icon.png" にファイル名を変更します。
以上で Mobage Native SDK の導入が完了しました。
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
- Install Referrer を正しく取るために com.mobage.android.TrackingReceiver を AndroidManifest.xml に追加しました。
- 2014/07/11
- Google Play Services について追記
- 2013/12/04
- 初版作成