App crashes when i apply crashlytics on it
FATAL EXCEPTION: main
Process: com.ehs.pk, PID: 20963
java.lang.RuntimeException: Unable to get provider com.crashlytics.android.CrashlyticsInitProvider: java.lang.ClassNotFoundException: Didn't find class "com.crashlytics.android.CrashlyticsInitProvider" on path: DexPathList[[zip file "/data/app/com.ehs.pk-8.apk"],nativeLibraryDirectories=[/data/app-lib/com.ehs.pk-8, /vendor/lib, /system/lib]]
at android.app.ActivityThread.installProvider(ActivityThread.java:4993)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4585)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4499)
at android.app.ActivityThread.access$1500(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5293)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.crashlytics.android.CrashlyticsInitProvider" on path: DexPathList[[zip file "/data/app/com.ehs.pk-8.apk"],nativeLibraryDirectories=[/data/app-lib/com.ehs.pk-8, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.app.ActivityThread.installProvider(ActivityThread.java:4978)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4585)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4499)
at android.app.ActivityThread.access$1500(ActivityThread.java:157)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1307)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5293)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
I was facing the same issue, is related to the 64k limit "multidex".
I was using multiDexEnabled true property in build.gradle in defaultConfig block, under android one.
As stated in Google documentation
for devices with Android API prior to 21, we need to include the multidex library (implementation 'com.android.support:multidex:1.0.2')
and extend MultiDexApplication in our Application class
I have solved this problem by doing the following:
In the Application class:
#Override
public void attachBaseContext(Context base) {
super.attachBaseContext(base);
try {
MultiDex.install(this);
} catch (RuntimeException multiDexException) {
multiDexException.printStackTrace();
}
}
We were having the same issue, and disabling instant run in Android Studio seemed to get it working.
On mac
Android Studio Settings or Preferences -> Build,Execution,Deployment -> Instant Run.
By looking at this part...
Didn't find class ... on path: DexPathList ... dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
of the stack trace you can figure out that your test device is probably pre-Lollipop (Android 5.0) and that you just hit the 64k limit. You can fix it as described here.
This could be an issue with Instant Run. Turn off the Instant Run and run the build again. I faced the same issue and it resolved it.
When minifyEnabled is true while using firebase or crashlytics this problem may happens. Enabling minifyEnabled shrinks methods and classes names to lowest possible characters (changing names and that raises ClassNotFoundException). Unfortunately, firebase and crashlytics versions had many problem with that. To solve it just tell proguard to not shrink those classes by writing the next lines in proguard file "proguard-rules.pro" as:
-keep class com.crashlytics.** { *; }
-keep class com.google.firebase.*.* { *; }
Now if the problem not go away or it didn't find other classes like yours, then check your base project build.gradle dependencies version of gradle and others. I found these version is free of that error:
dependencies {
classpath 'com.android.tools.build:gradle:3.0.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:3.2.0'
classpath 'io.fabric.tools:gradle:1.25.1'
}
Remeber you can put any classes path into that proguard file so it did not change its name or methods when minify is enabled, and that will help you with other classes "ClassNotFoundException" as well.
Also to test this in debugging, you can adjust debug setting in build.gradle as:
buildTypes {
release {
debuggable false
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Just one more case:
In my case, I disabled instant run, added multiDexEnabled true in my gradle, and added the 'com.android.support:multidex:1.0.3' to my dependencies, called the MultiDex.install(this); directly in my custom application, but I still got the same error. The error only occurs in the system Android 4.4. Everything works well on Android 7.0 and 9.0.
Finally, moving the MultiDex.install(this); from the onCreate(Context) method to the attachBaseContext(Context) solved my problem.
So, you should call MultiDex.install(this); in attachBaseContext(Context) instead of onCreate(Context) when you don't plan to extend the MultiDexApplication directly.
If this happens when you run with minifyEnabled true, add this rule in your proguard-rules.pro file:
-keep public class com.crashlytics.android.CrashlyticsInitProvider
Related
Instrumented tests do pass on local emulators and physical devices but fail on Firebase Test Lab, when the following conditions are met:
ProGuard is enabled for the debug builds;
There are both Dagger and Espresso dependencies.
FTL shows different test issues:
1) In case with APIs 26-28 it shows either Instrumentation run failed due to 'java.lang.NoClassDefFoundError' or Instrumentation run failed due to 'Process crashed.'
Exception stacktrace looks like this, it's not always shown in Firebase but is always present in logcat:
Rejecting re-init on previously-failed class java.lang.Class<androidx.test.espresso.core.internal.deps.dagger.internal.Factory>:
java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/inject/Provider;
FATAL EXCEPTION: Instr: androidx.test.runner.AndroidJUnitRunner
Process: com.example.debug, PID: 11425
java.lang.NoClassDefFoundError: Failed resolution of: Ljavax/inject/Provider;
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:453)
at androidx.test.internal.runner.TestLoader.doCreateRunner(TestLoader.java:72)
at androidx.test.internal.runner.TestLoader.getRunnersFor(TestLoader.java:104)
at androidx.test.internal.runner.TestRequestBuilder.build(TestRequestBuilder.java:789)
at androidx.test.runner.AndroidJUnitRunner.buildRequest(AndroidJUnitRunner.java:544)
at androidx.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:387)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:2145)
Caused by: java.lang.ClassNotFoundException: Didn't find class "javax.inject.Provider" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/system/framework/android.test.mock.jar", zip file "/data/app/com.example.debug.test-9kvw--JgNKzmuQurRdDbCQ==/base.apk", zip file "/data/app/com.example.debug-sz-oCUGs05zlEadCzyqsDA==/base.apk"],nativeLibraryDirectories=[/data/app/com.example.debug.test-9kvw--JgNKzmuQurRdDbCQ==/lib/arm64, /data/app/com.example.debug-sz-oCUGs05zlEadCzyqsDA==/lib/arm64, /system/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:134)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
... 8 more
2) I also ran one test on API 21 which only had one NoClassDefFoundError in the logs. However, this exception is also present on APIs 26-28, but is a part of the exception shown above. Maybe there's just some difference between how it's logged on different API levels.
java.lang.NoClassDefFoundError: androidx.test.espresso.core.internal.deps.dagger.internal.Factory
FATAL EXCEPTION: Instr: androidx.test.runner.AndroidJUnitRunner
Process: com.example.debug, PID: 5691
java.lang.NoClassDefFoundError: androidx.test.espresso.core.internal.deps.dagger.internal.Factory
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:308)
at androidx.test.internal.runner.TestLoader.doCreateRunner(Unknown Source)
at androidx.test.internal.runner.TestLoader.getRunnersFor(Unknown Source)
at androidx.test.internal.runner.TestRequestBuilder.build(Unknown Source)
at androidx.test.runner.AndroidJUnitRunner.buildRequest(Unknown Source)
at androidx.test.runner.AndroidJUnitRunner.onStart(Unknown Source)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1837)
Some relevant lines from build.gradle configuration:
android {
defaultConfig {
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
debug {
minifyEnabled true
useProguard true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules-debug.pro'
testProguardFile 'proguard-rules-test.pro'
}
}
}
dependencies {
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:core:1.0.0-beta01'
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0-beta01') {
// exclude module: 'javax.inject' - Exclusion doesn't help
}
// androidTestImplementation 'javax.inject:javax.inject:1' - Inclusion doesn't help either
androidTestImplementation('androidx.test.ext:junit:1.0.0-beta01') {
exclude group: "org.junit"
}
androidTestImplementation 'androidx.test:runner:1.1.0-beta01'
androidTestImplementation 'androidx.test:rules:1.1.0-beta01'
androidTestImplementation 'org.mockito:mockito-android:2.22.0'
implementation 'com.google.dagger:dagger:2.16'
kapt 'com.google.dagger:dagger-compiler:2.16'
}
proguard-rules-test.pro:
-ignorewarnings
-dontshrink
-dontoptimize
-dontobfuscate
Upon disabling ProGuard or removing Dagger dependency, tests start to pass on FTL.
So I contacted Firebase support and got an embarrassingly simple solution.
Add the following rule to the proguard-rules-debug.pro
-keep class javax.inject.** { *; }
It's still not clear why this problem doesn't occur while testing locally.
But at least this solution works.
I want to enable ProGuard in library module but getting compilation error that package does not exists. Why package not exists after apply ProGuard in library module?
library module build.gradle
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
Log Error
/home/hitesh/Documents/Android Studio Project/ALPR-Sample/app/src/main/java/com/alpr/sample/GalleryActivity.java
Error:(15, 32) error: package com.alprlib.alpr.doc does not exist
Error:Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
here doc class file exist in library module
ProGuard file rules
-keep class com.alprlib.alpr.** { *; }
-keepclassmembers class alprlib.alpr.** {*;}
It makes sense to me to specify proguard settings for a library (like which library files shouldn't be obfuscated) in the library project. I've found that I also need to include proguard configurations from my library modules in my application. To do this, I added the following to the defaultConfig section in my library's build.gradle
consumerProguardFiles 'proguard-rules.pro'
and then configured the proguard-rules.pro file in my library module to keep the names of important serialized classes.
See also consumerProguardFiles
Please see this post:
https://stackoverflow.com/a/48636288/8770663
you can write on your proguard file -
-keep public class * extends android.app.Activity
Or what ever class you want to keep.
Have a look on this - https://www.guardsquare.com/en/proguard/manual/examples
I updated my dex classes with amigo library (it's changing one apk for another apk with the same key and signature, all is working except JSOUP)
Error:
FATAL EXCEPTION: Thread-1567
Process: com.smedic.tubtub, PID: 26102
java.lang.ExceptionInInitializerError
at org.jsoup.nodes.Document$OutputSettings.(Document.java:372)
at org.jsoup.nodes.Document.(Document.java:19)
at org.jsoup.parser.TreeBuilder.initialiseParse(TreeBuilder.java:32)
at org.jsoup.parser.TreeBuilder.parse(TreeBuilder.java:42)
at org.jsoup.parser.HtmlTreeBuilder.parse(HtmlTreeBuilder.java:56)
at org.jsoup.parser.Parser.parseInput(Parser.java:32)
at org.jsoup.helper.DataUtil.parseByteData(DataUtil.java:104)
at org.jsoup.helper.HttpConnection$Response.parse(HttpConnection.java:666)
at org.jsoup.helper.HttpConnection.get(HttpConnection.java:225)
at com.power.mati.VideosAdapter$4.run(VideosAdapter.java:177)
at java.lang.Thread.run(Thread.java:818)
Caused by: java.lang.IllegalStateException: Could not read resource
entities-xhtml.properties. Make sure you copy resources for
org.jsoup.nodes.Entities
at org.jsoup.nodes.Entities.load(Entities.java:289)
at org.jsoup.nodes.Entities.access$000(Entities.java:25)
at org.jsoup.nodes.Entities$EscapeMode.(Entities.java:48)
Any idea how to fix it?
I am using jars and maven, same situation.
I saw something similar and my solution is in proguard
-keep class org.jsoup.**
Update the library, use this one :
implementation 'org.jsoup:jsoup:1.13.1'
Your problem will be resolved...
add Jsoup library in libs folder and add -keep class org.jsoup.** in your proguard-rules.pro file.
Then it will work.
in my case, my problem is solved by turning minifyEnabled to false in the app's build.gradle, this will keep all classes in the final release apk.
android {
....
buildTypes {
...
release {
minifyEnabled false
}
}
}
I keep on getting the NoClassDefFoundError on other test device (4.4.2) that I'm using. But works fine on my test device (Android 5.1).
I tried the solutions that I've googled and nothing seems to work.
I'm using Firebase Realtime Database. Can somebody please help?
Here is the error log:
06-03 01:36:29.607 2655-2655/mobapps.mypersonal.biz.grouptracker E/dalvikvm: Could not find class 'com.google.firebase.FirebaseOptions', referenced from method com.google.firebase.FirebaseApp.<init> 06-03 01:36:29.617 2655-2655/mobapps.mypersonal.biz.grouptracker E/dalvikvm: Could not find class 'com.google.firebase.FirebaseApp$zzb', referenced from method com.google.firebase.FirebaseApp.zzaJ 06-03 01:36:29.621 2655-2655/mobapps.mypersonal.biz.grouptracker E/dalvikvm: Could not find class 'com.google.firebase.FirebaseApiNotAvailableException', referenced from method com.google.firebase.FirebaseApp.getToken 06-03 01:36:29.629 2655-2655/mobapps.mypersonal.biz.grouptracker E/dalvikvm: Could not find class 'com.google.firebase.FirebaseApp$zza', referenced from method com.google.firebase.FirebaseApp.zza 06-03 01:36:29.639 2655-2655/mobapps.mypersonal.biz.grouptracker E/AndroidRuntime: FATAL EXCEPTION: main
Process: mobapps.mypersonal.biz.grouptracker, PID: 2655
java.lang.NoClassDefFoundError: com.google.firebase.FirebaseOptions
at com.google.firebase.FirebaseApp.zzbu(Unknown Source)
at com.google.firebase.provider.FirebaseInitProvider.onCreate(Unknown Source)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1656)
at android.content.ContentProvider.attachInfo(ContentProvider.java:1627)
at com.google.firebase.provider.FirebaseInitProvider.attachInfo(Unknown Source)
at android.app.ActivityThread.installProvider(ActivityThread.java:5079)
at android.app.ActivityThread.installContentProviders(ActivityThread.java:4653)
at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4593)
at android.app.ActivityThread.access$1500(ActivityThread.java:151)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1402)
at android.os.Handler.dispatchMessage(Handler.java:110)
at android.os.Looper.loop(Looper.java:193)
at android.app.ActivityThread.main(ActivityThread.java:5363)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:828)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:644)
at dalvik.system.NativeStart.main(Native Method)
This is what solved the problem for me:
Add compile 'com.android.support:multidex:1.0.2' to
app/build.gradle.
Add android:name="android.support.multidex.MultiDexApplication" to the application tag in AndroidManifest.xml.
If you are using a custom Application class, skip the
AndroidManifest.xml and make your Application class extend MultiDexApplication instead of Application.
This bug is reported with newer versions mostly arround Revision 28,29 and its resolved in newer Play services versions so if you having this issue then make sure you have updated version of Google Play service in your Android studio. as older versions have it. To update Play services version..
Follow these steps:
Go to Android SDK Manager
Go to Extra here you will find as shown in image below, update it to latest version and try to run project.
Then if you are using MultiDex in your Application,then make sure you have correctly done it.
In you App level Build.Gradle file use this code multiDexEnabled true
defaultConfig {
applicationId "com.reversebits.tapanhp.saffer"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
multiDexEnabled true
}
Apply MultiDex dependency in dependencies inside Same file.
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.google.android.gms:play-services:9.4.0'
compile 'com.android.support:multidex:1.0.1'
}
Then inside your AndroidMenifest.xml file make sure that Application tag have name of MultiDexApplication.
<application
android:name="android.support.multidex.MultiDexApplication"
android:allowBackup="true">
Note
if you have your own Application class and you are using it in your menifest file then you can initialize multidex in your Application class as follows,
public class AppClass extends Application {
//this will initialize multidex in your own Application class
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
Thanks to TapanHP above I got this working quickly for me:
Short Answer:
I had multiDexEnabled= true set in my app/build.gradle file and this ran fine on Android 5.x.x above but any test device with 4.x.x (kit kat) would throw a critical error "Unfortunately, YourAppName has stopped."
Debugger showed:
Could not find class 'com.google.firebase.FirebaseOptions' ....
Note: I also have a custom class that extends Application.
My Solution:
Added the following code to my custom Application class
import android.support.multidex.MultiDex;
public class YourCustomApplication extends Application {
#Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
...
}
No more critical crash.
I have the same problem, with this I have solved:
https://stackoverflow.com/a/37364044
You must replace android:name=".app" with android:name="android.support.multidex.MultiDexApplication"
I'm trying to add Espresso testing framework to my project. However, I'm stuck with this NoClassDefFoundError for 3 days. After searching over Google I found testing APK is using by default the DEBUG build type. For some reason I need to set Proguard on for debug build type. However, I get the following error when running my test configuration:
06-02 15:27:01.105 19436-19457/com.lingyue.YqgAndroid E/TestLoader: Could not find class: android.support.test.espresso.base.UiControllerModule_ProvideUiControllerFactory
06-02 15:27:01.107 19436-19457/com.lingyue.YqgAndroid I/art: Rejecting re-init on previously-failed class java.lang.Class<android.support.test.espresso.core.deps.dagger.internal.Factory>
06-02 15:27:01.107 19436-19457/com.lingyue.YqgAndroid I/art: Rejecting re-init on previously-failed class java.lang.Class<android.support.test.espresso.base.ViewFinderImpl_Factory>
06-02 15:27:01.107 19436-19457/com.lingyue.YqgAndroid I/art: Rejecting re-init on previously-failed class java.lang.Class<android.support.test.espresso.base.ViewFinderImpl_Factory>
06-02 15:27:01.109 19436-19457/com.lingyue.YqgAndroid E/TestLoader: Could not find class: android.support.test.espresso.base.ViewFinderImpl_Factory
06-02 15:27:01.114 19436-19457/com.lingyue.YqgAndroid I/art: Rejecting re-init on previously-failed class java.lang.Class<android.support.test.espresso.core.deps.dagger.internal.Factory>
06-02 15:27:01.115 19436-19457/com.lingyue.YqgAndroid E/AndroidRuntime: FATAL EXCEPTION: Instr: android.support.test.runner.AndroidJUnitRunner
Process: com.lingyue.YqgAndroid, PID: 19436
java.lang.NoClassDefFoundError: android.support.test.espresso.core.deps.dagger.internal.Factory
at java.lang.Class.classForName(Native Method)
at java.lang.Class.forName(Class.java:324)
at android.support.test.internal.runner.TestLoader.doLoadClass(TestLoader.java:92)
at android.support.test.internal.runner.TestLoader.loadIfTest(TestLoader.java:113)
at android.support.test.internal.runner.TestRequestBuilder.loadClassesFromClassPath(TestRequestBuilder.java:801)
at android.support.test.internal.runner.TestRequestBuilder.build(TestRequestBuilder.java:747)
at android.support.test.runner.AndroidJUnitRunner.buildRequest(AndroidJUnitRunner.java:354)
at android.support.test.runner.AndroidJUnitRunner.onStart(AndroidJUnitRunner.java:260)
at android.app.Instrumentation$InstrumentationThread.run(Instrumentation.java:1879)
My build.gradle looks likes this for dependencies:
dependencies {
compile "com.android.support:cardview-v7:${supportVersion}"
compile "com.android.support:recyclerview-v7:${supportVersion}"
compile 'com.nostra13.universalimageloader:universal-image-loader:1.9.3'
compile 'com.loopj.android:android-async-http:1.4.9'
compile 'com.qiniu:qiniu-android-sdk:7.0.9'
compile 'com.mcxiaoke.gradle:packer-helper:1.0.4'
compile 'me.henrytao:smooth-app-bar-layout:23.2.1.1'
compile 'com.alipay.euler:andfix:0.4.0#aar'
compile 'com.umeng.analytics:analytics:6.0.0'
compile fileTree('libs')
compile project(':framework')
compile project(':yqdsdk')
// Only needed at compilation
provided 'com.google.dagger:dagger-compiler:2.0'
provided 'org.glassfish:javax.annotation:10.0-b28'
// For testing
androidTestCompile "com.android.support:support-annotations:${supportVersion}"
androidTestCompile 'com.android.support.test:runner:0.5'
androidTestCompile 'com.android.support.test:rules:0.5'
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') {
exclude group: 'javax.inject'
}
}
Build Types look like the following:
buildTypes {
debug {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
testProguardFile 'test-proguard-rules.pro'
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
testProguardFile.pro looks like this:
-dontobfuscate
-dontwarn
What I've done:
If I switch Proguard off for debug build by setting minifyEnabled=false, the test runs successfully. I get the error above otherwise.
I tried to put testProguardFile under "defaultConfig" and "debug", but to no avail both.
I tried to add one more build type "uiTest" with Proguard off, but the test configuration won't work after I set testBuildType to "uiTest". The error is that Android Studio won't recognise the test runner AndroidJUnitRunner.
It seems to me the problem comes with the mix use of proguard and dagger2 but I'm running out of ideas. Please help.
Best wishes
After doing more research, I found a solution for this problem although which is not straight forward:
Add a new build type and sync the build the project, e.g.
uiTest {
minifyEnabled true
}
On the left down side of the Android Studio, click on "Build Variants". For your application module, choose the newly added build variant, e.g. "UiTest".
Run the application.
This is somewhat inconvenient because you need to switch back and forth when you need to test under different build variants. But it gets Expresso running.
I had a similar problem and was able to fix it by adding the following rule to the proguard-rules.pro:
-keep class javax.inject.** { *; }
I'm not entirely sure your issue is the same though.
Also I'm not sure that you need to exclude javax.inject group from espresso-core dependency.