When targeting Android from Android Studio: checkDebugDuplicateClasses FAILED

217 views
Skip to first unread message

Jeff Lawson

unread,
Jan 2, 2023, 8:08:43 AM1/2/23
to Chromium-discuss

Hi,

It would be great if someone knows how to resolve this error can can let me know what to do:   checkDebugDuplicateClasses FAILED

Goal: from Android Studio, run/debug Chromium on an Android device. (Thereafter, make PKI-related updates required for use on a corporate intranet.)

My work has been with a new computer:
   i7-13700KF CPU
   2 TB SSD
   32 GB DRAM
   Ubuntu 22.04.1 LTS
   Android Studio Dolphin | 2021.3.1 Patch 1

I followed the current Chromium download/build instructions but no matter what I tried (over two days), I could not resolve this error:
   checkDebugDuplicateClasses FAILED

No change has been made to the downloaded Chromium source code so this error is occurring in the Chromium project as it is today and as it was over the past week.

Today, I started afresh, using what I have learnt. Here's an acurate record of what I did (I still saw the same error):


a) Followed instructions at:  https://chromium.googlesource.com/chromium/src/+/master/docs/android_build_instructions.md ...

   fetch --nohooks --no-history android

   cd src

   build/install-build-deps-android.sh

   gclient runhooks

   gn args out/Default
      when prompted, paste into args.gn:
         target_os = "android"
         target_cpu = "arm64"

   autoninja -C out/Default chrome_public_apk



b) Followed instructions at:  https://chromium.googlesource.com/chromium/src.git/+/main/docs/android_studio.md ...

   build/android/gradle/generate_gradle.py --output-directory out/Default --project-dir /home/jeff/chromium2/Android --target //chrome/android:chrome_public_apk

   Import /home/jeff/chromium2/Android into Android Studio
      Android Gradle Plugin upgrade recommended but ignored. (Previously, I updated but that did not help.)
      Wait for indexing to complete.


c) Use imported project ...

   Clean Project. Rebuild Project. Generates build output:
      > Task :chrome.android.chrome_public_apk:checkDebugDuplicateClasses FAILED
      > Task :chrome.android.chrome_public_apk:compileDebugJavaWithJavac FAILED
      Duplicate class com.google.common.util.concurrent.ListenableFuture found in modules guava-31.1-android (guava-31.1-android.jar) and listenablefuture-1.0 (listenablefuture-1.0.jar)

   To build.gradle in app module, added:
      configurations {
          all*.exclude group: 'com.google.guava', module: 'listenablefuture'
      }
   then did Sync Now.

   To gradle.properties, added:
      org.gradle.jvmargs=-Xmx4g -XX:MaxPermSize=2048m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
      android.useAndroidX=true
      android.enableJetifier=true
   then did Sync Now.


   Clear Project. Rebuild Project.

   Still see:

      > Task :chrome.android.chrome_public_apk:checkDebugDuplicateClasses FAILED

      plus many duplicate files


Previously built with --debug but nothing obvious appears.

Andrew Grieve

unread,
Jan 15, 2023, 8:17:15 PM1/15/23
to Chromium-discuss, Jeff Lawson
The generated gradle project does not support building unfortunately. It's there just so that .java files can be edited in Android Studio. Building via ninja is the only way.

Jeff Lawson

unread,
Jan 16, 2023, 8:03:55 AM1/16/23
to Chromium-discuss, agr...@chromium.org
OK. That makes sense. Thank you for taking the time to help  :-)


Jeff
Reply all
Reply to author
Forward
0 new messages