Sunday, April 7, 2019

flutter Android dependency 'androidx.core:core' has different version for the compile (1.0.0) and runtime (1.0.1) classpath

In the android/build.gradle file set the gradle version to 3.3.2 as follows:

dependencies {
    classpath 'com.android.tools.build:gradle:3.3.2'
}


Reference: https://github.com/flutter/flutter/issues/27254

flutter "detected problems with api compatibility"

In the android/app/build.gradle file change the targetSdkVersion from 27 to 28.

Reference: https://stackoverflow.com/questions/49957255/espresso-test-on-android-p-preview-detected-problems-with-api-compatibility-err

Friday, April 5, 2019

flutter "unable to start activity" "ensureInitializationComplete must be called after startInitialization"

Flutter app fails to launch with the following error:


 Caused by: java.lang.IllegalStateException: ensureInitializationComplete must be called after startInitialization  
     at io.flutter.view.FlutterMain.ensureInitializationComplete(FlutterMain.java:190)  
     at io.flutter.app.FlutterActivityDelegate.onCreate(FlutterActivityDelegate.java:156)  
     at io.flutter.app.FlutterActivity.onCreate(FlutterActivity.java:89)  
     at net.pawpalflutter.MainActivity.onCreate(MainActivity.java:10)  
     at android.app.Activity.performCreate(Activity.java:6672)  
     at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1140)  
     at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2612)  
     ... 9 more  


This error occurred when loading app from Android Studio to a mobile phone. It seems the transfer of the app may have been interrupted abruptly and didn't close properly, causing all subsequent transfers to fail.

The Solution

Power off and on the phone

Reference: https://github.com/flutter/flutter/issues/14513

Sunday, March 31, 2019

Intellij Dart Analysis Server Bad State: Too many elements

This error was also causing an issue "cannot find declaration to go to"
After doing a flutter upgrade, I had to do the following:

  1. Close IntelliJ
  2. delete the project's .idea folder and any *.iml files
  3. Reopen the project in intellij
If that doesn't work try File -> Invalidate caches / restart and repeat the steps above

Sunday, March 3, 2019

PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 8: null)

Using the flutter framework for android development, I received the following error during google signin:

PlatformException(sign_in_failed, com.google.android.gms.common.api.ApiException: 8: null)

While it wasn't obvious from the error message what the problem was, it turns out there was no network connection available. So if you get this error, check that you have access to the internet!!

Tuesday, February 19, 2019

Node.js Centos 7 production configuration


Install nodejs

Download
wget --no-check-certificate https://nodejs.org/dist/v10.15.1/node-v10.15.1-linux-x64.tar.xz
Move the downloaded file /usr/local
Then unpack
tar xf node-v10.15.1-linux-x64.tar.xz
Add node executables to the path by adding symlinks to /usr/bin
ln -s /usr/local/node/bin/node /usr/bin/node
ln -s /usr/local/node/bin/npm /usr/bin/npm
ln -s /usr/local/node/bin/npx /usr/bin/npx

Install pm2

To run node as service we need to install a nodejs package
npm install pm2@latest –g
We need to run set the path to pm2
ln -s /usr/local/node/bin/pm2 /usr/bin/pm2
ln -s /usr/local/node/bin/pm2 /usr/bin/pm2-runtime

For security reasons we should run our app NOT as root. We create a new user nodejs to run our app
useradd nodejs
chown -R nodejs:nodejs /usr/local/node
chown –R nodejs:nodejs /usr/local/node-v10.15.1-linux-x64
# as root
pm2 startup system –u nodejs –-hp /home/nodjs

To start the application as the nodejs user, switch to the user nodejs
su nodejs
pm2 start /usr/local/node/apps/chat/server.js
pm2 list
# to automatically start the app on reboots
pm2 save

You should see that the app is running as user nodejs 



Likewise to stop
#other commands
pm2 stop /usr/local/node/apps/chat/server.js
pm2 delete /usr/local/node/apps/chat/server.js

Monday, February 11, 2019

Install ArangoDB on Centos 7


The instructions on the official arangodb website do not work, so I’m documenting the steps I took so that it may help others.

The first problem is adding arangodb as a repo due to invalid SSL certificates. To get around the issue:


The added ‘k’ parameter connects to the repo insecurely skipping the step of verifying the certificates.

Before we can run the yum command to install arangodb, we need to configure the arangodb.repo to skip SSL checks by adding the following to the file /etc/yum.repos.d/arangodb.repo
sslverify=0

Then run the command to install:
yum install arangodb3

References: