How to fix ssh-add -K issue with Mac OS Sierra?

Standard

Before Mac OS Sierra, using this line of code save your time adding ssh keys once in your keychain:

ssh-add -K ~/.ssh/{your key}

but recently there is some issue with Mac OS new version and all your keys added to keychain reset on startup.

to fix this issue I found a solution with might be helpful.

  1. create a bash file containing these codes (~/.ssh/add_ssh_keys.sh):
count=`ssh-add -l |grep -v "The agent" |wc -l|awk '{print $1}'`
 if [ "0" == "${count}" ]
 then
 arr=`cd ~/.ssh && find id_rsa* -not -path '*.pub'`
 for key in ${arr[@]}
 do
 ssh-add -k ~/.ssh/${key}
 done
 fi
  1. make this file executable:
chmod +x ~/.ssh/add_ssh_keys.sh
  1. add this file to your Mac launch (~/Library/LaunchAgents/ssh_fixer.plist):
<plist version="1.0">
 <dict>
 <key>Label</key>
 <string>add_ssh_keys</string>
 <key>ProgramArguments</key>
 <array>
 <string>/Users/{YOUR USERNAME}/.ssh/add_ssh_keys.sh</string>
 </array>
 <key>RunAtLoad</key>
 <true/>
 </dict>
 </plist>
  1. now restart your Mac!

 

That’s it! 😎

How to fix “Android N requires the IDE to be running with Java 1.8 or later” on Mac?

Standard

I get this error while I was in layout editor selecting api N for preview, It was so easy to fix,

  1. install jdk1.8
  2. Set “JDK_HOME” and “JAVA_HOME” environment variables.
  3. Edit the file “/Applications/Android Studio.app/Contents/Info.plist"
  4. Look for “JVMVersion”
  5. add “1.8*,1.8+” to it:
...
<key>JVMVersion</key>
<string>1.8*,1.8+</string>
...

Now restart your “Android Studio”

Android Utils

Standard

This is a utils library for Android Applications containing useful methods.
AndroidUtils class help you to interact with different parts of android os without writing many codes and as simple as possible.

Github_LogoGithub repo:
https://github.com/mirhoseini/android_utils

Grab via Maven:

<dependency>
 <groupId>com.mirhoseini.utils</groupId>
 <artifactId>utils</artifactId>
 <version>1.0.7</version>
 <type>pom</type>
</dependency>

or Gradle:

compile 'com.mirhoseini.utils:utils:1.0.7'

How to setup CircleCI environment JAVA7_HOME, JAVA6_HOME for RetroLambda

Standard

Using retrolambda in Android application being built using circleci as continuous integration cause some issues:

> Building 10%When running gradle with java 8, you must set the path to the old jdk, either with property retrolambda.oldJdk or environment variable JAVA5_HOME/JAVA6_HOME/JAVA7_HOME

The problem is you have to configure environment variables for Java_Home, Java7_Home, Java6_Home and etc in circleci virtual machine.

this circle.yml file could help you in this regard:

#
# Build configuration for Circle CI
#

general:
    artifacts:
        - /home/ubuntu/weather_app/app/build/outputs/apk/
        - /usr/lib/jvm/

machine:
    environment:
        ANDROID_HOME: /usr/local/android-sdk-linux
        JAVA6_HOME: /usr/lib/jvm/java-6-openjdk-amd64

    java:
      version: openjdk8

dependencies:
    override:
        - echo y | sudo apt-get update
        - echo y | sudo apt-get install libpango-1.0-0
        - echo y | sudo apt-get install openjdk-6-jre

        - echo y | android update sdk --no-ui --all --filter tools,platform-tools,build-tools-23.0.3,android-23,extra-google-m2repository,extra-google-google_play_services,extra-android-support
        - ANDROID_HOME=/usr/local/android-sdk-linux ./gradlew dependencies

test:
    override:
        - (./gradlew assemble):
            timeout: 360

        - (./gradlew test):
            timeout: 360

stetho-timber Library issue with new Timber 4.1.2

Standard

While I was trying to use stetho-timber Library in my Android application I faced this problem:

Error:Module 'com.facebook.stetho:stetho-timber:1.3.1' depends on one or more Android Libraries but is a jar

After inspecting in its codes I found that it uses timber v3.0.1!

Just add this to your build.gradle dependencies tag to exclude timber within the stetho library,
cause it is an old version and conflicts with new one:

dependencies {
    compile ("com.facebook.stetho:stetho-timber:1.3.1") {
        exclude group: "com.jakewharton.timber", module: "timber"
    }
    .
    .
    .

I have recently found Facebook Stetho Library and using it is fantastic, give it a try! :)