Archive for May, 2020

07
May
20

Version 2.0 (And 2.01) released for Android

Last summer, Google dropped the support for Google Cloud Messaging and now demanded only the usage of Firebase Cloud Messaging to send and receive notifications to an app.

Now, one could think that it just would be a matter of implementing Firebase then? Well, unfortunately RummyFight-Android was created using Eclipse and Firebase can only be implemented using Android Studio which meant I had to migrate the whole project to Android Studio.

Of course the automatic migration would not work since it’s such a complex project so the only way for me to succeed was to create a blank project in Android Studio and import piece by piece into it, adjusting every part of the source and resources to work in this new environment.

If that wasn’t enough, I had to do something about my usage of AndEngine. It’s a 2D graphics library that I had always used for all the dragging, dropping, updating of the interface etc. In the old RummyFight I used AndEngine GLES1 (For OpenGL 1.0) and of course that doesn’t work in Android Studio. However there exists a GLES2 version (For OpenGL 2.0) that could be hacked into working so I tried that and actually succeeded.

A lot of things had changed in the GLES2 version though so I needed to go though all code and redesign a lot and also re-invent the wheel some since a few functions was removed. That is the reason for the Fireworks looking different in v2.0. The particle system had changed a lot since GLES1 so I had to create a completely new fireworks solution.

I also had to change a lot regarding the fetching of profile pics and theme backgrounds to make them work in GLES2.

But eventually the app finally compiled and I could start testing it… realizing there were yet a lot of things to fix.

One of them was the popup of dialogs. GLES1 ran on uiThread but GLES2 on backgroundThread meaning that if someone clicks on a player name, the app would crash when opening the profile dialog since it MUST be opened on the uiThread.

So I had to find all places where i open a dialog and surround the code with

runOnUiThread(new Runnable() {
    public void run() {
        OpenTheDamnDialogHere();
    }
});

What I then believed was the last step to do was to make the app accepted by Google Play which meant creating new, larger icons it it to take into account that newer phones and tablets with higher resolutions have been released the last 4 years. That included app icons, notification icons etc. Apparently app icons should be round now, not square… but still needs to be square if the app is installed on an older device.

Notification icons I said? Hmmm… Oh, new rules from Google. They must be black and white only now if you use a modern device. Ok, draw a new one black&white then and include code to distinguish what Android version are used and select the appropriate icon.

And while on the topic of notifications: Firebase supports two types of messages: Notifications and data. However if I send a notification message to RummyFight while it’s in the background, the receiving device will only play the standard notification sound. Since there is an option in RF-Settings to select your own sound I wanted that function to be kept which meant that Data-Message what the way to go and give all the logic to the app instead of the system.

Then, of course I had to change in the server how these messages were sent to the devices but at last I got it working.

Ok, back to releasing it to Google Play.
Create APK, upload it, all looks good… then a BIG WARNING:
“The app uses READ_PHONE_STATE – This is not recommended”

What? It does not!!!

Actually it was a bug in Android that added this permission by itself but I found a solution that worked. I added READ_PHONE_STATE in the code and then immediately removed it efterwards, hehehe 🙂

New upload – rejected since not all parts of the app was 64 bit code. What??? I thought all java would compile into 32 and 64 bit automatically? Yes, but there were parts of andEngine that was only 32 bit. Luckily some nice people on the net had managed to create 64 bit libraries of andEngine that I could import and finally the app was accepted by Google.

They informed me a release could take up to 7 days to be accepted so I started working on other things but already after 18 hours the new version was live… and it crashed hard!

After some debugging and looking at crash reports I realized that this only happened on Android 9 and 10. Seems that the http object used in the app to fetch info from the servers is totally ok to use up until Android 8. From 9 and forward another object must be used… or at least explicit support for the old version must be stated.

I stated!
<uses-library android:name=”org.apache.http.legacy” android:required=”false”/>
and also added a policy saying that http requests to *.rummyfight.se is allowed, not only https.

Then I submitted v2.01 and keeping my thumbs really hard it will work this time.

Damn it’s difficult to maintain a 8 year old project where the latest release was done 4 years ago.




Categories