Friday, July 28, 2023

Android Studio Giraffe 2022.3.1: limiting memory for 8GB Ram on windows 11

 Running on Ryzen 7535HS Ram 8GB Windows 11

I got bad experience after upgrading Android Studio Flamingo to Giraffe. It cosumes to much memory on my machine and causing Dead of Blue Screen. 

To limit memory usage:

  1. File -> Settings -> Appearance & Behavior -> System Settings -> Memory Settings
    IDE max heap Size: 1280MB
    Gradle daemon max heap size: 1536MB
    Kotlin daemon max heap size: 1536MB
  2. Click Ok and restart your android studio

Note: This problem did not happened on Debian 11 after upgrading Android Studio Flamingo to Giraffe on same machine (dual boot).

Wednesday, July 19, 2023

Android Studio Flamingo 2022.2.1 Patch 2 Duplicate Class Found

Build Tools Version 34.0.0

Error:

:app:checkDebugDuplicateClasses 1error

duplicate class kotlin.collections.jdk8.collectionsjdk8kt found in modules kotlin-stdlib-1.8.20

Duplicate Class Found

Build Output:

> Task :app:checkDebugDuplicateClasses FAILED
Execution failed for task ':app:checkDebugDuplicateClasses'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
   > Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations found in modules kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
...
     Duplicate class kotlin.text.jdk8.RegexExtensionsJDK8Kt found in modules kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
     Duplicate class kotlin.time.jdk8.DurationConversionsJDK8Kt found in modules kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)

* Try:
> Run with --info or --debug option to get more log output.
> Run with --scan to get full insights.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:checkDebugDuplicateClasses'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:149)
    at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:147)
    at
...
org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:463)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:380)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:49)
Caused by: java.lang.RuntimeException: Duplicate class kotlin.collections.jdk8.CollectionsJDK8Kt found in modules kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
Duplicate class kotlin.internal.jdk7.JDK7PlatformImplementations found in modules kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and kotlin-stdlib-jdk7-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.6.21)
...
...
Duplicate class kotlin.text.jdk8.RegexExtensionsJDK8Kt found in modules kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)
Duplicate class kotlin.time.jdk8.DurationConversionsJDK8Kt found in modules kotlin-stdlib-1.8.20 (org.jetbrains.kotlin:kotlin-stdlib:1.8.20) and kotlin-stdlib-jdk8-1.6.21 (org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.6.21)

Go to the documentation to learn how to Fix dependency resolution errors.
    at com.android.build.gradle.internal.tasks.CheckDuplicateClassesDelegate.run(CheckDuplicateClassesDelegate.kt:65)
    at com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable.execute(CheckDuplicateClassesDelegate.kt:91)
    at org.gradle.workers.internal.DefaultWorkerServer.execute(DefaultWorkerServer.java:63)
    at
...
org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.runBatch(DefaultConditionalExecutionQueue.java:157)
    at org.gradle.internal.work.DefaultConditionalExecutionQueue$ExecutionRunner.run(DefaultConditionalExecutionQueue.java:126)
    ... 2 more

Edit build.gradle (Module.app) at the end of depedency

dependencies {
...
    implementation(platform("org.jetbrains.kotlin:kotlin-bom:1.8.0"))
    constraints {
        implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk7:1.8.0") {
            because("kotlin-stdlib-jdk7 is now a part of kotlin-stdlib")
        }
        implementation("org.jetbrains.kotlin:kotlin-stdlib-jdk8:1.8.0") {
            because("kotlin-stdlib-jdk8 is now a part of kotlin-stdlib")
        }
    }

NOTE: 

Does not need on android studio giraffe 2022.3.1

Reference:

  • https://gist.github.com/danielcshn/7aa57155d766d46c043fde015f054d40 
  • https://youtrack.jetbrains.com/issue/KT-54136/Duplicated-classes-cause-build-failure-if-a-dependency-to-kotlin-stdlib-specified-in-an-android-project



Monday, July 17, 2023

Debian Bookworm: Configure printer and scanner HP Ink 415 Wireless (all in one)

Install required packages for printer and scanner

# apt-get install system-config-printer hplip cups hplip-ppds  

To configure printer:

  1. Applications -> Settings -> Print Settings
  2. Add new printer
  3. Select Network Printer -> AppSocket/HP JetDirect and fill Enter Host with printer's IP address

Install XSane for scanning image

# apt-get install xsane sane-utils

To configure scanner:

  1. Run XSane to configure scanner
  2. After XSane detected HP Printer & Scanner, select Hewlett-Pac and press Ok.

To install driver print to pdf

# apt-get install printer-driver-cups-pdf



Wednesday, July 12, 2023

Debian Bookworm: change grub resolution on boot using grub-customizer to 640x480

Install grub customizer

# apt-get install  grub-customizer  

To change grub resolution on boot:

Applications -> Settings -> Grub Customizer -> Appearance Settings -> custom resolution 640x480

Wednesday, July 5, 2023

Debian Bookworm: installing Apache2, MariaDB and PHP 8.2 (default)

 Installing MariaDB database

# apt-get install mariadb-client mariadb-server  

Install apache2 and PHP

# apt-get install apache2 php libapache2-mod-php php8.2-mysql

By default, PHP version for Debian Bookworm is 8.2.

To disable apache2 and mariadb start during boot (to faster your PC start, not recommended for live server)

# systemctl disable apache2
# systemctl disable mariadb

You can start and stop manualy after boot.

Install additional php 8.2 required by CodeIgniter

# apt-get install php8.2-curl php8.2-imagick php8.2-gd php8.2-intl php8.2-mbstring php8.2-memcache php8.2-memcached php8.2-redis php8.2-xml php8.2-phpdbg