Robolectric compilation error while using shadowOf method - android

I am using Robolectric 1.2 in an Andorid 2.3.3 project (API 10)
It throws the below compilation error, when using shadowOf method
ShadowView shadowView = Robolectric.shadowOf(view);
error: cannot access ObjectAnimator
But the error is gone, if I change the android sdk to API 11 and above

I'm still having this issue with 2.2. I got around this by
import static org.robolectric.Robolectric.shadowOf_;
...
ShadowView shadowView = Robolectric.shadowOf_(view);
If anyone could provide some insight why this works, that would be awesome!

After some analysis, found that it is a bug in robolectric.
For now, using 2.0-alpha-1 seems to fix the issue.
Here is the github issue created for the issue
https://github.com/pivotal/robolectric/issues/431

Related

Xamarin Android error on DeviceInfo.Model

I have a Xamarin for Android app that has been working until today. I needed to make a change but before I did, I ran a test to ensure no VS or Nuget package updates caused an issue. I have Xamarin.Essentials in my app and this line worked before, not sure what is happening now.
if(DeviceInfo.Model == "TC72"){scannerIndex = 1;}
Exception Unhandled:
Xamarin.Essentials.NotImplementedInReferenceAssemblyException: 'This
functionality is not implemented in the portable version of this
assembly. You should reference the NuGet package from your main
application project in order to reference the platform-specific
implementation.'
Any insight would be helpful. TIA
I changed the DeviceInfo.Model to Build.Model and get the same info I was expecting. That fixed my issue. If anyone has a different suggestion, happy to entertain them.
Added 8/11/21 3:25pm CT
I also found that changing my Compile Target to 10.0 fixed the Xamarin.Essentials issues. So far the application is working on 8.1 on the device (Zebra MC3300).

Android Webview Chromium UnitTests fail with java.lang.NoSuchMethodError

We are currently facing this NoSuchMethod Error when we want to create the unit test with Robolectric version 4.3.1 and Mockito version 2.18.3
Exceptions:
java.lang.NoSuchMethodError: 'void com.android.webview.chromium.WebViewChromium.<init>(com.android.webview.chromium.WebViewChromiumFactoryProvider, android.webkit.WebView, android.webkit.WebView$PrivateAccess, boolean)'
Here is the code we did:
mWebView = Mockito.spy(
new WebviewChromium(
mockWebViewChromiumProvider, webView, webView.new PrivateAccess(), false));
In BUILD.gn, we have included the "//android_webview/glue:glue_java" as dependency, we can successfully compile the code but it sounds like in the runtime, it refers to the another wrong jar, does someone know how to config the build file to use the correct jar or any ideas about how to solve this error?
did you check this followjng thread https://github.com/robolectric/robolectric/issues/5092 and this one I think you need open jdk 11 or 13 I recently had the same issue after adding open jdk 13 to android studio it solved my problem robolectric started working fine you can check following thread as well https://github.com/robolectric/robolectric/issues/5092

Android: PlaybackOverlayFragment not working

I am working on an Android TV app and when I have started working on the project code it throws an error for PlaybackOverlayFragment, stating it cannot resolve symbol PlaybackOverlayFragment
public class PlaybackOverlayFragment extends android.support.v17.leanback.app.PlaybackOverlayFragment
currently in my gradle file it reads :
compile 'com.android.support:leanback-v17:27.1.1'
The original project was in compile sdk version 26 and I upgraded it to 27, is this throwing error because of it?
PlaybackOverlayFragment was deprecated some time ago and then completely removed in v27.
You should move away from deprecated API as soon as possible because they may be removed any time in the future.
The doc says you shoud use PlaybackFragment instead which was also deprecated in 27.1.0... So now you should use PlaybackSupportFragment
Source: https://developer.android.com/reference/android/support/v17/leanback/app/PlaybackFragment

Gesture Builder in API 27

I try to learn Gesture Handling in Android and I tried this tutorial: www.techotopia.com/index.php/Implementing_Android_Custom_Gesture_Recognition_with_Android_Studio
My problem is, that I can not download Samples for SDK in my Android Studio 3.0.1 because there is just no option called like that:
So I tried this App on Appstore: https://play.google.com/store/apps/details?id=pack.GestureApp
But when I try to read the file like this:
gLibrary = GestureLibraries.fromRawResource(this, R.raw.gesture);
the gLibrary is always empty.
So I tried to find the official Gesture Builder Application here: https://developer.android.com/samples/index.html and in Android Studio: File/New/Import Sample:
as u can see, nothing there too.
I also tried to get a old (API 17) version running: https://github.com/Miserlou/Android-SDK-Samples
but I just got errors over and over again.
So lets get to my question. How to build a gesture file today with API 26/27 or how to get the old Gesture Builder (running).
I solve this problem by downloading all API 27 package

Robolectric - How to clean up message: "WARNING: unknown service autofill"

During my tests with Robolectric, I always get a warning message in console (no LogCat) with says: "WARNING: unknown service autofill".
Does Anyone know what to do to clean it up?
Thanks in advance.
You can set the sdk version to 25. Thereby the tests will run against api level 25. The warnings should be removed/implemented in future robolectric versions.
To set the sdk version see: http://robolectric.org/configuring/
The following configurations worked for me,
#Config(sdk = 21)
public class MyClassTests {
/* testCodeHere */
}
Other sdk Config that worked fine =
#Config(sdk = 22)
#Config(sdk = 23)
#Config(sdk = 24)
#Config(sdk = 25)
This error happens when running tests against sdk = 26.
Therefore, as #Moritz suggested,
change the sdkVersion in your tests or create a robolectric.properties file, Configuring Robolectric.
I upgraded from SDK 24 to 26 and began seeing this error. Going back to SDK 25 didn't seem like a good solution so I tried upgrading Robolectric to its latest stable version.
At time of writing this is version 3.8.
https://mvnrepository.com/artifact/org.robolectric/robolectric/3.8
This fixed the problem for me.
From the sounds of it, they fixed this in 3.7
https://github.com/robolectric/robolectric/releases/

Categories

Resources