Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Change package identifier of libGDX game

I have an existing game in google play store. The existing version was developed fully using Android Studio using native codes. Now I am about to release a highly enhanced version of the same game in play store, but this time, the application is developed using libGDX. The problem is my application's original package name was com.myname.mygame(some confidentiality issues in revealing the real name). I gave the same package name for libGDX base project. But when it is compiling in android, it is adding a .android extension to the package name. So the package name now becomes com.myname.mygame.android, due to which I can't release the app as an update. What can I do to change the package name?

EDIT

As per one of the answers posted here, I tried changing the package name of core module fromcom.myname.mygame to com.myname.mygame.core, then changed package in manifest to package="com.myname.mygame" and moved AndroidLauncher from com.myname.mygame.android to com.myname.mygame. But now I am getting the following error when I try to run the app:

Installing com.myname.mygame.android
DEVICE SHELL COMMAND: pm install -r "/data/local/tmp/com.myname.mygame.android"
pkg: /data/local/tmp/com.myname.mygame.android
Success


Launching application: com.myname.mygame.android/com.myname.mygame.AndroidLauncher.
DEVICE SHELL COMMAND: am start -n "com.myname.mygame.android/com.myname.mygame.AndroidLauncher" -a android.intent.action.MAIN -c android.intent.category.LAUNCHER
Starting: Intent { act=android.intent.action.MAIN cat=[android.intent.category.LAUNCHER] cmp=com.myname.mygame.android/com.myname.mygame.AndroidLauncher }
Error type 3
Error: Activity class {com.myname.mygame.android/com.myname.mygame.AndroidLauncher} does not exist.

I noted that it is still written there are com.myname.mygame.android and the application fails to launch.

like image 786
Harikrishnan Avatar asked May 25 '15 11:05

Harikrishnan


People also ask

How to generate a project from libGDX?

Click the Generate button and Libgdx Project Generator does all the routine work for us. Once the project was generated you can open it in your favorite IDE (I am going to use Intellij IDEA. You can use Eclipse, IDEA, NetBeans, or Android Studio for instance).

What file formats are supported by libGDX?

Note: libGDX supports MP3, OGG and WAV files. Which format you should use, depends on your specific needs, as each format has its own advantages and disadvantages. For example, WAV files are quite large compared to other formats, OGG files don’t work on RoboVM (iOS) nor with Safari (GWT), and MP3 files have issues with seemless looping.

What is array class in libGDX?

The Array class tries to minimize garbage as much as possible. libGDX offers other garbage collector aware collections such as hash-maps or sets as well. We’ll store the time in nanoseconds, that’s why we use a long.

How to describe a bucket and raindrop in libGDX?

So, to describe both the bucket and raindrops we need to store their position and size. libGDX provides a Rectangle class which we can use for this purpose. Let’s start by creating a Rectangle that represents our bucket. We add a new field: In the create () method we instantiate the Rectangle and specify its initial values.


1 Answers

Thanks a lot to Saeed's answer, I was able to do it, but there was one more thing I needed to do for making the app to work after changing the package name. I am explaining the steps here:

  1. Change package name of core module from com.myname.mygame to com.myname.mygame.core
  2. Change package in manifest to package="com.myname.mygame"
  3. Move AndroidLauncher from com.myname.mygame.android to com.myname.mygame

The above steps solved the problem of changing the package name, a big thanks to Saeed. Now the application was failing to launch. Then I saw that the installation command was wrong. To change this, just go to the android application's build.gradle and change the following line:

commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.myname.mygame.android/com.myname.mygame.android.AndroidLauncher'

to:

commandLine "$adb", 'shell', 'am', 'start', '-n', 'com.myname.mygame/com.myname.mygame.AndroidLauncher'

And you are ready to go!!!

like image 74
Harikrishnan Avatar answered Sep 17 '22 23:09

Harikrishnan