How to define version property in gradle

Issue #351 From Gradle tips and recipes, Configure project-wide properties For projects that include multiple modules, it might be useful to define properties at the project level and share them across all modules. You can do this by adding extra properties to the ext block in the top-level build.gradle file. ext { navigationVersion = "2.0.0" } rootProject.ext.navigationVersion Versions are used mostly in dependencies block so having them defined in global ext is not quite right....

August 10, 2019 Â· 1 min Â· Khoa Pham

How to use Navigation component with DrawerLayout in Android

Issue #349 build.gradle dependencies { classpath 'android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha05' } app/build.gradle apply plugin: 'androidx.navigation.safeargs' dependencies { def navigationVersion = "2.0.0" def drawerLayoutVersion = "1.0.0" implementation "androidx.drawerlayout:drawerlayout:$drawerLayoutVersion" implementation "androidx.navigation:navigation-fragment-ktx:$navigationVersion" implementation "androidx.navigation:navigation-ui-ktx:$navigationVersion" } main_activity.xml Use CoordinatorLayout and ToolBar Define layout_gravity for NavigationView <?xml version="1.0" encoding="utf-8"?> <androidx.drawerlayout.widget.DrawerLayout android:layout_height="match_parent" android:layout_width="match_parent" xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/drawerLayout" tools:context=".MainActivity"> <androidx.coordinatorlayout.widget.CoordinatorLayout android:layout_width="match_parent" android:layout_height="match_parent"> <com.google.android.material.appbar.AppBarLayout android:layout_width="match_parent" android:layout_height="wrap_content"> <androidx.appcompat.widget.Toolbar android:layout_width="match_parent" android:layout_height="?attr/actionBarSize" android:id="@+id/toolbar"/> </com.google.android.material.appbar.AppBarLayout> <fragment android:layout_width="match_parent" android:layout_height="match_parent" android:id="@+id/hostFragment" android:name="androidx.navigation.fragment.NavHostFragment" app:defaultNavHost="true" app:navGraph="@navigation/navigation_graph"/> </androidx.coordinatorlayout.widget.CoordinatorLayout> <com....

August 7, 2019 Â· 2 min Â· Khoa Pham

How to use ext in gradle in Android

Issue #338 Gradle uses Groovy and it has ext, also known as ExtraPropertiesExtension Additional, ad-hoc, properties for Gradle domain objects. Extra properties extensions allow new properties to be added to existing domain objects. They act like maps, allowing the storage of arbitrary key/value pairs. All ExtensionAware Gradle domain objects intrinsically have an extension named “ext” of this type. project.ext { myprop = "a" } assert project.myprop == "a" assert project....

July 2, 2019 Â· 1 min Â· Khoa Pham

Understanding device and OS share for iOS and Android

Issue #316 Browsers and devices used in 2018 AppStore measurement

June 18, 2019 Â· 1 min Â· Khoa Pham

How to use Gradle Kotlin DSL in Android

Issue #285 kts settings.gradle.kts include(":app") build.gradle.kts import org.gradle.kotlin.dsl.apply import org.gradle.kotlin.dsl.dependencies import org.gradle.kotlin.dsl.kotlin import org.gradle.kotlin.dsl.* import org.jetbrains.kotlin.config.KotlinCompilerVersion plugins { id("com.android.application") kotlin("android") kotlin("android.extensions") } //apply { // from("$rootDir/tools/grgit.gradle") // from("$rootDir/buildSrc/quality.gradle.kts") // from("$rootDir/tools/ktlint.gradle") // from("$rootDir/tools/detekt.gradle") //} android { compileSdkVersion(28) flavorDimensions("default") defaultConfig { applicationId = "com.onmyway133.myapp" minSdkVersion(26) targetSdkVersion(28) // versionCode = ext.get("gitCommitCount") as? Int versionCode = 1 versionName = "1.0" testInstrumentationRunner = "androidx.test.runner.AndroidJUnitRunner" } signingConfigs { create("release") { keyAlias = "keyalias" keyPassword = "keypassword" storePassword = "storepassword" storeFile = file("/Users/khoa/Android/Key/keystore") } } buildTypes { getByName("debug") { signingConfig = signingConfigs....

May 24, 2019 Â· 2 min Â· Khoa Pham

How to run Android apps in Bitrise

Issue #273 Original post https://hackernoon.com/using-bitrise-ci-for-android-apps-fa9c48e301d8 CI, short for Continuous Integration, is a good practice to move fast and confidently where code is integrated into shared repository many times a day. The ability to have pull requests get built, tested and release builds get distributed to testers allows team to verify automated build and identify problems quickly. I ‘ve been using BuddyBuild for both iOS and Android apps and were very happy with it....

May 23, 2019 Â· 5 min Â· Khoa Pham

How to setup Android projects

Issue #257 checkstyle (Java) http://checkstyle.sourceforge.net/ https://github.com/checkstyle/checkstyle Checkstyle is a development tool to help programmers write Java code that adheres to a coding standard. It automates the process of checking Java code to spare humans of this boring (but important) task. This makes it ideal for projects that want to enforce a coding standard. app/build.gradle apply plugin: 'checkstyle' task checkstyle(type: Checkstyle) { description 'Check code standard' group 'verification' configFile file('$project....

May 23, 2019 Â· 5 min Â· Khoa Pham

How to fix ApiException 10 in Flutter for Android

Issue #188 Get error com.google.android.gms.common.api.ApiException: 10 with google_sign_in package. Read https://developers.google.com/android/guides/client-auth Certain Google Play services (such as Google Sign-in and App Invites) require you to provide the SHA-1 of your signing certificate so we can create an OAuth2 client and API key for your app console.developers.google.com/apis/credentials Credentials -> OAuth client id If we specify SHA1 in firebase, then console.developers.google.com will generate an Android oauth for us keytool -list -v -keystore {keystore_name} -alias {alias_name} Use correct keystore for debug and release...

March 24, 2019 Â· 1 min Â· Khoa Pham

How to fix SSLPeerUnverifiedException in Android

Issue #184 Get error javax.net.ssl.SSLPeerUnverifiedException: No peer certificate in Android API 16 to API 19 Getting started Read about HTTPS and SSL https://developer.android.com/training/articles/security-ssl Check backend TLS https://www.ssllabs.com/index.html TLS by default in Android P https://android-developers.googleblog.com/2018/04/protecting-users-with-tls-by-default-in.html TLS version Read https://developer.android.com/reference/javax/net/ssl/SSLSocket.html This class extends Sockets and provides secure socket using protocols such as the “Secure Sockets Layer” (SSL) or IETF “Transport Layer Security” (TLS) protocols. TLS 1.1 and 1.2 are supported from API 16, but not enabled by default until API 20....

March 24, 2019 Â· 4 min Â· Khoa Pham

Make your own sliding menu on Android tutorial – Part 2

Issue #152 This is the part 2 of the tutorial. If you forget, here is the link to part 1. Link to Github In the first part, we learn about the idea, the structure of the project and how MainActivity uses the MainLayout. Now we learn how to actually implement the MainLayout DISPLAY MENU AND CONTENT VIEW First we have MainLayout as a subclass of LinearLayout public class MainLayout extends LinearLayout We then need declare the constructors...

February 27, 2018 Â· 8 min Â· Khoa Pham

Make your own sliding menu on Android tutorial - Part 1

Issue #151 This post was from long time ago when I did Android I can’t deny that Facebook is so amazing, they made trends and people want to follow. That is the case of the sliding menu. Searching many threads on SO, like these create android Sliding Menu like Facebook,gmail, Android sliding menu similar to the one on facebook, Android - Sliding menu with sub menu 
 they will mostly introduce you to some good sliding menu libraries, like this SlidingMenu and some tutorials on how to use it....

February 27, 2018 Â· 5 min Â· Khoa Pham

Understanding suspend function in Kotlin Coroutine in Android

Issue #123 Getting to know Coroutine From https://kotlinlang.org/docs/reference/coroutines.html To continue the analogy, await() can be a suspending function (hence also callable from within an async {} block) that suspends a coroutine until some computation is done and returns its result: From https://kotlinlang.org/docs/tutorials/coroutines-basic-jvm.html We are using the delay() function that’s like Thread.sleep(), but better: it doesn’t block a thread, but only suspends the coroutine itself. The thread is returned to the pool while the coroutine is waiting, and when the waiting is done, the coroutine resumes on a free thread in the pool....

December 18, 2017 Â· 5 min Â· Khoa Pham

BuddyBuild and gradle.properties

Issue #109 People advise against storing keys inside build.gradles. We should store them on 1Password and populate our gradle.properties, so don’t track this file in git. Here is .gitignore file *.iml /build /gradle.properties /local.properties .gradle .idea There are several ways to help BuddyBuild know about our gradle.properties 1. Using Environment variables But when configuring the project on BuddyBuild, it complains about key not found. The solution is to use Environment variables...

November 23, 2017 Â· 1 min Â· Khoa Pham

Communication between Fragment and Activity

Issue #108 There’s always need for communication, right 😉 Suppose we have OnboardingActivity that has several OnboardingFragment. Each Fragment has a startButton telling that the onboarding flow has finished, and only the last Fragment shows this button. Here are several ways you can do that 1. EventBus 🙄 Nearly all articles I found propose this https://github.com/greenrobot/EventBus, but I personally don’t like this idea because components are loosely coupled, every component and broadcast can listen to event from a singleton, which makes it very hard to reason when the project scales...

November 21, 2017 Â· 3 min Â· Khoa Pham