Maven #03 ~ How to create Maven project in IntelliJ

To create a maven project using IntelliJ we can to import: pom.xml file or create a project from scratch.
This post describes how to use this second option.

First, we must to open Wizard and select: Create New Project

From next window select: maven and after that mark: Create from archetype

On the same wizard window select: org.jetbrains.idea.maven.model.maven-archetype-quickstart

On the next window view type GroupId and ArtifactId:

Select Maven home directory:

The last but not least, insert location directory of your project:

The last step is to click Finish button to create a project.

Lv0. VIM user

In the beginning of this post, I asked myself: why Vim and why I would like to cut my fingers? (Joke). An answer to this question is simple: I met with a number of situations in my life where I  actually edit the file on the server or on a specific device connected to the network. But how to do it when there are no possibilities of installing any external text editor?

Everyone has their own toolbox, which is a set of tools that uses in everyday work and even after work. Sometimes it is so that incoming to the company/job anyone could ask a simple question. What tools do you use? So then what you say? In my opinion, either in the work of the tester, programmer or system administrator and any other work related to IT, it is important to know well and use a text editor. And the text editor in both Linux and Unix is Vim. Some will say that the Vi, but for simplicity, I will say that Vi and Vim mean to me almost the same thing.

For the moment someone says, but he is the best Emacs text editor, again, another person can say that Atom is really great. OK, I agree with all the views, but … There are some cons. Especially on any Linux and  UNIX machine. If I log onto the production machine likely I’m will not even have the right to install any additional software but use this one that is already available. Of course, we can look around and see what happens but it will be hard with installing there any additional software. However, we will not use such editors as, for example, nano the text editor is often used on Ubuntu, but Red Hat or CentOS no longer can be a pre-installed editor, which is relatively easy to use.

Vim is free. If we have one machine – our beloved laptop we don’t need to pay for the license. We have 10,000 servers – is still free on each of these machines, there are no hidden costs involved.

The third reason – Vim is super customizable. The ability to install plugins, write your own and the engine itself can not be compared with any paid tool.

Another important thing is that Vim does not require a graphical user interface. Most servers do not have a graphical user interface installed, the X server so inevitably we can not run anything that will allow you to display icons, Eclipse, or are other java-based editors. We can never assume what we have installed on the server.

The last reason: Vim is a fast tool for editing code or editing files. If you’ve ever seen a user who has for several years used the Vim and how he can make changes in the code you were a probably very impressed. There is a competition which aims to see how quickly the participants can do the right things in Vim.

There is one disadvantage, the learning curve but in the end, it is worth it.

Reading logs with ADB: the most useful commands

Reading logs during testing Android applications often force developer or tester to use appropriate tools. One of them is: Android Device Bridge. ADB comes as a part of the standard Android SDK, it provides a terminal-based interface for interacting with your devices with Android file system. Below I added some useful commands that every tester, programmer use during deal with applications every day.

 

Useful commands:

adb locat

– access to Android device logs, direct output to the console

adb logcat -d > [filename]

– this command allows to save logs in a file name you have specified, for example: abd logcat -d Users/user/storage

adb logcat -c - all

– logs on devices are erased, after that you are able to grab logs without unnecessary data

adb logcat -v time

– display logs with specified time

adb reboot

– reboot device

adb start-server

– ensure that there is a server running

adb kill-server

– kill the server if it is running

adb push app /system/sd/app

– push apps from comupter onto device

adb get-state

– prints: offline | bootloader | device

adb get-serialno

– prints: serial-number

adb status-window

– continuously print device status for a specified device

adb remount

– remounts the /system partition on the device read-write

adb reboot [bootloader|recovery]

– reboots the device, optionally into the bootloader or recovery program

adb tcpip

– restarts the adbd daemon listening on TCP on the specified port

adb jdwp

– list PIDs of processes hosting a JDWP transport

adb ppp  [parameters]

– Run PPP over USB.
Note: you should not automatically start a PPP connection. refers to the tty for PPP stream. Eg. dev:/dev/omap_csmi_tty1 [parameters] – Eg. defaultroute debug dump local notty usepeerdns

adb -s [yourdeviceserialnumberhere] shell

– above command will start an interactive shell from your machine, but running on your device

adb shell rm -r /system/sd/app
adb shell rm -r /system/sd/app-private

– deleting existing apps on SD

adb bugreport

– return all information from the device that should be included in a bug report

fastboot oem unlock

– unlock bootloader, making root access possible

fastboot flash recovery

– flash a custom recovery image to your phone

am start -n com.package.name/com.package.name.ActivityName

or:

adb shell am start -n com.package.name/.ActivityName

– starting application using adb tools


Reference:



Starting a Feedbacker project in Android Studio

Starting a new project in Android Studio is a very simple task if we have an idea of course what we want to do. In this post, I will show step by step how to create a simple project using blank activity with fragment.

First, we should run AndroidStudio and then select from the main window: Start a new Android Studio project. After that, we will see a: Configure your new project window:

1

This window allows naming your project, select location of workspace and also set your company domain, for me company domain is: andrzejdubaj.com.

Next screen allows selecting form factors on which app will be running.

2

I select: Phone and Tablets, also: Minimum SDK – API 21: Android 5.0(Lollipop). Why has Android 5.0 Lollipop ? Because I have a smartphone on which I can test my app – physical device, not an emulator and second: I want to build from source Android 5.0 and run in on raspberry pi 2 or 3 version. We will see in the future.

7

On: Add an activity to Mobile allows selecting one from several activities with automatically add necessary file to project, for example, *.xml files. I select a blank activity. If I decided to create some localization app I will choose google maps application.

3

Next step takes us to: Customize the Activity. Way, I choose fragments ? Because fragments allow building an application with behaves somewhat like a nested activity that can define its own layout and manage its own lifecycle. You can read more here.

4
 After pressing on: Finish button we will get build the layout of an application. Basic project structure with catalogs and base classes.
6
 
On this point,  we can start developing the application. Writing code and add necessary files.

aapt on OS X

During launching my tests written in JUnit I notice problem with performing one of them. I received:

java.io.IOException: Cannot run program "aapt": error=20, Not a directory at java.lang.ProcessBuilder.start(ProcessBuilder.java:1048)

In Stack Overflow I found a lot of solutions but non of them didn’t solve my problem. There’s a bug in IntelliJ IDE that points to platform-tools for executable that are in build-tools. I found my own solutions of this problem:

ln -s 23.0.2 build-tools/current
ln -s ../build-tools/current/aapt platform-tools/aapt
ln -s ../build-tools/current/lib platform-tools/lib

This solution works for me. Similar problem appears in Windows and Linux.