Solution 1 :
I just did the following and It solved my problem.
- Invalidate caches and Restart (File -> Invalidate Caches / Restart)
- 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);
}}
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());
}}
Comments
Comment posted by stackoverflow.com/a/68501093/1633493
See similar error and possible solutions here: