Fixed
Status Update
Comments
jo...@gmail.com <jo...@gmail.com> #2
This time actually attaching the project :)
uc...@google.com <uc...@google.com>
cm...@google.com <cm...@google.com> #3
Yes, we don't merge assets in libraries now for performance reasons. This is a larger change that I don't think will make it in 3.0
jo...@gmail.com <jo...@gmail.com> #4
Could test_config.properties & Robolectric then be updated to accept a set of assetDirs (currently points to a single dir) to workaround this problem? I'll try to find some time to craft a Gradle hack (copying assets) in the meantime as this is a blocker for our migration to AGP 3.0.
jo...@google.com <jo...@google.com> #5
Problem is this means that Robolectric tests won't work for libraries using the new build system api.
I wonder how users test library components now, does AGP generate a BuildConfig.class for libraries?
Is it possible to mitigate / defer the performance concerns and just do the merging if includeAndroidResources = true is specified?
If its not going to be supported in 3.0 we'll need to message it on the Robolectric site and provide some kind of alternative.
I wonder how users test library components now, does AGP generate a BuildConfig.class for libraries?
Is it possible to mitigate / defer the performance concerns and just do the merging if includeAndroidResources = true is specified?
If its not going to be supported in 3.0 we'll need to message it on the Robolectric site and provide some kind of alternative.
cm...@google.com <cm...@google.com> #6
Jerome, can you triage this?
Looking at the code history, I think this never worked, as we never merged assets from dependencies in library subprojects. The AndroidTest variants have their own asset/resource source folders and processing pipeline, so that works fine. If this isn't a regression from 2.3 it's going to be a hard sell for 3.0 at this point.
I think the work involved would be:
- Introduce a second android asset merger task in libraries (maybe in the unit test variant, but doesn't really matter) that includes dependencies
- When includeAndroidResources=true, wire the task dependency and include that in the properties file we pass to roboelectric
Yes, there is a build config class per library, in the same package as the R class, not sure what that has to do with this though.
Hope that helps.
Looking at the code history, I think this never worked, as we never merged assets from dependencies in library subprojects. The AndroidTest variants have their own asset/resource source folders and processing pipeline, so that works fine. If this isn't a regression from 2.3 it's going to be a hard sell for 3.0 at this point.
I think the work involved would be:
- Introduce a second android asset merger task in libraries (maybe in the unit test variant, but doesn't really matter) that includes dependencies
- When includeAndroidResources=true, wire the task dependency and include that in the properties file we pass to roboelectric
Yes, there is a build config class per library, in the same package as the R class, not sure what that has to do with this though.
Hope that helps.
jo...@google.com <jo...@google.com> #7
Parsing the BuildConfig.class was the way the ad-hoc Robolectric integration used to work, obviously we'd like to move to the new includeAndroidResources API, just thinking about workarounds.
je...@google.com <je...@google.com>
im...@google.com <im...@google.com>
jo...@gmail.com <jo...@gmail.com> #8
Still occurs with AGP 3.0 beta 6 running on:
Android Studio 3.0 Beta 6
Build #AI-171.4333198, built on September 13, 2017
JRE: 1.8.0_152-release-915-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.6
with error message:
java.lang.RuntimeException: Font not found at [/Users/jrod/Downloads/ExampleAssetsTest/tests/build/intermediates/bundles/debug/assets/fonts/OpenSans-Regular.ttf]
at org.robolectric.shadows.ShadowTypeface.createFromAsset(ShadowTypeface.java:74)
at android.graphics.Typeface.createFromAsset(Typeface.java)
at com.example.fonts.BaseTextView.<init>(BaseTextView.java:18)
at com.example.fonts.BaseTextView.<init>(BaseTextView.java:11)
at com.example.exampleassetstest.ExampleUnitTest.roboTest(ExampleUnitTest.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
Android Studio 3.0 Beta 6
Build #AI-171.4333198, built on September 13, 2017
JRE: 1.8.0_152-release-915-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.6
with error message:
java.lang.RuntimeException: Font not found at [/Users/jrod/Downloads/ExampleAssetsTest/tests/build/intermediates/bundles/debug/assets/fonts/OpenSans-Regular.ttf]
at org.robolectric.shadows.ShadowTypeface.createFromAsset(ShadowTypeface.java:74)
at android.graphics.Typeface.createFromAsset(Typeface.java)
at com.example.fonts.BaseTextView.<init>(BaseTextView.java:18)
at com.example.fonts.BaseTextView.<init>(BaseTextView.java:11)
at com.example.exampleassetstest.ExampleUnitTest.roboTest(ExampleUnitTest.java:12)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
eu...@gmail.com <eu...@gmail.com> #9
I'm also getting all Robolectric tests failing for the app project where I've just updated android gradle plugin to 3.0.0-beta6 version.
The tip of the stack trace:
android.content.res.Resources$NotFoundException: null
at org.robolectric.android.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:72)
at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:293)
The tip of the stack trace:
android.content.res.Resources$NotFoundException: null
at org.robolectric.android.internal.ParallelUniverse.setUpApplicationState(ParallelUniverse.java:72)
at org.robolectric.RobolectricTestRunner.beforeTest(RobolectricTestRunner.java:293)
eu...@gmail.com <eu...@gmail.com> #10
If I run it from command line my tests are failing with:
java.lang.SecurityException: class "android.databinding.Observable"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(ClassLoader.java:898)
java.lang.SecurityException: class "android.databinding.Observable"'s signer information does not match signer information of other classes in the same package
at java.lang.ClassLoader.checkCerts(ClassLoader.java:898)
cm...@google.com <cm...@google.com> #11
#9, #10 these are not the same issues, please file them separately. #9 should probably be filed in the roboelectric issue tracker with the whole stacktrace and a project that reproduces the issue, and #10 is a known issue with beta6 that will be fixed in beta 7.
cm...@google.com <cm...@google.com> #12
To restate - I don't believe that we ever merged assets in library projects, so this is a feature request that will be looked in the release after 3.0
jo...@gmail.com <jo...@gmail.com> #13
On the other hand, Robolectric's ability to locate assets in Android projects has been broken for a few versions now. Its workaround is to keep changing the file paths based on version of AGP, which is very cumbersome to maintain as consumers of this test library.
On our end, this broke when migrating AGP 2.2 from AGP 2.3. The workaround then was to add a custom GradleManifestFactory that works more like the Maven version (i.e., allows one to declare dependencies via the libraries attribute on the Config annotation).
Migrating from 2.3 to 2.4 (now 3.0) has broken this again, since the previous workaround relied on /exploded-aar and it's unclear how to obtain the correct subfolder in the lib-cache.
Given that the lengthy (understandable) timeline behind AGP 3.0's stable release and that this has been broken for even longer, I'd urge the maintainers to reconsider adding this as a 3.0 bugfix/improvement vs a 3.1 feature request. The Robolectric's inputs depend heavily on the build tools' outputs (code, resources, assets) and the output formats/locations/implementations have all changed a great deal.
On our end, this broke when migrating AGP 2.2 from AGP 2.3. The workaround then was to add a custom GradleManifestFactory that works more like the Maven version (i.e., allows one to declare dependencies via the libraries attribute on the Config annotation).
Migrating from 2.3 to 2.4 (now 3.0) has broken this again, since the previous workaround relied on /exploded-aar and it's unclear how to obtain the correct subfolder in the lib-cache.
Given that the lengthy (understandable) timeline behind AGP 3.0's stable release and that this has been broken for even longer, I'd urge the maintainers to reconsider adding this as a 3.0 bugfix/improvement vs a 3.1 feature request. The Robolectric's inputs depend heavily on the build tools' outputs (code, resources, assets) and the output formats/locations/implementations have all changed a great deal.
jo...@gmail.com <jo...@gmail.com> #14
Any thoughts of fixing this for 3.1?
jo...@gmail.com <jo...@gmail.com> #15
Any thoughts of adding this for 3.2?
cm...@google.com <cm...@google.com> #16
Sorry missed updating this issue. This was implemented in ag/I8e6fc051655a46b20ab10bc40a9377dd60b15b06, assets from dependencies are now merged when running roboelectric tests, and should be in a 3.2 alpha.
sh...@gmail.com <sh...@gmail.com> #17
Fixed
Description
The fix for that issue handles cases test cases run from an application module (:app:testDebug), but tests run from library modules (:lib:testDebug) still fail.
Android Studio 3.0 Beta 5
Build #AI-171.4316950, built on September 5, 2017
JRE: 1.8.0_152-release-915-b01 x86_64
JVM: OpenJDK 64-Bit Server VM by JetBrains s.r.o
Mac OS X 10.12.6
* AGP 3.0-beta5
* Robolectric 3.4.2
* android.testOptions.unitTests.includeAndroidResources=true
* no constants or manifest attribute in @Config.
An example project is attached. Download & run `./gradlew :tests:testDebug`.