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”

Best practise for Logcat colours in Android Studio!

Android Studio Logcat color scheme Preferences
Standard

I know that using solid black colour logcat in Android Studio  is awful !!!

Here is my best practice colour codes that you can use for changing the face of you logcat in Android Studio to make it more useful. go to Android Studio Preferences and search for logcat and save as your own scheme:

Assert9C27B0
Debug2196F3
ErrorF44336
Info4CAF50
WarningFFC107

All colours are picked from material design colour pattern: https://www.google.com/design/spec/style/color.html

How to solve “Duplicate files copied in APK META-INF/LICENSE.txt”?

Standard

Sometimes depends on libraries that you have used in your Android project this annoying error shows up during gradle build using Android Studio:

Error:com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK META-INF/LICENSE.txt

can be solve this issue and many more by adding this to the Android tag of your build.grade file:

packagingOptions {
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/dependencies.txt'
    exclude 'META-INF/LGPL2.1'
}