microsoft / ApplicationInsights-Android

Microsoft Application Insights SDK for Android

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Failing tests when including the library

romainpiel opened this issue · comments

When including application insights in our project, our robolectric tests are failing:

java.lang.RuntimeException: Could not find any resource  from reference ResName{com.myapp:style/Theme_AppCompat_Light_NoActionBar} from style StyleData{name='AppTheme_Base', parent='Theme_AppCompat_Light_NoActionBar'} with theme null
    at org.robolectric.shadows.ShadowAssetManager$StyleResolver.getParent(ShadowAssetManager.java:456)
    at org.robolectric.shadows.ShadowAssetManager$StyleResolver.getAttrValue(ShadowAssetManager.java:394)
    at org.robolectric.shadows.ShadowResources.getOverlayedThemeValue(ShadowResources.java:294)
    at org.robolectric.shadows.ShadowResources.findAttributeValue(ShadowResources.java:283)
    at org.robolectric.shadows.ShadowResources.attrsToTypedArray(ShadowResources.java:186)
...
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1145)
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:615)
    at java.lang.Thread.run(Thread.java:724)

At first glance it looks like an issue related to Robolectric but we're using plenty other aar libraries and we don't have this issue. Removing the dependency to application insights fixes the issue. So I'm wondering if it could be related to the content of the manifest or something...

The only way I found to fix the issue is to put this dirty hack in our gradle.properties:

android.library.reference.1=../app/build/intermediates/exploded-aar/com.microsoft.azure/applicationinsights-android/1.0-beta.3

It looks pretty similar to this issue although support libraries don't complain for me.

Oh right, this is because of the dependency to appcompat-v7. I could fix the issue by excluding it:

compile ('com.microsoft.azure:applicationinsights-android:1.0-beta.3') {
    exclude group: 'com.android.support', module: 'appcompat-v7'
}

Any reason why app insights depends on appcompat?

Hi Romain,

you're right, it's the compat-lib.
I'm investigating the dependency right now because I don't think it's required anymore (it used to be a required dependency in an earlier version).

By the way: our beta.4 is available since yesterday, let us know if you run into any issues. :)

awesome! will do, thanks

The dependency to compat lib has been moved to the sample project.