Android Crash Fix: Firebase_admob (0.6.1+1)

The bug is described in issue #23102.

The cause can be backtracked to the latest Google Mobile Ads SDK change (v.17.0.0): https://ads-developers.googleblog.com/2018/10/announcing-v1700-of-android-google.html

The temporary fix when using firebase_admob (0.6.1+1) is to add your AdMob app ID to the AndroidManifest.xml of your flutter project:

1
2
3
4
5
6
7
8
<manifest>
<application>
<!-- TODO: Replace with your real AdMob app ID -->
<meta-data
android:name="com.google.android.gms.ads.APPLICATION_ID"
android:value="ca-app-pub-################~##########"/>
</application>
</manifest>

Flutter vs React Native

Summary: This week we’ll be looking at a comparison between two open-source mobile application frameworks, namely React Native and Flutter.

Mobile development is nothing new, you usually use native solutions à la Java/Kotlin (Android) or Objective-C/Swift (iOS). Cross-platform doesn’t have to be like this though, React Native and Flutter will help you with maintaining just one code base! There are other similar cross-platform frameworks available, but today we’ll be focusing on these two only, as I have written and published Apps with both frameworks already.

I have decided to do weekly TL;DR comparisons for software and hardware choices. This week we’ll be looking at a comparison between two open-source mobile application frameworks, namely React Native and Flutter.

Introduction

Mobile development is nothing new, you usually use native solutions à la Java/Kotlin (Android) or Objective-C/Swift (iOS). Cross-platform doesn’t have to be like this though, React Native and Flutter will help you with maintaining just one code base! There are other similar cross-platform frameworks available, but today we’ll be focusing on these two only, as I have written and published Apps with both frameworks already.

Quick Facts

FlutterReact Native
backed byGoogleFacebook
programming languageDartJavaScript
first release20152017

Performance

React Native: JavaScript communication to native code via bridge.

Flutter: Dart code is compiled into a native, ARM library.

Generally Flutter should have the upper hand when it comes to performance.

SSH and Port Knocking

It turns out that SSH brute-force attacks, dictionary attacks or combinations of those are daily routines nowadays. Server logs are quickly filled with login attempts, in the hopes that one of them is right. The best prevention against these kind of attacks is to - obviously - have a secure password, or even better to force key-based authentication.

However, this won’t stop automated attacks from trying out dozens of usernames and passwords anyway, which is generally annoying. Thus, the approach to hide the SSH port, which by default is 22. One solution some people do is moving SSH to a non-standard port. Basically, some random number that won’t conflict with anything else.

Another interesting trick is to not immediately expose the SSH port, but only when a client is saying “Open Sesame”. Jokes aside, that’s roughly what port knocking allows us to do. There are many variants on port knocking and many programs that implement it. The following tutorial will use knockd as port-knocking server.

Install Prerequisites

Download and install the knock-server rpm package:

1
2
$ wget http://li.nux.ro/download/nux/misc/el6/i386/knock-server-0.5-7.el6.nux.i686.rpm
$ rpm -ivh knock-server-0.5-7.el6.nux.i686.rpm

Configuration

The configuration file can be found under /etc/knockd.conf.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[options]
logfile = /var/log/knockd.log

[openSSH]
sequence = 6000,7000,8000
seq_timeout = 15
command = /sbin/iptables -I INPUT -s %IP% -p tcp --dport 22 -j ACCEPT
tcpflags = syn

[closeSSH]
sequence = 8000,7000,6000
seq_timeout = 15
command = /sbin/iptables -D INPUT -s %IP% -p tcp --dport 22 -j ACCEPT
tcpflags = syn

In the above configuration, we’ve stated that any host that sends a TCP SYN message to port 6000, then 7000 and finally to 8000, within 15 seconds, will cause the iptables command to be run. As you can see, the use of iptables is not hard-coded to knockd at all, meaning that any command can be run when the port sequence is triggered, allowing us to do all sorts of fancy stuff. To close it up, we do the same sequence in reverse order (that’s because we have configured it to do so).

GPG Cheatsheet

GnuPG (GNU Privacy Guard) is a tool for encrypting and signing data. It is a completely free implementation of the OpenPGP standard (defined by RFC4880), which is also known as GPG. This post contains a brief overview of the most important commands you probably have to use when working with GnuPG.

Generating GPG Keys

1
$ gpg --gen-key

You will be asked what kind of key you want, simply proceed with the instructions that are given to you.

Listing GPG Keys

Listing public keys:

1
$ gpg --list-keys

Listing private keys:

1
$ gpg --list-secret-keys

Exporting GPG Keys

XML Introduction

A XML (short for Extensible Markup Language) document consists of:

  • the prolog (optional)
  • the document type definition (DTD, optional)
  • the root element (which furthermore consists of more elements, tree structure)

Comments and processing instructions can be defined outside of tags.

Prolog

The basic prolog looks like this: <?xml version="1.0" ?> An extended version: <?xml version="1.0" encoding="ISO-8859-1" standalone="yes" ?>

Attributes explained:

  • version: XML version
  • encoding: Character set, defaults to UTF-8
  • standalone: define if extern entities or DTDs are being referenced in this document

Document Type Definition

The DTD defines structure validation rules for our documents. We fundamentally construct elements with their respective type (analogous to the database schema).

Reasons to use DTD:

Using Git to Manage a Live Site

Uploading files to production level after every change in code can be quite a hassle. Most people would use an automated deployment system instead of doing it manually. We can create an automated deployment system ourself by just using a version control like Git, which would also only take a few seconds to set up.

This post outlines the exact steps on how to do that. You should be able to understand basic terminology like pushing or pulling.

Install Prerequisites

Install Git on the server- and client-side.

1
$ yum install git-core

Head to this page if you still don’t know how to install it.

Server Setup

You’ll want to start by creating a bare repository on your server. A folder without its actual source files. The repository should be set up somewhere outside of your web root. We are going to instruct Git where to put the actual files later. Once you decide on a location for your repository, go ahead and create the bare repository:

1
2
3
mkdir mysite.git
cd mysite.git
git init --bare

Now we need to instruct Git where to put the files after every commit. This can be done via hooks, basically actions defined by triggers.

Quick Introduction to C

C Preprocessor

C preprocessor code will be executed before compiling the actual c code.
Preprocessor lines start with # and do not end with a semicolon (in contrast to usual code instructions).

1
2
#define MAX_SIZE = 1
#undef MAX_SIZE

The first instruction replaces instances of MAX_SIZE with 1. The second instruction undefines the previous made call.

1
2
#include <stdio.h>
#include "myheader.h"

Tells the cpp to include stdio.h from the system libraries, where else the next line includes the header file myheader.h from the local directory.

1
2
3
4
5
6
7
#ifndef MAX_SIZE
...
#endif

#ifdef DEBUG
...
#endif

Pointers

A pointer points to a variable address/stores a variable address.

1
2
3
4
char val = 'c';
char val2;
char *pointer = &amp;val;
val2 = *pointer;

VHDL Snippets

Entity

1
2
3
4
5
6
7
8
entity ENTITY_NAME is
port(
i_a : in std_logic;
i_b : in std_logic;
i_c : in std_logic;
o_c : out std_logic
);
end entity;

Architecture

Processes run concurrent to each other.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
architecture ARCHITECTURE_NAME of ENTITY_NAME is
type states is (q0, q1, q2, q3);
signal state : states; -- end internal signals

begin
-- concurrent code
PROCESS_NAME : process(i_c) -- sensitivity list
begin
if rising_edge(i_c) then
-- sequential code
elsif falling_edge(i_c) then
-- sequential code
end if;
end process;
-- concurrent code
end architecture;

Process

1
2
3
4
5
6
process(c_in) is
begin
if (c_in='1') then
-- do something
end if;
end process;

Process (rising edge)

1
2
3
4
5
6
process(c_in) is
begin
if (c_in'event and c_in='1') then
-- do something
end if;
end process;