Posts

Showing posts with the label android

🔍 What is Tight Coupling and Loose Coupling? (Android Developer Explanation)

✅  Tight Coupling Two classes/components are tightly coupled when they depend on each other directly. If one changes, the other must also change. It reduces flexibility and reusability. 📌 Example (Bad Practice – Tight Coupling) class UserRepository { fun getUser() = "Android Developer" } class UserViewModel { private val repository = UserRepository() // Direct object creation → TIGHT COUPLING fun printUser() { println(repository.getUser()) } } 🔴 Problems: UserViewModel cannot work without UserRepository Hard to unit test (cannot inject mock repo) If repository changes, viewmodel breaks Not reusable ✅ Loose Coupling Two classes are loosely coupled when they depend on abstractions (interfaces) instead of concrete classes. You can replace dependency without modifying main logic → more flexible. 📌 Example (Good Practice – Loose Coupling with DI) interface UserRepository { fun getUser(): String } class UserRepository...

📌 Android Documentation Plugins: The Best Way to Document Your Code

Image
📖 Introduction Writing good documentation is essential for maintaining and scaling Android projects. Whether you are working solo or in a team, having well-structured documentation helps developers understand the project, onboard new team members, and avoid confusion. In this blog post, we will explore Dokka , the officially recommended documentation tool for Kotlin-based Android apps . We will also briefly discuss other options and compare their features. 🔥 What is Dokka? Dokka is an official documentation tool developed by JetBrains for generating API documentation from Kotlin and Java projects. It works similarly to Javadoc but is optimized for Kotlin. ✅ Key Features of Dokka: ✔️ Generates HTML, Markdown, and Javadoc-style documentation ✔️ Supports KDoc (Kotlin's built-in documentation format) ✔️ Integrates with Gradle and Version Catalogs ✔️ Works with both Kotlin and Java code in Android projects ✔️ Supports publishing documentation to GitHub Pages, ReadTheDocs, etc...

Error in Android Migration Gradle 7.5 to 8.5 - java.lang.NullPointerException: Cannot invoke "String.length()" because "" is null

Image
The error message: java.lang.NullPointerException: Cannot invoke "String.length()" because "<parameter1>" is null indicates that a null value is being passed to a method that expects a non-null string , and it's trying to call .length() on it. Solution: Update the Supported Java version in Android Studio Android Studio -> Settings -> Build, Execution, Deployment -> Build Tools -> Gradle ->  Update Gradle JDK to 17 or Higher

Create emulator in Linux Virtual machine through terminal using docker for android

 Set Java: 1. Use Java 11 or 17 Instead of Java 18 SDK Manager works best with Java 11 or Java 17 . Java 18 is not officially supported for Android SDK tools. Run the following command to check your Java version: java -version sudo apt update sudo apt install openjdk-17-jdk export JAVA_HOME=$(/usr/libexec/java_home -v 17) export PATH= $JAVA_HOME /bin: $PATH Now, try running the sdkmanager command again. 2. Install android image using sdkmanager sdkmanager "system-images;android-34;google_apis;arm64-v8a" --sdk_root=/opt/android-sdk if sdkmanger is not found in emulator root@dee16e24c043:/# ${ANDROID_SDK_ROOT}/cmdline-tools/bin/sdkmanager --sdk_root=${ANDROID_SDK_ROOT} --licenses 3. Create emulator using avdmanager avdmanager create avd -n MyEmulator -k "system-images;android-34;google_apis_playstore;x86_64" --device "pixel_5" 4. Launch the Emulator root@dee16e24c043:/# emulator -avd MyEmulator -no-snapshot -noaudio -no-boot-anim 5. Install kvm if emulat...

Dockerizing an Ionic Capacitor App: A Step-by-Step Multi-Arch Dockerfile Guide

  Execute the image through podman or docker podman buildx build --platform linux/amd64,linux/arm64 -t my-ionic-app:latest . docker buildx build --platform linux/amd64,linux/arm64 -t my-ionic-app:latest . Run the image podman run -it --rm --privileged -v /dev/bus/usb:/dev/bus/usb my-ionic-app:latest bash docker run -it --rm --privileged -v /dev/bus/usb:/dev/bus/usb my-ionic-app:latest bash

🚀 Decompile or (Reverse Engine) an APK on macOS

Image
Required: jd-gui - https://java-decompiler.github.io/ apktool - https://apktool.org/ dex2jar - https://github.com/pxb1988/dex2jar Download and Install APKTool: Once you have the JDK installed, you can download and install APKTool using Homebrew: brew install apktool Verify Installation: After installing APKTool, you can verify the installation by running the following command in Terminal: bash apktool --version Usage: To decompile an APK file using APKTool, navigate to the directory containing the APK file in Terminal and run the following command: bash apktool d filename.apk If this error occur: getting error "Error: python@3.12: the bottle needs the Apple Command Line Tools to be installed." Here's how you can install the Apple Command Line Tools and resolve the error: 1. Install Apple Command Line Tools: You can install the Apple Command Line Tools using the following command in the Terminal: bash xcode-select --install This command will prompt you to install the C...

Android Interview Questions 2022

JAVA Why String is mutable? String str1 = 10                 String str2 = 20         str1 == str2 is this true? What String Pool in java? Difference of StringBuffer vs String? Difference of StringBuilder vs StringBuffer? What is HashMap and purpose? Difference of HashMap vs HashTable? Difference of HashMap vs HashSet? What is array vs list? What is abstract class in java? What is collections in java? What is flatmap? What is array vs arraylist? What is Interface in Java? What is polymorphism ? What is singleton class? The following variable stored in which memory?                 String str = new String()  - memory?         String str = “test”;         String str1 = “test”; ...