Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Upgrade some dependencies #403

Merged
merged 7 commits into from
Jul 10, 2024

Conversation

joggee-fr
Copy link
Contributor

A small (first) step to update the dependencies of the project.

@justin-stephenson
Copy link
Contributor

Thank you for the PR @joggee-fr

It looks like mockito needs to be updated as well

Starting 210 tests on test(AVD) - 10
Test run failed to complete. Expected 210 tests, received 206. Time: 158.622
There was 1 failure:
1) org.fedorahosted.freeotp.TokenAdapterTest
org.mockito.exceptions.base.MockitoException:
Mockito cannot mock this class: class android.content.Context.

https://github.com/freeotp/freeotp-android/actions/runs/9714722536/job/26814449772?pr=403

Done by the AGP Upgrade Assistant in Android Studio.
As recommended by the AGP Upgrade assistant in Android Studio.
Instead of also using org.jetbrains.annotations.
Added in commit 64ea85a but does not seem to be
used in project.  However, it was hiding an issue with Kotlin functions import
from io.fotoapparat. Directly add Kotlin stdlib as dependency to fix it.  Check
out RedApparat/Fotoapparat#370 for details.
FreeOTP does not use local JAR as dependencies. It just seems an old directive
from Android Studio default template which has been removed now. Check
https://issuetracker.google.com/issues/145977222.
Minor release and changes from 2.1.3.
@joggee-fr
Copy link
Contributor Author

Thanks @justin-stephenson. I will check this issue but I need to understand a bit more how these Mockito tests run first.

Upgrade Mockito from 2.23.0 to 2.24.0 to avoid the following issue:
org.mockito.exceptions.base.MockitoException: Mockito cannot mock this class:
class android.content.Context.  Underlying exception :
java.lang.IllegalArgumentException: On Android P, a class injection can only be
applied to BaseDexClassLoader:
net.bytebuddy.dynamic.loading.MultipleParentClassLoader@23f7dce

Looking at Mockito 2.x release notes:
https://github.com/mockito/mockito/blob/release/2.x/doc/release-notes/official.md

- Previous issue may have been fixed in later 2.23.18 published on now
  unavailable Mockito Bintray repository. Consequently, move to 2.24.0 release
available on Maven Central.
- It seems that from 2.23.13 and androidx.test support added, tests are now
  launched in a dedicated instrumentation thread that does not prepare an
Android Looper. But as Adapter class will instatiate an Android Handler, even
if not needed for the tests, the following error is encountered:
java.lang.RuntimeException: Can't create handler inside thread Thread[Instr:
androidx.test.runner.AndroidJUnitRunner,5,main] that has not called
Looper.prepare()
Consequently, force the Looper to be prepared once before tests.
@joggee-fr
Copy link
Contributor Author

@justin-stephenson, my last commit should fix the issue observed with token adapter tests.
I may open later a new PR to really upgrade the test dependencies as it should not impact the distributed application.

@justin-stephenson
Copy link
Contributor

Thank you very much @joggee-fr PR looks good to me!

@justin-stephenson justin-stephenson merged commit b28c593 into freeotp:master Jul 10, 2024
2 checks passed
@joggee-fr joggee-fr deleted the jg/dependencies branch July 14, 2024 20:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants