January 9, 2020

 

Android Emulator in Docker

Here's what I use for android instrumented tests pipeline: project with Android emulator in Docker image with VNC access. This is new variant of less convenient one (it was forked from Agoda). It wasn't nice to use, but gave me good example. This one is better. Usage:
$ make build-base && make build && make start
. This provides emulator device waiting to run your tests.

PS I am not a big fan of building in docker, however it's possible using avd-base image from same project. I will cover this later.

Labels: , ,

January 8, 2020

 

Android: one ViewModel per view

It's a surprisingly common belief of using one ViewModel class in several views (screens) in modern Android Jetpack-based MVVM architecture style. In reality ViewModel cannot be shared. There're lots of arguments against reusing ViewModel. Most obvious one is that it mixes data processing logics of different screens which increases complexity of implementing and testing of ViewModels.

Do not create huge ViewModels, keep it simple. Yes, it's more classes per view, however your support and development costs are closer to linear in time.

Labels: , , , , ,

December 10, 2019

 

An interview assignment: ML image classifier (WhatsThat app)

Project repository. For how to install app see below "How to install app" section.

WhatsThat app privacy policy:

No user data is collected by app.
P.S. Actually it's completely offline app: contains no networking code at all.

Project summary


Diagram. Data streams overview.

Summary of what's done is below, also see (more in repository readme):

For my own projects I sometimes use non-standard coding conventions for XML (indents = 2 + special attributes order), and some for Java/Kotlin (indent = 2). However for team workflow I believe it's better to use a standards if there's no team decision otherwise. Also for larger teams >5 people it's better to always stick to standards (helps onboarding).

How to install app


Update 10 Dec:
- Implemented unit and instrumented tests
- Added unit test to CI pipeline
- Started adding dockerized android for instrumented tests (problem: server does not provide /dev/kvm, so emulator needs to be tunes to use ARM system image)
- Added user to Jira, Jenkins, Artifactory. Will share credentials tomorrow in a task report.
- Todo: Add Jenkins-slave with kvm to run instrumented tests.
- Todo: Add some general diagrams to show work flow, compose full task report.

Update 9 Dec: 
- Added MVVM with Jetpack to easily bind image classification with UI output
- Added dagger2 to more simple load of components
- TensorFlow model now works fine
- Project repo: https://gitlab.gotalkmobile.com/shamilg1/image-classifier
- Todo: Setup a functional test to be run in Jenkins as pre-build step. I plan to add a dockerized android emulator espresso test
- Todo: Add some general diagrams to show work flow.

Update 7 Dec: 
- Added Jira/Gitlab/Jenkins/Artifactory integrations and set up CI pipeline with CD to Artifactory.
- Added planned tasks to Jira (Kanban-based).
- Basic kotlin CameraX implementation is done.
- Tomorrow todos: set up basic quantized image analysis integration and further experiment with models.

5 Dec 2019. I've got assignment for the interview with a nice startup on ML image classification using existing pre-trained model. The aim of this project is to share my skills and experience in dealing with project, specifically an Android app.

I know almost nothing on the practical side of ML, so I've started reading.
Starting point is link from the assignment: firebase.google.com/docs/ml-kit/. The aim is to create Android app to classify an image like in the HBO's Silicon Valley's "Hotdog or not" app. Nice one, and a good chance for me to try ML.

From what I see like there're several frameworks available for Android from Google (I was surprised on wide range of them!):
  • TensorFlow (for IoT and mobile devices, has pre-trained models)
  • ML Kit
  • CloudVision (google cloud backed only, has first-1000-images-free period)
  • AutoML (this is on training a custom model)

There're some good ML learning materials not tied to specific framework:

TensorFlow
TensorFlow has some pre-trained models listed at: https://www.tensorflow.org/lite/guide/hosted_models. Seems like there's a balance between accuracy and latency (not sure what NNAPI time is).

There's an Android example image classifier example project: https://github.com/tensorflow/examples/tree/master/lite/examples/image_classification/android. I believe this is a good start to not to waste time on boilerplate code. Still I will need to build CI pipelines and I'd prefer at least some end to end tests, at least one or two.

I've decided to create a public repo project at my own gitlab's instance as I've all the required CI integrations set up already.

As a first step I'm going to try the TF Android example app with some pre-trained tensorflow-lite model.
From what I can compare now TensorFlow lite fits the task, although if it's not I'll switch to next (CloudVision seems to be a good next step to try). In the next posts I'll share some technical decisions made on this project (like CI, repo, tests, etc.).

Labels: , , , , , , , , , , ,

April 23, 2019

 

Upgrading Android project to Studio 3.4

Upgrade involves:
  1. dependency versions chain upgrade: studio -> gradle plugin -> kotlin version
  2. solving mysterious problems with desugaring D8 (add "android.enableD8.desugaring=false" to gradle.properties)

I'm not very happy when I'm unexpectedly forced to spend 3h+ on infinite chain of tasks. This repeats itself for most of the Android Studio upgrades.

Labels: , , ,

March 15, 2019

 

Android "DataBindingComponent not found" error solution

In case while building there's flood of "symbol not found: DataBindingComponent" errors (which are fake), try to increase max number of errors with adding javacOptions after dataBinding into app gradle file:
    dataBinding {
        enabled = true
    }
    kapt {
        javacOptions {
            // Increase the max count of errors from annotation processors.
            // Default is 100.
            option("-Xmaxerrs", 500)
        }
    }

Labels: , , , , , , ,

August 28, 2018

 

Android emulator window @xfce does not gain keyboard focus

In order to fix it open Settings -> Window Manager Tweaks -> Focus tab -> select the Do nothing (When a window raises itself)

Labels: , , , ,

May 8, 2016

 

Software documentation

Recently I don't see almost any diagrams in software docs. It seems like the nowadays developers cannot also create any ascii-graphics like this BufferStrategy class doc written 10+ years ago. None of such I've seen in Android docs (point me out to any please?).

Moreover some talented developers seems don't want to document at all. Check out this one, very complex UI behaviour class AppBarLayout.Behavior. It says: "The default AppBarLayout.Behavior for AppBarLayout. Implements the necessary nested scroll handling with offsetting." That's all. What exactly is necessary?

Yes, I've heard many times that mantra of idlers "code source is the best documentation for itself". Without docs it requires sometimes hours or even days to know all the nuances of implementation. In total it requires additional man*years if some popular framework is poorly documented and decreases overall experience of developers and users for using such piece of technology.

So my friend, let's start documenting the sources we write with something more than the usual "f%ck off I'm busy"-style docs and comments that we see in so many docs by adding the details of implementation and side effects. And diagrams!

Labels: , , , , , , ,

December 4, 2014

 

android market -> play and back

Last week I downgraded Google Play using "Uninstall updates" button (on android ver 2.3.4), so I got fast Market app back (v. 2.3.4). Old Market app worked good and installed apps without problems, but when I needed to test In-app-billing, it for sure did not work :-) (Google requires ) So I tried to force it autoupdate (usually Market and Play apps updated automatically). I even installed all-hated Google Services Framework and Play Services, hoping that they will help Market to autoupdate. They did not. I followed recommendations to clear Market cache and data, but it only cleared list of "My apps". $%$#$&!

So the only way was to manually update Market to Play. As this is original apk signed with Google keys, all went OK. IAB working now.

Labels: , , , , , , , , , ,

April 3, 2012

 

Android: multiple logons breaks C2DM (android push)

If you have same main account on more than one android device, C2DM delivery will only work for last logged in device (seems that google acc logon happens on system restart). This is a problem for testing park devices for which is hard to create and support unique google accounts :-(

Labels: , , , , ,

April 1, 2012

 

android: rotate 3d animation

Just another bookmark:
http://developer.android.com/resources/samples/ApiDemos/src/com/example/android/apis/animation/Rotate3dAnimation.html

http://stackoverflow.com/questions/3452687/better-implementation-of-rotate3danimation-in-android-viewflipper

Labels: , , ,

 

Android: progress bar updating solution

just a bookmark for myself
http://www.helloandroid.com/tutorials/progressbar-updating-using-message-handler

Labels: , , ,

November 1, 2011

 

SonyEricsson sk17i (mini pro) en hw keyboard layout FIX

Please note that I've tested this XML patch only for russian hw keyboard.

FN-keys in cyanogen-mod are awful (especially on russian version kb) and no fix from xda-developers forum works!
So I've finished manually edited english layout file (FN-keyboard section) which you can download:
qwerty-en.xml
You should move it using root explorer to
/system/usr/keyboard-config/layouts/

then change owner to root (id=0) and group to root (id=0) and change permissions to RW-R--R-- and restart phone.

Don't forget to backup original file and, by the way! I'm not responsible for any side effect ;)

Labels: , , , , , ,

March 16, 2011

 

some mobile smartphones impressions

This is not full coverage nor review, just some key impressions just for me.

Windows 7 phone (Lg E900):
- ugly ui, but surprisingly very useful :-) usability on high grade, seems designers were not allowed to give any recommendations :-))) This is the way, ppl!
- Very small number of apps: does not have any ssh/telnet terminal in marketplace
- search in marketplace gives artists, songs and albums instead of APPS! go to hell with all that paid bad music :-) i can make noise myself on guitar :)))

Android (HTC G1, HTC Desire Z):
- [android all] every app want access to everything (no way to manage permissions as it is for J2ME)
- very small (desire z) text
- it is not phone, nor SMART: messaging takes TIME to load! Every simple phone (from nokia 1100 up to sony ericsson k750) loads sms inbox very fast, to call one just start typing number. But in android you first FIND phone app... then wait it to load :-) suxx
- samsung galaxy tab: it HAS GPRS via SIM card, but does not have phone app and no way to install it without root-ing and firmware replace.
- Android officially is open-source, but very closed still (no access to ussd, no way to install native apps without rooting)
- by the way, every app with permission for messaging can read ALL incoming sms!
- NO GOOGLE EARTH FOR GOOGLE PHONE?! WTF!

iPhone:
- same as android trouble with finding 'phone' app, slow messaging load
- good screen for iphone 4 (ips matrix)
- closed proprietary platform: recently apple stopped posting security updates to iphone 3G. "Don't hold it..." ...anymore. Buy new one?!

Labels: , , , ,

January 28, 2011

 

android dev: '?????? no permissions' trying to deploy to samsung galaxy tab

--
Update: this works until device disconnect only. After reconnect IDE could hang up :-)
Update: added string for HTC Desire Z
--
Ubuntu 10.04/android sdk 7(9? where the f%%k is sdk version? no version in readme! opensource sometimes is such an opensource.)

When you see such f%%% sh%%%:
./adb devices
List of devices attached
???????????? no permissions


To be able to deploy to samsung galaxy tab do the following:
1) create new file (51 is just some number below 99):
sudo vi /etc/udev/rules.d/51-android.rules
and put there:
SUBSYSTEM=="usb", SYSFS{idVendor}=="04e8", MODE="0666"
SUBSYSTEM=="usb", SYSFS{idVendor}=="18d1", MODE="0666"

04e8 is samsung id
18d1 is for HTC Desire Z
2) restart adb daemon:
sudo ./adb kill-server
sudo ./adb devices
you now should see this:
* daemon not running. starting it now on port NNNN *
* daemon started successfully *
List of devices attached
10001c18352d device

If above still doesn't help add more detailed description for usb device in 51-android.rules like this

SUBSYSTEMS=="usb", ATTRS{idVendor}=="0bb4", ATTRS{idProduct}=="0c91", MODE="0666"

here 0c91 is the HTC Desire Z product id. You can watch these details using 'lsusb' command:

Bus 002 Device 011: ID 0bb4:0c91 High Tech Computer Corp.

Labels: , , , , , , , , , ,

February 4, 2010

 

Android G1: more surprises

When I put another operator's SIM card into G1 immediately I started to receive strange SMS (every minute!) from short number 684 with text "Service is temporarily unavailable". A little investigation shows that 684 is operator's aggregation paid short number (operator provides some paid SMS services via that number). More: any outgoing SMS to that number cost $0.16.
So, G1 usage cost $0.16 per minute.
It's of course not so bad as downloading Android updates via 3G (which ate 5$ in 3 minutes for me when I first switched G1 on). But: sending some SMS to network without my permission is not good.
Note that this is not some third-party app: I check every app when installing for permissions and I'm sure that nothing was set up with SMS sending permission.
Some threads (english translation) indicate that this is because G1 has some low-level T-mobile locks (although mine is officially unlocked one from singapore).
By the way, user has no way to officially way to rebuild and reflash its (open-source!) android OS.

Labels: , , ,

July 27, 2009

 

[life] iphone -> iSkype-on

Yesterday I tried to call through wifi via skype using iphone client. Works great, talked for more than 15 minutes and quality is just like when using GSM! Also tried to install the Android skype client, but is said that I MUST enter my phone number and it will (WTF?!) be used when calling (all calls are paid, it said! callback?). Seems that Skype beta in Android is very strange thing: it cannot use 3G/Wifi connection for free skype2skype calls. Yes, just found quote from comments from here: http://share.skype.com/sites/skypegear/2009/01/video_skype_lite_on_android.html
Sad that receiving any phone calls, even from a skype caller, skype credit is used.
and more:
No calls can be made, no free calls received even when in WI-FI spot. This application is not ready for prime time ... If I wanted to IM, I would use another application. Please make Skype like it is on computers. Free calls computer-to-computer (or phone-to-skype_contact) over wifi or carrier's data plan.
Else is is useless.

This is it. iPhone is better :-)

Labels: , , , ,

This page is powered by Blogger. Isn't yours?