Thought I would compile some info for people since I can’t seem to add anything to the Wiki atm. Hoping this can be used temporarily as a place to add Advice/How To’s until it can be moved to the Wiki: If you have questions, create another topic please Just refer to the particular problem you encounter there.
Changing the Name of Your APK/Application:
- Open your project’s properties and navigate to Application
- Update the title
This has no real effect, however it keeps continuity throughout your app. Actually, this likely renamed the window created to display your app. So, now go change the actual name of your APK:
- Select File View in the left pane of the SDK
- Navigate to the mobile/res/values directory and open the strings.xml file
- There should be a string tag with the following key pair: name=“app_name”
- Replace MyGame with your app’s name and save the file.
- In File view, navigate to nbproject and open the project.properties file
- Edit the value of application.title to reflect your game’s name (unless step 1/2 above altered this for you)
Changing the APK Icon:
- Under the File view of your project navigate to mobile/res and add a “drawable” folder if one does not exist.
- Add you icon file (png)
- Open the Android Manifest file and add the following to your application tag: android:icon="@drawable/<ICON FILE NAME WITHOUT EXTENSION>"
- If you would like multiple size icons, add the following folders:
** drawable-hdpi (should contain the icon named the same at 72x72 pixels)
** drawable-ldpi (should contain the icon named the same at 36x36 pixels)
** drawable-mdpi (should contain the icon named the same at 48x48 pixels)
** drawable-xhdpi (should contain the icon named the same at 96x96 pixels)
Adding a Splash Screen to your app:
- Open Android Main Activity, ether through the Important Files list in Project view or in the File view under mobile/src/<package name>/ directory
- Add the following line to the MainActivity method:
splashPicID = R.drawable.<IMAGE NAME WITHOUT EXTENSION>;
- Add the image the the mobile/res/drawable directory
Compiling Google Play Services and Adding it to Your Project:
First get the api:
- Download the google play services add-on through the SDK Manager under Extras (named Google Play services)
- Copy the directory from where you downloaded it to another location (like JME Projects Folder)
Compile the jar file for use with your project:
- In the directory you copied, there is an android project file.
- In JME’s IDE, open this project
- In the General section of the project properties, there is a list of potential Android target platforms. Select the one you are using for your project by clicking on the list (this is not intuitive at all, as the list looks like nothing more than info… not selectable items)
- Under the Library section, click the checkbox that is labeled: Is Library
- Click Ok and then Clean & Build this project.
This will compile the play services all proper like so you can add it to your project. Now, for that step:
- Open your project’s properties.
- In the Libraries section, click the “Add JAR/folder” button.
- Find and add the jar you compiled above (This can be found in: <COPIED DIR>\libproject\google-play-services_lib\libs\google-play-services.jar
- Modify your Android Manifest by adding the following tags under application:
<meta-data android:name=“com.google.android.gms.games.APP_ID”
android:value="@string/app_id" />
<meta-data android:name=“com.google.android.gms.version”
android:value="@integer/google_play_services_version"/> - Add the following tag to your mobile/res/values/integers.xml file (create it if it doesn’t exist):
<integer name=“google_play_services_version”>4323000</integer> - Clean & Build your project
Adding Play Games Services to Your Project:
- Download the project from: https://github.com/playgameservices/android-samples
- In the following directory, you find java files you will need to add to your project:
** <DOWNLOAD DIR>\android-samples-master\BasicSamples\libraries\BaseGameUtils\src\main\java\com\google\example\games\basegameutils
** Grab GameHelper.java and GameHelperUtil.java and add them to the directory you projects Main Activity is in - In the following directoriy, you find a resource file you will need to add to your project:
** <DOWNLOAD DIR>\android-samples-master\BasicSamples\libraries\BaseGameUtils\src\main\res\values
** Grab the gamehelper_strings.xml into your mobile/res/values folder - Add the following jar from the Adroid SDK folder to your project as a library:
** <ANDROID SDK INSTALL DIR>\adt-bundle-windows-x86_64-20131030\sdk\extras\android\support\v4\android-support-v4.jar
And this is the basics for setting this up.
Adding AdMob Support to Your Project:
- Open your Android Manifest and add the following tag update the application tag:
<activity android:name=“com.google.android.gms.ads.AdActivity” android:configChanges=“keyboard|keyboardHidden|orientation|screenLayout|uiMode|screenSize|smallestScreenSize”/> - After the application tag, add the following tags:
<uses-permission android:name=“android.permission.INTERNET”/>
<uses-permission android:name=“android.permission.ACCESS_NETWORK_STATE”/> - In the onCreate method of your Main Activity, add the following snippet (configure however you like):
[java]
adView = new AdView(this);
adView.setAdSize(AdSize.FULL_BANNER);
adView.setAdUnitId("<WHATEVER AD UNIT ID YOU ARE ASSIGNED THROUGH THE GOOGLE DEV CONSOLE>");
adView.buildLayer();
LinearLayout ll = new LinearLayout(this);
ll.setGravity(Gravity.BOTTOM);
ll.addView(adView);
addContentView(ll, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT));
[/java]
Ok, that’s all I have for now. Will add things as I find them.