jakewharton Espresso Idling Resource won't import - android

I'm writing tests using okhttp3, mockwebserver, and retrofit2 in Android/Kotlin.
Everything I look up tells me to use the jakewharton idling resource, but it will not import into my project.
I got the info straight from Jake Wharton's github
Screenshot of my build.gradle
Is there anything I can do to fix this?
Are there decent alternatives to adding this type of idle resource to my test suite?

It looks like the build.gradle dependencies no longer support androidTestCompile.
The dependency should switch from:
androidTestCompile 'com.jakewharton.espresso:okhttp3-idling-resource:1.0.0'
to
androidTestImplementation 'com.jakewharton.espresso:okhttp3-idling-resource:1.0.0'

Related

Android: Twitter sdk: cannot import any twitter class

I'm want to implement Twitter login in my app, but I can't import any of the related classes.
In my gradle I added:
implementation 'com.twitter.sdk.android:twitter:3.3.0'
gradle sync works fine, app compiles and run, but I'm not able to import any of the com.twitter classes like TwitterConfig. If I write "Twitter" and let Android Studio suggest me the only option I get are TwitterAuthCredential and TwitterAuthProvider both from com.google.firebase.auth.
What is going on? Am I missing some gradle line?
I managed to solve it importing only the dependecies I needed:
implementation 'com.twitter.sdk.android:twitter-core:3.3.0'
implementation 'com.twitter.sdk.android:tweet-ui:3.3.0'
implementation 'com.twitter.sdk.android:tweet-composer:3.3.0'
implementation 'com.twitter.sdk.android:twitter-mopub:3.3.0'
It migth be related to the large size of the library.

androidTestUtil in a library

I have a library that contains test-butler. So in the library I do.
implementation 'com.linkedin.testbutler:test-butler-library:2.1.0'
and in the app consuming this library I do:
androidTestImplementation 'com.github.mylib...'
now I am wondering how I could do the same for androidTestUtil - would like that the dependency:
androidTestUtil 'com.linkedin.testbutler:test-butler-app:2.1.0'
comes via the lib and does not need to be stated in the app.
I don't think this is directly possible unfortunately. The only thing I can think of is having a custom Gradle plugin that the app uses and having the plugin depend on AGP and add the androidTestUtil dependency on the Test Butler app. That seems very unnecessary though, and doesn't really save you much over the app just adding the dependency directly.

More than one file was found with OS independent path 'mockito-extensions/org.mockito.plugins.MockMaker'

More than one file was found with OS independent path 'mockito-extensions/org.mockito.plugins.MockMaker' getting this error while adding
androidTestImplementation "org.mockito:mockito-inline:2.15.0"
in gradle to mock final class
For Android, you usually just want
androidTestImplementation "org.mockito:mockito-android:<latest-version>"
You especially don't want mockito-inline because it configures the wrong MockMaker (mock-maker-inline) instead of AndroidByteBuddyMockMaker which is the only one working on Android that is distributed by the Mockito project. If you need advanced capabilities or faster mocking, head over to the dexmaker project.
In my case I resolved this issue by removing dexmaker dependency from the build.gradle
So, I removed the below dependency
androidTestImplementation "com.linkedin.dexmaker:dexmaker-mockito:2.12.1"
and kept only the below Mockito dependency
androidTestImplementation "org.mockito:mockito-android:2.25.0"
Not sure if that your case, but it solves mine.
If you are using Koin dependency injector, I found the solution on this Github issue.
Try androidTestImplementation ("org.koin:koin-test:$koin_version") { exclude group: 'org.mockito' }
It worked for me, I hope this may help others in the future.
The only correct answer is PowerMockito does not support the Davik VM Android uses, it is meant for a standard JVM. So you can't use it with instrumented tests, only unit tests. I have heard there's a library called OpenDex that allows you to use PowerMockito even with Android but it seems a bit involved to setup and I haven't personally tried it.

How to use Transform api in gradle?

I am new to Gradle, I'm now trying to use AOP to design a plugin that can manipulate bytecode. And I'm now trying to use transform APIļ¼Œ however I cannot get the correct library imported, like TransformManager, etc.
I know this question is a little dumb but I don't really know what to do with it... So for the following, I just copied and pasted the code from the source I'm learning from, but It's the same when I'm writing the code myself, I can't import the correct library, instead, the auto-import is
import org.apache.tools.ant.taskdefs.Transform which I didn't find in the transform api.
Can anybody explain why? and how can I solve it?
Lack of dependence,add libraries into plugin_demo/build.gradle
dependencies {
implementation gradleApi()
implementation localGroovy()
//android gradle plugin libraries
implementation 'com.android.tools.build:gradle:3.3.0'
implementation 'com.android.tools.build:gradle-api:3.3.0'
}

RxJavaHooks cannot be resolved in my android unit testing

In my android unit testing file, I am doing this import:
import rx.plugins.RxJavaHooks;
as I need to use RxJavaHooks.
In my gradle file, i have added the dependency for RxJava and RxAndroid:
compile "io.reactivex:rxandroid:$RXANDROID_VERSION"
compile "io.reactivex:rxjava:$RXJAVA_VERSION"
Still, I get an error that RxJavaHooks cannot be resolved. Can someone help me with this. Thanks
rx.plugins.RxJavaHooks is an artifact of RxJava 1.x.
the group part of the coordinates of your dependencies (io.reactivex) indicates you are using RxJava 2.x, which is why the class you're looking for isn't available.
(fyi - RxJava 1.x classes uses the rx namespace)
according to the docs you should use RxJavaPlugins:
The class-based RxJavaObservableHook and friends are now gone and
RxJavaHooks functionality is incorporated into RxJavaPlugins.

Categories

Resources