Monday, October 30, 2017

How to create a new project using apache maven 3.5.2

I just installed apache-maven-3.5.2 and oh boy creating a project seems very difficult. Specially if you are new. It seems it's not possible to create a new project according to the quick start tutorials.

xx> mvn -B archetype:generate -DarchetypeGroupId=org.apache.maven.archetypes -Dgroup
Id=com.mycompany.app -DartifactId=my-app
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] BUILD FAILURE
[INFO] ------------------------------------------------------------------------
[INFO] Total time: 0.086 s
[INFO] Finished at: 2017-10-31T11:44:26+07:00
[INFO] Final Memory: 4M/15M
[INFO] ------------------------------------------------------------------------
[ERROR] The goal you specified requires a project to execute but there is no POM in this directory (xxx). Please verify you invoked Maven from the correct directory. -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MissingProjectException


Instead, try this

mvn -B archetype:generate -DinteractiveMode=true

Wednesday, May 24, 2017

How to check the Android SIM count

getprop ro.multisim.simslotcount

or

SystemProperties.getInt("ro.multisim.simslotcount", 1) > 1

How to detect Dual SIM using Android shell ?


getprop persist.radio.multisim.config returns "dsds" or "dsda"   on multi sim Samsung devices

source: https://android.googlesource.com/platform/frameworks/base/+/master/telephony/java/com/android/internal/telephony/TelephonyProperties.java


    public static Boolean isDualSimModel() {
        return (Boolean.valueOf("dsds".equals(SystemProperties.get("persist.radio.multisim.config")))                    Boolean.valueOf("dsda".equals(SystemProperties.get("persist.radio.multisim.config"))));
    }

Tuesday, January 24, 2017

How to install letsencrypt ssl certificate on nginx without Unable to locate package letsencrypt error

Today, I thought of moving some of the websites to ssl. so I looked up for a guide on Google and most of them says

sudo apt-get install letsencrypt


but it ends with

E: Unable to locate package letsencrypt

So, I had to go back to the original repo to fix this problem.


git clone https://github.com/letsencrypt/letsencrypt
cd letsencrypt
./letsencrypt-auto --help

this will show the help. If you are trying to configure to run on nginx.

 sudo ./letsencrypt-auto --nginx

and then select the website number. Make sure you do not have anything running on port 443 now.

Wednesday, December 21, 2016

How to setup Android Studio for Java 8

Today, I wanted to move one of the project I was working on to Android Studio 2.2 to support Java 8. It's kind of amazing there is not enough information about how to convert an existing project to support Android Studio + Java 8.

1. In your project build.gradle add classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'  So it should be like this

// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
    repositories {
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:2.2.2'
        classpath 'me.tatarka:gradle-retrolambda:3.2.3'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.8'
        // NOTE: Do not place your application dependencies here; they belong
        // in the individual module build.gradle files
    }
}
allprojects {
    repositories {
        jcenter()
    }
}
task clean(type: Delete) {
    delete rootProject.buildDir
}

2. In your Module build.gradle add

apply plugin: 'me.tatarka.retrolambda'

compileOptions {
    sourceCompatibility JavaVersion.VERSION_1_8
    targetCompatibility JavaVersion.VERSION_1_8
}


apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'me.tatarka.retrolambda'
android {
    compileSdkVersion 25
    buildToolsVersion "25.0.1"
    defaultConfig {
        ..
    }
    buildTypes {
        ...
    }
     
    compileOptions {
        sourceCompatibility JavaVersion.VERSION_1_8
        targetCompatibility JavaVersion.VERSION_1_8
    }
}
dependencies {
 ....
}