Month: August 2014

Publishing Android application in Google Play Store

2014-08-31 Android, Google, Play No comments

Introduction

When you want to publish your Android application in Google Play Store, first you need to go to https://play.google.com/apps/publish/ website and create a Developer account. Its cost is $25. You can read more about that at: https://support.google.com/googleplay/android-developer/answer/113468?hl=en.

Problems with payments during registration

Remember that you need to have appropriate debit card in order to proceed with payments. E.g. I have debit card in PKO BP (Polish bank), which has two-stage authorization. Most of debit cards has two-stage authorization for the registration of the card in on-line payment system and next payments are verified only once. In my bank every payment is verified twice. It’s more secure, but due to this security policy I was not able to pay for my developer account at all! I decided to create another bank account for on-line payments in bank, which has one-stage authorization for regular payments. I’ve chosen mBank (another Polish bank). Finally, I was able to proceed with payments and create my developer account.

Developer Console

When you have your developer account created, you can access Developer Console with your Google credentials.

all_applications

When you create your application, you can choose it from the list of available applications and you can manage several sections.

google_play_chosen_app

You don’t have to to everything in one session, you can save a “draft” of your application and fill rest of the elements e.g. next day.

APK

Preparing APK file to upload

Before we publish our app in Google Play Store, we need to generate signed *.apk file. In Android Studio, we can choose Generate Signed APK... option from Build menu.

generate_signed_apk

If we don’t have our key store, we need to create one.

create_new_keystore

Very important: We need to remember or save somewhere our key store password and alias password (they can be the same). We also need to save somewhere (in a few different places) our key store file. Key store file, key store password and alias password are necessary for signing app. If we want to update uploaded app in the future, we need to sign it with exactly the same key store file and we need to know mentioned passwords to perform sign operation. Passwords can be changed, but we need to know old passwords to do it. When we will sign our app with a different key store file, we won’t be able to update our app after uploading.

Next, we need to set master password.

master_password

After that, we can click Next and finalize generating *.apk file. In this step, we can optionally run ProGuard.

generate_apk_proguard

If everything went ok, we should see the following window.

apk_generated

Now, we are ready to upload our *.apk file to Google Play Store.

Uploading APK file

In APK section you can upload your application compiled into *.apk file to Google Play Store.

apk_section

You can also set up Beta testing or Alpha testing and distribute your app to selected group of testers.

When, we uploaded our *.apk file, application is marked as “Draft”.

publishing_app_01

We need to provide all mandatory information in several sections.

When, I filled everything, my application was still a “Draft”. I could display message “Why can’t I publish?” and see details.

why_cant_i_publish

I needed to go to “Pricing and Distribution” section and check mandatory fields.

pricing_and_distribution_agreements

I also needed to mark checkbox Not submitting a privacy policy URL at this time. in “Store Listing” section (“Privacy Policy” subsection).

Store listing

Basic information

In store listing, you need to provide basic information about your app.

store_listing_basic_info

Graphic assets – screenshots

Next, you need to provide screenshots of your app. Screenshots for the phone are necessary, but screenshots for the tablets are optional.

graphic_assets

Graphic assets – Hi-res icon, promo images & video

Then, you need to provide promo images & video. Two options are mandatory.

promo_images

Categorization, Contact Details & Privacy Policy

Next, we can categorize our app, set up Contact Details and Privacy Policy if it’s necessary. If we don’t have Privacy Policy, we need to check the field Not submitting a Privacy Policy URL at this time.

categorization_contact-details_privacy_policy

Translations

We can manage translations and prepare different description, application name, screenshot and other details for different languages. In my case, I prepared description and screenshots in Polish and English language versions.

google_play_translations

Pricing & Distribution

In this section you can provide information about distribution. You can determine whether your app will be available all-around the world or only in selected countries. You can also determine if it will be free or paid.

pricing_and_distribution

In-app Products

We are able to create in-app products. Application, which I was publishing does not have such feature. You can read more about that at: http://developer.android.com/google/play/billing/api.html

Services and APIs

In this section, you can set up Google Cloud Messaging (GCM), Licensing & In-app billing and Google Play Game Services. Here you can get license keys and link your mobile app with server application if it’s neccessary. There is also feature called App Indexing from Google Search, where you can deep link into your app from Google search.

Optimization tips

Here you can see some optimization tips from Google, which you can apply for your app, to make it better.

Launch checklist

Don’t forget to browse Google’s Lauch Checklist.

Ready to publish

After proving all the information, my application was finally ready to publish!

ready_to_publish

I could click Publish this app button and deploy my application to Google Play Store.
After that, my application was marked as Published on the list of the applications. It’s worth mentioning that applications are not available on Google Play Store immediately after publishing, but within a few hours. I was informed about that after clicking the Publish this app button.

app_published_waiting

You can see that my app was successfully published. You can download it at:
https://play.google.com/store/apps/details?id=com.pwittchen.eeganalyzer.
It’s specific application reading brain waves from NeuroSky MindWave Mobile device, so you need to have such device in order to use this app. It can be connected via Bluetooth to the Android smartphone or tablet.

Last words

Information provided in this article does not cover all functionalities and possibilities of Google Play Store. If you want to learn more, please read official Google’s websites.

Package by feature, not layer

2014-08-31 Java, Software Architectural Patterns, Software Development No comments

The first question in building an application is “How do I divide it up into packages?”. For typical business applications, there seems to be two ways of answering this question.

Good article concerning mentioned topic can be found at: http://www.javapractices.com/topic/TopicAction.do?Id=205.
It’s worth reading, so check this out. Maybe it’s not too late to apply that idea in your project?
Read about more Java practices at: http://www.javapractices.com/.

Stuff you should know about Android

2014-08-29 Android No comments

Today I had talk at Future Processing about Android. It was part of company’s Java show & tell series. I wanted to make it interesting both for people without any experience with Android development and for people who already know something about this platform. Presentation was divided into three main parts:

  • Basics
  • Challenges
  • Techniques

Below, you can browse slides from the presentation.

Of course, slides does not show everything I prepared, but they are good summary of the talk. I hope you find it interesting and useful.
Feel free to give me any feedback about the presentation (especially if you attended it in person. ;-)) !

Reading/writing generic Java objects to JSON files and vice versa

2014-08-27 Android, Java No comments

Overview

Recently, I have written small set of methods for a FileHelper using Jackson library in Android application, which allows to save generic Java objects and list of generic objects in JSON format to a file and read them back in the original form. In the beginning I had some problems with saving and reading data properly. I could save and read data (e.g. list of the objects), but their type was LinkedHashMap, which wasn’t the list of desired generic objects. After adjusting Jackson library, I finally achieved my goal. You can see helper class below.

Helper class

Usage

You can use this helper in the following way:

NetworkEvents – Android library

2014-08-19 Android, Java No comments

Please note: This post is outdated. Check newest API on the GitHub.

Introduction

NetworkEvents is an Android library, which I’ve created recently for one of the projects. It uses Otto Event Bus to support event driven programming. We can use appropriate annotations and perform any action, when connectivity status changes. E.g. when device will go offline, connects to the mobile network, connects to the WiFi network, connects to the WiFi network with Internet access or connects to WiFi network without Internet access. Android API does not allow to determine whether specific WiFi Access Point is connected to the Internet, but this library does. In addition, we can monitor change of the signal strength of available WiFi Access Points in the same manner as connectivity status.

Where can I get it?

NetworkEvents library is open-source and available on GitHub at: https://github.com/pwittchen/NetworkEvents.
You can clone this repository and see how it works. It contains sample project using library module dependency.
Network Events library is placed in separate module. Android Studio is recommended IDE.

How to use it?

1. Initialize EventBus and NetworkEvents

You can do it in onCreate() method of the activity in case of using library in activity.

2. Register/Unregister EventBus and NetworkEvents

3. Subscribe events

We can subscribe two or just one event. It depends on our needs.
The following events are available:

  • ConnectivityStatusChangedEvent
  • WifiAccessPointsSignalStrengthChangedEvent

Subscribing events is simple. Look at the code below.

That’s it! For more details, check NetworkEvents project on GitHub at: https://github.com/pwittchen/NetworkEvents
README.md file also contains some details.

Remarks

EventBus and NetworkEvents can be accessed via Singletons to avoid multiple instances of these classes.

Software for common users on Ubuntu

2014-08-18 Linux, Ubuntu No comments

In this article, I’ll describe Ubuntu software for common users, which I personally use and which could be helpful on daily basis.
Ubuntu software dedicated to programmers AKA developers will be described in separate article.

Chrome

In my opinion, it’s currently the best web browser. We can download, unpack and install it, with the `owing commands:

sudo apt-get install libxss1 libappindicator1 libindicator7
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome*.deb

Skype

Maybe it’s not the best, but one of the most known messengers and lot of people use it. In addition, at my work people currently use it as a common messenger. We can download and install it with the following commands (first command adds new software repository, from which Skype can be downloaded):

sudo add-apt-repository "deb http://archive.canonical.com/ $(lsb_release -sc) partner"
sudo apt-get update
sudo apt-get install skype

Spotify

After I started using Spotify, I stopped keeping all my mp3s on the hard drive. Of course, it has pros and cons, but for now I think that Spotify is good choice for people who like to listen to the music quite often. In addition, premium version is quite cheap. We can download and install Linux version of the Spotify with the following commands:

sudo sh -c 'echo "deb http://repository.spotify.com/ stable non-free" > /etc/apt/sources.list.d/spotify.list'
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys 94558F59
sudo apt-get update
sudo apt-get install spotify-client

Disabling notifications after starting new song
Notifications, which appears after starting new song are enabled by default. They are annoying for me, so I decided to turn them off.

I’ve edited file: ~/.config/spotify/Users/[Spotify user name]/prefs
and set ui.track_notifications_enabled=false. After that, I restarted Spotify and notifications disappeared.

Dropbox

Dropbox is great software. I often use it to backup my files and when I want to access specific files on different devices. We can install it with the following command:

cd ~ && wget -O - "https://www.dropbox.com/download?plat=lnx.x86_64" | tar xzf -

After installing, we can launch Dropbox with the following command:

~/.dropbox-dist/dropboxd

We can execute the following command to run Dropbox in the background even if we close terminal:

nohup ~/.dropbox-dist/dropboxd

Unfortunately, Dropbox is not launched on autostart after rebooting computer, so I installed additional software, which runs Dropbox in the background on startup and displays indicator icon. I just typed the following commands:

sudo apt-get install libappindicator1
sudo apt-get install nautilus-dropbox

Deluge

Deluge is lightweight torrent client similar to uTorrent and BitTorrent. We can install it by typing the following command:

sudo apt-get install deluge

Transmission

Yet another light torrent client. Install it with:

sudo apt-get install transmission

Java

Many programs are written in Java, so if we want to use them, we have to have Java Virtual Machine installed on the system.
Using Oracle Java 7 is not formally supported by Ubuntu. There’s plenty solutions for installing it, listed on https://help.ubuntu.com/community/Java.

The simplest one listed is this one:

sudo add-apt-repository ppa:webupd8team/java
sudo apt-get update
sudo apt-get install oracle-java7-installer

It’ll keep your java 7 installation up to date.

To automatically set up the Java 7 environment variables JAVA_HOME and PATH:

sudo apt-get install oracle-java7-set-default

Enabling global menu (HUD) support in Swing applications

Some Java Swing applications do not support global menu (HUD) available in Unity environment enabled by default in Ubuntu.
This problem occurs often in applications for software developers like IntelliJ IDEA, Android Studio, PyCharm, Netbeans, etc. but it may also occur in any Swing application. We can enable this menu by installing jayatana in the following way:

sudo add-apt-repository ppa:danjaredg/jayatana
sudo apt-get update
sudo apt-get install jayatana

Source of this solution: http://www.webupd8.org/2014/02/get-unity-global-menu-hud-support-for.html

Wine

Wine is a software, which allows to run some MS Windows applications on Linux. For sure it works with Adobe Photoshop CS2. We can install it with the following command:

sudo apt-get install wine

Gthumb

Small and useful image browser and editor. Use the command below to install it.

sudo apt-get install gthumb

Pinta

Pinta is simple, lightweight image editor. We can install it with the following command:

sudo apt-get install pinta

Furious ISO Mount

Furious ISO Mount is application similar to Virtual Clone Drive or Daemon Tools available on Windows, which allows us to mount images of the CD into virtual drive. We can install it in the following way:

sudo apt-get install furiusisomount

Virtual Box

Virtual Box allows us to use virtual machines and install on them e.g. MS Windows 7, 8, different Linux distributions or any other operating system and use it in dedicated sandbox. We can install it with the following command:

sudo apt-get install virtualbox

Gedit

Gedit is simple, but very good text editor and a little bit enhanced notepad. It’s available on Ubuntu by default, but in case you don’t have it, use the following command to get it:

sudo apt-get install gedit

Clementine

Ubuntu has one music player installed by default. It’s called Rhythmbox. It looks ok, but it had problems with playing my mp3 files. Problem could be connected both with the drivers and this software. I decided to try another lightweight music player called Clementine. It’s small, configurable and works fine with my mp3s right after installing. Use the following command to download and install it:

sudo apt-get install clementine

VLC

VLC is one of the best video players for MS Windows and Linux. You should have it if you want to play your videos without problems.
Use the following command to install VLC:

sudo apt-get install vlc browser-plugin-vlc

Drivers for Logitech H760 Wireless Headset

I am using Logitech H760 Wireless Headset and it does not work on Ubuntu by default.
In order to bring it to work we have to install additional software in the following way:

sudo add-apt-repository ppa:ubuntu-audio-dev/ppa
sudo apt-get update
sudo apt-get dist-upgrade -y

After connecting headset receiver, I had to change output of the sound and input of the microphone to my headset in system settings. Previously it was set to loud speakers. After switching back to loud speakers, I have to change output of the sound to speakers to hear sound in the speakers. It’s quite inconvenient, but I don’t know, how to automate it. In MS Windows it switches automatically without additional drivers or additional operations, so probably manufacturer should take care of this in case of Linux OS.

Something else?

I guess I listed most of the common Ubuntu software I use (besides of course Terminal, System Monitor and programming tools ;-). If you know any useful software, which wasn’t listed here, write about it in comments below this article. I would be happy to update this post.

Ubuntu system boot problem

2014-08-17 Linux, Ubuntu 4 comments

Description of the problem

Recently, after installing Linux Ubuntu 14.04 LTS on my computer, I encountered strange problem during the system boot. Before system launched, I received the following message:

After that, I typed: exit and system started normally, but this error occurred every time after reboot, so I decided to fix it.

Fixing the problem

Attempt #1

First, I tried to change rootdelay as error message said. I opened file /etc/default/grub
I found there the following line:
GRUB_CMDLINE_LINUX_DEFAULT="quiet splash"
and changed it to:
GRUB_CMDLINE_LINUX_DEFAULT="rootdelay=90 quiet splash"
rootdelay became longer, but unfortunately it didn’t fix the problem in my case.

Attempt #2

I edited /etc/fstab file. I executed the following command in terminal: sudo gedit /etc/fstab and edited fstab file in gedit. In the beginning my file looked like that:

Then, I commented one line and added another one describing /dev/sda1 disk device. Now, my file looks as follows:

Problem still existed, so I tried another attempt to solve it.

Attempt #3

I opened terminal and typed the following command:

sudo grub-install /dev/sda

and then I typed another command to update grub:

sudo update-grub

After all of this, I rebooted computer and finally, error disappeared and problem was fixed!

Note #1

After removing rootdelay from the /etc/default/grub file, everything still works fine.

I was struggling with this error for some time, so I am very happy that I managed to fix it. I am a Linux n00b, so If you know any better or more efficient solutions to fix it, I will appreciate all of these.

Note #2

I’ve found another attempt (work-around) for this problem.
You can get rid of the described problem with the following commands.

sudo sed -i 's/maybe_break mount/sleep 5\nmaybe_break mount/g' /usr/share/initramfs-tools/init
sudo update-initramfs -u

For more details check this thread.