Problem:
My current App is called “Shapes!” but I want to change it to something like “Bubbles”.
Solution:
Move and Rename ALL of the files with a reference to “Shapes.” This ended up being more complex than I thought because I wanted to keep my git history. Because of this, I will first post what I did inside the Android SDK. Note, it you are using git, or other Source control, then you will need to do this equivalent moving with your VCS.
Personally I first checked out a new project and did all of the steps below in a clean checkout. I committed all of the changes locally. Second, I checked out a 2nd copy of the project to a new directory, then manually made all of the file moves before I then copied the contents first project to the second. Finally, when everything compiled in the 2nd copy, I pushed it back to the server.
Steps for the Android SDK
In each of the steps below I am simply replacing the word “Shapes” with “BubbleDeluxe”
1) Rename the Game class inside the Android SDK using Refactor (Shift+F6)
public class BubbleDeluxe extends Game {
2) Rename the package in the package explorer using Refactor (Shift+F6)
package com.stonemill.bubble;
3) Manually rename the package in Android Manifest.xml
package="com.stonemill.bubble.android"
4) Manually rename the App Name in srcandroidresvaluesstrings.xml
<string name="app_name">Bubble Deluxe</string>
5) Shapes.gwt.xml – Manually rename the file and the app name
<source path="com/stonemill/bubble" />
6) Manually change the build.gradle script
commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.stonemill.bubble.android/AndroidLauncher'
7) Exit Android Studio
8) Delete the 4 directories
- Build
- .idea
- .gradle
- gradle
Here is a link to a good post on this step. While the question may not be exactly on point, many of the answers go into a lot of detail on synchronizing gradle and the Android SDK.
9) Return to the SDK
10) Choose – Open and Existing Prodject
11) Choose – Use Defaut Gradle Wrapper
12) Launch the Desktop Launcher (it will fail)
a. Go into the Run Configurations and change the Desktop Launcher to user the android assets directory
Bubblessrcandroidassets
b. Rebuild the desktop application
Success!
Change Log from my git Push
I use GitLab as my code repository, ticketing system, and code review repository. On Windows I am still using TortoiseGit. As such, I found this link to help explain how to move files.
http://tortoisegit.org/docs/tortoisegit/tgit-dug-rename.html
Below are all of the files that ended up changing. I only have 5 files that I coded as part of the game. Everything else is part of the LibGDX framework. My files in are in the folder.
src/core/src/com/stonemill/bubble/AbstractScreen.java src/core/src/com/stonemill/bubble/Bubble.java src/core/src/com/stonemill/bubble/BubbleDeluxe.java src/core/src/com/stonemill/bubble/LevelScreen.java src/core/src/com/stonemill/bubble/Settings.java
Change log:
Showing 23 changed files with 89 additions and 90 deletions src/android/AndroidManifest.xml src/android/build.gradle src/android/res/values/strings.xml src/android/src/com/stonemill/bubble/android/AndroidLauncher.java src/build.gradle src/core/src/Shapes.gwt.xml src/core/src/com/stonemill/bubble/AbstractScreen.java src/core/src/com/stonemill/bubble/Bubble.java src/core/src/com/stonemill/bubble/BubbleDeluxe.java src/core/src/com/stonemill/bubble/LevelScreen.java src/core/src/com/stonemill/bubble/Settings.java src/desktop/build.gradle src/desktop/src/com/stonemill/bubble/desktop/DesktopLauncher.java src/gradle/wrapper/gradle-wrapper.jar src/gradle/wrapper/gradle-wrapper.properties src/html/build.gradle src/html/webapp/index.html src/html/src/com/stonemill/bubble/GdxDefinition.gwt.xml src/html/src/com/stonemill/bubble/GdxDefinitionSuperdev.gwt.xml src/html/src/com/stonemill/bubble/client/HtmlLauncher.java src/ios/build.gradle src/ios/robovm.properties src/ios/src/com/stonemill/bubble/IOSLauncher.java