Skip to content

Snappy1

  • Home
  • Android
  • What
  • How
  • Is
  • Can
  • Does
  • Do
  • Why
  • Are
  • Who
  • Toggle search form

[FIXED] java – Unit testing: Entry name ‘res/layout/test_toolbar.xml’ collided

Posted on November 11, 2022 By

Solution 1 :

I just did the following and It solved my problem.

  1. Invalidate caches and Restart (File -> Invalidate Caches / Restart)
  2. Clean Project (Build -> Clean Project)

Solution 2 :

This happens due to same xml may be included in third party SDKs.
Solution: exclude ‘res/layout/test_toolbar.xml’ in packagingOptions of app’s build.gradle file.

packagingOptions { exclude 'res/layout/test_toolbar.xml' }

Problem :

I’ve tried to do some unit test example that included in an Android Studio project like ExampleInstrumentedTest and ExampleUnitTest, so the result is :

Entry name ‘res/layout/test_toolbar.xml’ collided

I’ve searched everywhere on google but there’s not answers to this specific problem, so any help will be grateful

here’s the source of the basic unit test example :

ExampleUnitTest

 * Example local unit test, which will execute on the development machine (host).
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
public class ExampleUnitTest {
    @Test
    public void addition_isCorrect() {
        assertEquals(4, 2 + 2);
    }}

enter image description here

ExampleInstrumentedTest

 * Instrumented test, which will execute on an Android device.
 *
 * @see <a href="http://d.android.com/tools/testing">Testing documentation</a>
 */
@RunWith(AndroidJUnit4.class)
public class ExampleInstrumentedTest {
    @Test
    public void useAppContext() {
        // Context of the app under test.
        Context appContext = InstrumentationRegistry.getInstrumentation().getContext();

        assertEquals("com.example.abder.emarque", appContext.getPackageName());
    }}

enter image description here

Comments

Comment posted by stackoverflow.com/a/68501093/1633493

See similar error and possible solutions here:

READ  [FIXED] java - App crash with GC When an object added to firebase - Android Studio
Powered by Inline Related Posts
Android Tags:android, android-debug, java, test-coverage, unit-testing

Post navigation

Previous Post: [FIXED] activity_main.xml for android studio stuck on loading
Next Post: Can a beginner learn Moonlight Sonata 1st Movement?

Related Posts

[FIXED] java – How to find the R file in Android Studio 2020? Android
[FIXED] android – Getting error when trying to upload data to server Android
[FIXED] android – Firebase authentication for different kinds of users Android
[FIXED] java – Cant get PackageInstaller.uninstall working Android
[FIXED] android – UnitialisedPropertyAccessException even after lateinit var has been initialised? Android
[FIXED] android – Firebase not sending verification code to phone the second time Android

Archives

  • March 2023
  • February 2023
  • January 2023
  • December 2022
  • November 2022
  • October 2022
  • September 2022

Categories

  • ¿Cómo
  • ¿Cuál
  • ¿Cuándo
  • ¿Cuántas
  • ¿Cuánto
  • ¿Qué
  • Android
  • Are
  • At
  • C'est
  • Can
  • Comment
  • Did
  • Do
  • Does
  • Est-ce
  • Est-il
  • For
  • Has
  • Hat
  • How
  • In
  • Is
  • Ist
  • Kann
  • Où
  • Pourquoi
  • Quand
  • Quel
  • Quelle
  • Quelles
  • Quels
  • Qui
  • Should
  • Sind
  • Sollte
  • Uncategorized
  • Wann
  • Warum
  • Was
  • Welche
  • Welchen
  • Welcher
  • Welches
  • Were
  • What
  • What's
  • When
  • Where
  • Which
  • Who
  • Who's
  • Why
  • Wie
  • Will
  • Wird
  • Wo
  • Woher
  • you can create a selvedge edge: You can make the edges of garter stitch more smooth by slipping the first stitch of every row.2022-02-04
  • you really only need to know two patterns: garter stitch

Recent Posts

  • What is the rising action in Julius Caesar?
  • How do you secure a rope to itself?
  • Does waterproof laminate scratch easily?
  • What makes a building prewar?
  • What can you learn in a month without alcohol?

Recent Comments

No comments to show.

Copyright © 2023 Snappy1.

Powered by PressBook Grid Dark theme