question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Problems running tests on multidex app on Kitkat emulator after updating gradle plugin to 3.1.1

See original GitHub issue

Hello,

I’ve stumbled upon an issue after updating gradle plugin to 3.1.1.

I’ve tried to replicate on BasicSample (https://github.com/googlesamples/android-testing/tree/master/ui/espresso/BasicSample) project and got something very similar to my project’s errors. Please take a look at 3 subsequent commits on the forked repo.

  1. https://github.com/fada21/android-testing/commit/13488879e62e07349f204fc969642c25fe5af089 Working state of my project based on BasicSample. With not too many changes on top of BasicSample tests on Kitkat and Oreo emulator pass. All working fine.

  2. https://github.com/fada21/android-testing/commit/8d314542c1823958a4dde7bac0a129bdcf9bcf02 After update to gradle build tool to 3.1.1 with few necessary changes tests on Kitkat emulator fail when they pass with no problems on Oreo. I think that is relevant console output part

> Task :app:compileDebugAndroidTestJavaWithJavac 
Note: /home/fada21/Projects/android/android-testing/ui/espresso/BasicSample/app/src/androidTest/java/com/example/android/testing/espresso/BasicSample/ChangeTextBehaviorTest.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.

Warning: The rule `-keep public class *extends java.lang.annotation.Annotation {
  *;
}` uses extends but actually matches implements.
Starting 0 tests on Nexus_4_API_19(AVD) - 4.4.2

com.android.builder.testing.ConnectedDevice > No tests found.[Nexus_4_API_19(AVD) - 4.4.2] FAILED 
No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack @Test annotations).
  1. https://github.com/fada21/android-testing/commit/edc2613da4784002d04561578ca9c3de45ee616d After disabling multidex test pass on both emulators

My ci pipelines fail after update and I can’t disable multidex. Any ideas? Should I report that to tools team?

Cheers, Lukasz

Issue Analytics

  • State:open
  • Created 5 years ago
  • Reactions:1
  • Comments:12

github_iconTop GitHub Comments

12reactions
santanaluizcommented, Jun 6, 2018

I found a workaround to fix this problem. Instead of having my test related classes/packages inside: app/src/androidTest/com.company.app.**

I’m createad a subpackage called test: app/src/androidTest/com.company.app.**

Then, in my gradle file for I’ve added:

android {
   buildTypes {
        release {
            // ....
        }
        debug {
            // ....
            multiDexKeepProguard file('proguard-multidex-rules.pro')
        }
   }
}

Inside my file proguard-multidex-rules.pro, I’ve added the following rule:

-keep class com.company.app.test.** # <<--- this is the main trick
-keep class android.support.test.**
-keep class android.support.multidex.**
-keep class org.junit.**

Update:

instead of moving your packages, just add the following rule in the proguard-multidex-rules.pro file:

-keep @org.junit.runner.RunWith public class *
# ...
0reactions
eschoenawacommented, Sep 5, 2019

I’ve opened a feature request to make Android Studio automatically apply the fix for this problem, so noone has to search for this solution online. Feel free to give it a star here: https://issuetracker.google.com/issues/140124440

Read more comments on GitHub >

github_iconTop Results From Across the Web

Use the Android Gradle plugin Upgrade Assistant
The Upgrade Assistant changes the project build files and attempts to sync the new project build with Android Studio. This may take a...
Read more >
Multidex issue for androidTest with gradle plugin 3.0.0
Once I updated my app to gradle plugin 3.0.0 I started having issue with multidex, but only when I run androidTest .
Read more >
Support for legacy multidex test APK [37324038] - Issue Tracker
Your test sources and test-only dependencies are generating too many references. Java 8 language features are not related to this, as even when...
Read more >
DX App Experience Analytics - 19.1 - TechDocs - Broadcom Inc.
Cordova Plugin Updated. Problem: In the earlier versions, the contents in the AppDelegate file were replaced with the SDK initialization.
Read more >
Distribute Android apps to testers using Gradle - Firebase
Caution: When you register your app with Firebase, make sure to enter the same package name as ... Add the dependency for the...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found