Robolectric Samples and Gradle Plugin - android

In Robolectric sample project, there is no gradle plugin set up in build.gradle. For instance for AppCompat-v7
On the other hand we have Robolectric gradle plugin which as documentation says:
A Gradle plugin which enables Robolectric tests.
This plugin piggy-backs on the unit testing support added in version
1.1.0 of the Android Gradle plugin and configures the test tasks to work correctly with Robolectric.
I wonder why in Robolectric sample project there is no sign of Robolectric Gradle Plugin.
If we can run robolectric tests without the plugin in Android Studio using gradle wrapper, then what is the exact usages of Plugin?

Main reason is that this plugin isn't necessary and will be marked as deprecated if robolectric 3.0 get final. This is a statement from robolectric maintainer erd. See first answer at https://github.com/robolectric/robolectric-gradle-plugin/issues/148

Related

React Native: What's the difference between gradle references in gradle-wrapper.properties and build.gradle?

In my React Native app, I got an error about incompatibilities with gradle 6, so I looked in my project structure to find out which version of gradle I was running in my project. I found this line in gradle-wrapper.properties
distributionUrl=https\://services.gradle.org/distributions/gradle-5.5-all.zip
and this line in build.gradle
classpath("com.android.tools.build:gradle:3.4.2")
What I Want To Know: What's the difference between the reference to gradle in each of these files? In other words, how is version 5.5 being used in my project, and how is 3.4.2 being used?
distributionUrl represents Gradel Version where as classpath represents Android Gradle plugin version.
Gradel vs Android Gradle plugin: Reffer this difference between android gradle plugin and gradle
Gradle is the build system.
You can use it with a lot of plugins. One of these is the plugin for Android.
It is used to provide processes and configurable settings that are specific to building and testing Android applications.
For greater details and mapping of the above two type of versions refer the following URLs
https://developer.android.com/studio/releases/gradle-plugin#updating-gradle
https://developer.android.com/studio/releases/gradle-plugin#updating-plugin
I hope this answer has cleared your doubts.

Failed to build when using fragment testing library on AndroidGradlePlugin 3.5.0 and above for Dynamic Feature module

So, I was trying to use fragment testing library androidx.fragment:fragment-testing:1.2.4 in a dynamic feature module. When I used Android Gradle Plugin (AGP) version 3.6.3, it failed to build with an error
AAPT: error: resource style/FragmentScenarioEmptyFragmentActivityTheme (aka com.example.reminder.test:style/FragmentScenarioEmptyFragmentActivityTheme) not found.
And so I was curious and checkout the codelab github and try to upgrade the AGP on that project to 3.6.3 and it can build successfully. But the codelab does not use Dynamic Features.
So I tried to actually run a fragment test in my app module only (excluding the dynamic features module) and yes it can build successfully too.
But I still need to test my fragment in the dynamic features module, so I tried playing with the version one by one and then when I downgrade the AGP version to 3.4.1 it can build successfully.
And I found out that since AGP version 3.5.0 and above, it just failed to build with the same error above.
So,
AGP 3.5.0 and above:
- Building test on app module only -> works
- Building test on dynamic features -> failed to build
AGP 3.4.2 and below:
- Building test on app module only -> works
- Building test with dynamic features -> works
But I still want to use AGP 3.6.0 because I want to utilise viewBinding.
So does anyone know how to resolve the error above for fragment testing with dynamic features module?
Upgrading AGP to 4.0.0 and above should resolve the issue.

Android gradle build issue

strong textI getting the below error, even though I removed "apt" from the gradle files.
android-apt plugin is incompatible with the Android Gradle plugin.
Please use 'annotationProcessor' configuration instead.
Currently using gradle 3.1.0

Which version of android gradle plugin i can use with gradle 2.14?

I found a table here http://tools.android.com/tech-docs/new-build-system/version-compatibility but it has no entry for gradle 2.14. I am trying to build an app without an IDE with gradle
but it has no entry for gradle 2.14
Do not use Gradle 2.14. Use Gradle 2.14.1. If Gradle issues a patch level release, that's probably due to a critical bug.
Then, you are covered by the last row in the table, simulated below because Stack Overflow does not like teh tabelz:
Android Gradle Plugin Requires Gradle
2.1.3+ 2.14.1+
So, if you want to use Gradle 2.14.1, use version 2.1.3 or higher of the Android Plugin for Gradle.

Android gradle build that code coverage for robolectric tests

Is there a way to to have a gradle build that will generate code coverage from robolectric test that can be sent to sonar?
As far as I can tell: At this time, No.
In order to have code coverage you need Emma support and that's not yet fixed in the android gradle build plugin. It's supposed to come in version 0.8.+ but it was also "supposed" to come in version 0.6+ so don't hold your breath.
Roadmap: http://tools.android.com/tech-docs/new-build-system/roadmap
Related Emma Issue: https://code.google.com/p/android/issues/detail?id=60964

Categories

Resources