GithubHelp home page GithubHelp logo

Android support about wiremock HOT 43 CLOSED

yogurtearl avatar yogurtearl commented on August 19, 2024
Android support

from wiremock.

Comments (43)

tomakehurst avatar tomakehurst commented on August 19, 2024 1

Hi David,

I'm always interested to receive useful feedback.

Have you discovered some specific bugs? If so, would you mind raising them as Github issues?

Many thanks,
Tom

from wiremock.

handstandsam avatar handstandsam commented on August 19, 2024 1

Looks like you hit Multidex issues for the test apk. Try on a 21+ device and it should work.

from wiremock.

tomakehurst avatar tomakehurst commented on August 19, 2024

It's not on the list currently. Is there a reason you can't run it on your laptop and point the Android app at that?

from wiremock.

stephanenicolas avatar stephanenicolas commented on August 19, 2024

Usually, a mock server runs on the Android device itself. I can't say for @tomakehurst , but such a usage (on a desktop) while the android tests run on device/emulator would be quite tough to setup and even more to industrialize.

The best solution is really to be able to run the mock web server on the device itself.

from wiremock.

tomakehurst avatar tomakehurst commented on August 19, 2024

I'm surprised to hear that. I'd be interested to know why this is difficult.

I haven't done all that much mobile development, but when I have there's always been a server available over wi-fi in the test setup, and when I've needed mock responses I've run hosted them on this.

If an Android build would be genuinely helpful, then I'm more than happy to have this as part of the project. I probably lack the experience with Android development to make this happen any time soon though, so I'd welcome any contributions in this area.

from wiremock.

stephanenicolas avatar stephanenicolas commented on August 19, 2024

Suppose you use an Android and a laptop on the same WAN. Chances are that
the router will isolate hosts, and then that's over. Moreover, from an
industrialization perspective, it would be very hard to inject the ip
adress of the CI server into the app under test on an emulator/device.

The best is really to embed the webserver.

2013/10/8 tomakehurst [email protected]

I'm surprised to hear that. I'd be interested to know why this is
difficult.

I haven't done all that much mobile development, but when I have there's
always been a server available over wi-fi in the test setup, and when I've
needed mock responses I've run hosted them on this.

If an Android build would be genuinely helpful, then I'm more than happy
to have this as part of the project. I probably lack the experience with
Android development to make this happen any time soon though, so I'd
welcome any contributions in this area.


Reply to this email directly or view it on GitHubhttps://github.com//issues/53#issuecomment-25881086
.

Stéphane NICOLAS,
OCTO Technology
Développeur & Consultant Android / Java
..........................................................
50, Avenue des Champs-Elysées
75008 Paris
+33 (0)6.26.32.34.09
www.octo.com - mobilite.octo.com
blog.octo.com - www.usievents.com
...........................................................

from wiremock.

tomakehurst avatar tomakehurst commented on August 19, 2024

Certainly if your routers behave like that and your network team won't help out then that's a problem. My experience has been that you can usually find a way to get wi-fi working how you need it (even if it means setting your laptop up as an ad-hoc network).

I've handled the IP resolution issue in a couple of ways in the past: 1) by configuring local DNS to return the test server, 2) by creating an extra settings field for the server host which is only visible in dev builds.

from wiremock.

stephanenicolas avatar stephanenicolas commented on August 19, 2024

That's fine for me Tomas. Sorry to have disturbed, but on Android I prefer
to use mockwebserver. It's easier to handle according to my experience.

2013/10/8 tomakehurst [email protected]

Certainly if your routers behave like that and your network team won't
help out then that's a problem. My experience has been that you can usually
find a way to get wi-fi working how you need it (even if it means setting
your laptop up as an ad-hoc network).

I've handled the IP resolution issue in a couple of ways in the past: 1)
by configuring local DNS to return the test server, 2) by creating an extra
settings field for the server host which is only visible in dev builds.


Reply to this email directly or view it on GitHubhttps://github.com//issues/53#issuecomment-25884975
.

Stéphane NICOLAS,
OCTO Technology
Développeur & Consultant Android / Java
..........................................................
50, Avenue des Champs-Elysées
75008 Paris
+33 (0)6.26.32.34.09
www.octo.com - mobilite.octo.com
blog.octo.com - www.usievents.com
...........................................................

from wiremock.

letz avatar letz commented on August 19, 2024

Any developments regarding mock web server in the device itself?

from wiremock.

yogurtearl avatar yogurtearl commented on August 19, 2024

It is possible with a bit of work. :)

from wiremock.

letz avatar letz commented on August 19, 2024

can you give me some guidelines?

from wiremock.

tomakehurst avatar tomakehurst commented on August 19, 2024

I'm considering a refactoring to support multiple web servers, such that the Android fork of Jetty could be used. I'll start a discussion about this on the Google group, perhaps you'd all like to join so that you can participate?

from wiremock.

letz avatar letz commented on August 19, 2024

thats fine be me :)

from wiremock.

letz avatar letz commented on August 19, 2024

@tomakehurst any developments?

from wiremock.

tomakehurst avatar tomakehurst commented on August 19, 2024

I've just started a new job, so I've had no time to work on this.

Can I suggest you join the mailing list if you haven't already? I'm planning to start a thread about what to include in the next wave of development.

from wiremock.

letz avatar letz commented on August 19, 2024

I already joined the mailing list. Meanwhile @yogurtearl can you explain how did you do it?

from wiremock.

tomakehurst avatar tomakehurst commented on August 19, 2024

I'd also be very interested to hear about this (preferably on the mailing list!).

from wiremock.

objcode avatar objcode commented on August 19, 2024

Also looking into this. +1 on adding it out of box.

from wiremock.

objcode avatar objcode commented on August 19, 2024

I did part of the work to get it to run on Android:

#178

You'll still need to update the javax dependencies that aren't available on Android. I'm going to go down the path of hosting it on the desktop of my emulator for now.

from wiremock.

RodneyU215 avatar RodneyU215 commented on August 19, 2024

+1 on adding it out of box.

I've been having some trouble getting it configured properly as well. I'd love to hear how @yogurtearl got it working. He mentioned it again recently during his presentation at GTAC 2014. (Fast forward to 29:15)

from wiremock.

tomakehurst avatar tomakehurst commented on August 19, 2024

He's keeping his cards close to his chest on that one :-)

We're a few steps closer to OOTB Android support with the logging changes that went in recently. Just need to find the time for a final push.

from wiremock.

indraneel76 avatar indraneel76 commented on August 19, 2024

Hi

I tried integrating wiremock standalone jar with my android project and got error where its complaining about missing javax.naming.ldap.LdapName'.

02-05 04:01:50.100: E/dalvikvm(2944): Could not find class 'javax.naming.ldap.LdapName', referenced from method wiremock.org.apache.http.conn.ssl.AbstractVerifier.extractCNs

from wiremock.

indraneel76 avatar indraneel76 commented on August 19, 2024

I think I have got a bit of success now using Objcode's modification. I have not used gradle to build the android project but instead not the jars manually and built the android project.

You can access the android project at https://www.dropbox.com/s/ityzj8co7k0yrgt/MyProjectWithWireMock.zip?dl=0

This are the steps to run the program -

  1. unzip the file from dropbox and import it into eclipse as android project
  2. start the standalone wiremock on the laptop -
    java -jar wiremock-1.53-standalone.jar --port 8888 --verbose
  3. Run the android project on a emulator
  4. The small app should open up on emulator with SendRequest button
  5. click on sendRequest button and you would see a response from WireMock.

To run this on real device , you need to change 10.0.2.2 (the way emulator sees the laptop) to actual ip address of the laptop . both real device and laptop needs to be on wifi.

I hope it helps some one..

I also tried running wiremock as server on android device itself , but that failed due to some jetty issues (i have put jetty jar in libs folder of android .. but showed link to class error)

from wiremock.

tomakehurst avatar tomakehurst commented on August 19, 2024

Thanks for posting this.

Unfortunately, some of the libraries used by WireMock don't work on the Android JVM. Some other folks have had some success with private Android forks, including @yogurtearl , but I've not yet found the time to create an official one, although I'd like to do this.

from wiremock.

indraneel76 avatar indraneel76 commented on August 19, 2024

Finally Thanks to Tom for making this wonderful tool and Sean (objcode) for making it android compatible. It is a very useful tool for me ...and would save lot of time in developing android app.

from wiremock.

arkangelx avatar arkangelx commented on August 19, 2024

Hi, getting this error and others
02-16 15:18:26.133: E/AndroidRuntime(7180): java.lang.NoClassDefFoundError: org.mortbay.jetty.Server
02-16 15:18:26.133: E/AndroidRuntime(7180): at com.github.tomakehurst.wiremock.WireMockServer.start(WireMockServer.java:178)

from wiremock.

tomakehurst avatar tomakehurst commented on August 19, 2024

As I mentioned earlier in this thread, WireMock does not currently work with Android without modification.

from wiremock.

flyfeihuang avatar flyfeihuang commented on August 19, 2024

So bad ,I try it run in Andriod platform two days,but it don't work

from wiremock.

indraneel76 avatar indraneel76 commented on August 19, 2024

Hi
I can help you on this as the error looks familiar to me
.. you need to get some lib files in your directory like jetty
go to https://www.dropbox.com/s/ityzj8co7k0yrgt/MyProjectWithWireMock.zip?dl=0

unzip the zip file , there will be a libs folder inside . Get those libs as reference in your project as well
Also do have a folder in your project called libs with all those jars. Android run time picks up jars from libs folder . Your error points out that it didn't get jetty jar file . Reply back if you still have issues..

enjoy
Indraneel

from wiremock.

mike011 avatar mike011 commented on August 19, 2024

Updated for android studio, junit4, and espresso.

https://github.com/mike011/Wiremock_Android_Example

from wiremock.

tomakehurst avatar tomakehurst commented on August 19, 2024

Looks interesting, thanks for sharing!

from wiremock.

handstandsam avatar handstandsam commented on August 19, 2024

WireMock now supports Android as of 2.0.8-beta.
Thanks to everyone for their tips/examples. The updates done in the 2.0-beta branch fixed a lot of the dependency issues that hindered Android support in the 1.0 branch. I added a small method signature change that was the last piece of the puzzle to get full support: df2ccc6

You can see an example project I made running WireMock in some test cases here: https://github.com/handstandsam/AndroidHttpMockingExamples

Gradle Dependencies:

//WireMock Dependencies
androidTestCompile("com.github.tomakehurst:wiremock:2.0.8-beta") {
    //Allows us to use the Android version of Apache httpclient instead
    exclude group: 'org.apache.httpcomponents', module: 'httpclient'

    //Resolves the Duplicate Class Exception
    //Error:Execution failed for task ':app:transformClassesWithJarMergingForDebugAndroidTest'.
    //       > com.android.build.api.transform.TransformException: java.util.zip.ZipException: duplicate entry: org/objectweb/asm/AnnotationVisitor.class
    exclude group: 'asm', module: 'asm'
}
androidTestCompile 'org.apache.httpcomponents:httpclient-android:4.3.5+'

This issue can be marked as resolved.

from wiremock.

handstandsam avatar handstandsam commented on August 19, 2024

Figured out you also need to exclude org.json:json because Android already has a version. I updated the build.grade for the sample project here.

from wiremock.

davidgouldsky avatar davidgouldsky commented on August 19, 2024

It certainly looks promising; unfortunately I've encountered a number of reliability issues when using it in integration testing. If anybody would like some information to assist in improving the product, please let me know.

from wiremock.

ghdbre avatar ghdbre commented on August 19, 2024

Using WireMock 2.2.1 I had to specify
"exclude group: 'org.ow2.asm', module: 'asm'" and not
"exclude group: 'asm', module: 'asm'"
in handstandsam's build.gradle to get rid of the the error "ZipException: duplicate entry: org/objectweb/asm/AnnotationVisitor.class"

from wiremock.

tomakehurst avatar tomakehurst commented on August 19, 2024

Thanks for sharing that. Perhaps worth posting a comment on Sam's blog?

from wiremock.

ghdbre avatar ghdbre commented on August 19, 2024

Tried - only twitter users qualify.

Relying on GitHub's auto-mail feature.

from wiremock.

alexei28 avatar alexei28 commented on August 19, 2024

Android Studio 2.3.1.
My build.gradle (dependency).

`dependencies {
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.volley:volley:1.0.0'

// for folder "androidTest"
androidTestCompile 'com.android.support.test.espresso:espresso-core:2.2.2'
androidTestCompile "org.mockito:mockito-android:2.7.21"
androidTestCompile "org.powermock:powermock-api-mockito:1.6.6"
androidTestCompile 'org.powermock:powermock-module-junit4:1.6.6'

// for folder "test"
testCompile 'junit:junit:4.12'
testCompile 'org.powermock:powermock-api-mockito:1.6.6'
testCompile 'org.powermock:powermock-module-junit4:1.6.6'
testCompile "org.mockito:mockito-core:+"

//WireMock
androidTestCompile("com.github.tomakehurst:wiremock:2.6.0") {
    //Using Android Version Instead
    exclude group: 'org.apache.httpcomponents', module: 'httpclient'

    //Version conflict with our app's slf4j version
    exclude group: 'org.slf4j', module: 'slf4j-api'

    //Was getting a classpath conflict for org.objectweb.asm.AnnotationVisitor which is a part of 'net.minidev:asm'
    exclude group: 'org.ow2.asm', module: 'asm'

    //Was getting this warning, so decided to ignore this version included by WireMock.
    //Warning:Dependency org.json:json:20090211 is ignored as it may be conflicting with the internal version provided by Android.
    //In case of problem, please repackage with jarjar to change the class packages
    exclude group: 'org.json', module: 'json'
}

}`

But when I try to start Android instrumented unit test (from folder "androidTest") I get the next error:

`Error:Execution failed for task ':app:transformClassesWithDexForDevAndroidTest'.

com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.dex.DexIndexOverflowException: method ID not in [0, 0xffff]: 65536
`

from wiremock.

handstandsam avatar handstandsam commented on August 19, 2024

Yeah, you need Multidex enabled like the sample app unfortunately. Sorry for the late response. Your test apk can't actually go over the Dec, otherwise it won't find those classes in the 2nd dex. This isn't a problem on 21+ for tests.

from wiremock.

alexei-28 avatar alexei-28 commented on August 19, 2024

Android, Gradle, Espresso: When add WireMode get error: Instrumentation run failed due to 'java.lang.NoClassDefFoundError'

My Android Espresso test:

package com.example.testproject;

import android.content.Context;
import android.support.test.rule.ActivityTestRule;
import android.support.test.runner.AndroidJUnit4;

import org.junit.Before;
import org.junit.Rule;
import org.junit.Test;
import org.junit.runner.RunWith;

import static android.support.test.espresso.Espresso.onView;
import static android.support.test.espresso.action.ViewActions.click;
import static android.support.test.espresso.assertion.ViewAssertions.matches;
import static android.support.test.espresso.matcher.ViewMatchers.withId;
import static android.support.test.espresso.matcher.ViewMatchers.withText;
import static org.hamcrest.core.IsNot.not;

@RunWith(AndroidJUnit4.class)
public class MainActivityTest {
    private static String TAG;
    private Context context;

    @Rule
    public ActivityTestRule<MainActivity_> mActivityRule = new ActivityTestRule<>(MainActivity_.class);

    @Before
    public void init() {
        TAG = MainActivity.class.getName();
        context = mActivityRule.getActivity();
    }

    @Test
    public void checkClick() {
        onView(withId(R.id.myButton)).perform(click());
        onView(withId(R.id.myTextView)).check(matches(withText(R.string.you_click)));
    }
}

My build.gradle:

apply plugin: 'com.android.application'

`android {
    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.example.testproject"
        minSdkVersion 15
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        // Enabling Multidex support for 'androidTest' builds because of large dependencies
        // need for androidTest
        multiDexEnabled = true
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    packagingOptions {
        exclude 'META-INF/DEPENDENCIES'
        exclude 'META-INF/NOTICE'
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/LICENSE.txt'
        exclude 'META-INF/NOTICE.txt'

        exclude 'mockito-extensions/org.mockito.plugins.MockMaker'
    }
}

def AAVersion = '4.3.0'

dependencies {

    annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
    compile "org.androidannotations:androidannotations-api:$AAVersion"
    compile 'com.android.support.constraint:constraint-layout:1.0.1'
    compile 'us.feras.mdv:markdownview:1.1.0'
    compile 'com.github.mukeshsolanki:MarkdownView-Android:1.0.3'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:25.2.0'
    compile group: 'commons-io', name: 'commons-io', version: '2.4'

    androidTestCompile 'junit:junit:4.12'
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') {
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude group: 'com.google.guava', module: 'guava'
        exclude group: 'junit', module: 'junit'
    }
}

`

I run Espresso test (checkClick) by gradle from command line:

gradlew connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.example.testproject.MainActivityTest#checkClick

and Espresso test success run and execute. OK!

Now I want to use lib WireMock to test http request/response. So I change my dependencies in build.gradle:

dependencies {

    annotationProcessor "org.androidannotations:androidannotations:$AAVersion"
    compile "org.androidannotations:androidannotations-api:$AAVersion"
    compile 'com.android.support.constraint:constraint-layout:1.0.1'
    compile 'us.feras.mdv:markdownview:1.1.0'
    compile 'com.github.mukeshsolanki:MarkdownView-Android:1.0.3'
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:25.2.0'
    compile group: 'commons-io', name: 'commons-io', version: '2.4'

    androidTestCompile 'junit:junit:4.12'
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2') {
        exclude group: 'com.android.support', module: 'support-annotations'
        exclude group: 'com.google.guava', module: 'guava'
        exclude group: 'junit', module: 'junit'
    }

    //WireMock
    androidTestCompile("com.github.tomakehurst:wiremock:2.5.0") {
        //Using Android Version Instead
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'

        //Version conflict with our app's slf4j version
        exclude group: 'org.slf4j', module: 'slf4j-api'

        //Was getting a classpath conflict for org.objectweb.asm.AnnotationVisitor which is a part of 'net.minidev:asm'
        exclude group: 'org.ow2.asm', module: 'asm'

        //Was getting this warning, so decided to ignore this version included by WireMock.
        //Warning:Dependency org.json:json:20090211 is ignored as it may be conflicting with the internal version provided by Android.
        //In case of problem, please repackage with jarjar to change the class packages
        exclude group: 'org.json', module: 'json'
    }
    androidTestCompile 'org.apache.httpcomponents:httpclient-android:4.3.5.1'
    androidTestCompile 'commons-io:commons-io:2.4'
}

And now when I run same Espresso test I get error:

gradlew connectedAndroidTest -Pandroid.testInstrumentationRunnerArguments.class=com.example.testproject.MainActivityTest#checkClick --debug --stacktrace

...
:app:assembleDebugAndroidTest UP-TO-DATE
:app:connectedDebugAndroidTest
Starting 0 tests on Galaxy Nexus - 4.3
Tests on Galaxy Nexus - 4.3 failed: Instrumentation run failed due to 'java.lang.NoClassDefFoundError'

com.android.builder.testing.ConnectedDevice > No tests found.[Galaxy Nexus - 4.3] FAILED 
No tests found. This usually means that your test classes are not in the form that your test runner expects (e.g. don't inherit from TestCase or lack @Test annotations).
:app:connectedDebugAndroidTest FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:connectedDebugAndroidTest'.
> There were failing tests. See the report at: file:///D:/dev/mobile/TestProject/app/build/reports/androidTests/connected/index.html

* Try:
Run with --info or --debug option to get more log output.

* Exception is:
org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:connectedDebugAndroidTest'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:84)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:55)
    at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:62)
    at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
    at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:88)
    at org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54)
    at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:236)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker$1.execute(DefaultTaskGraphExecuter.java:228)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:61)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:228)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:215)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:77)
    at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:58)
    at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:32)
    at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:113)
    at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
    at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
    at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
    at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
    at org.gradle.initialization.DefaultGradleLauncher$3.execute(DefaultGradleLauncher.java:196)
    at org.gradle.initialization.DefaultGradleLauncher$3.execute(DefaultGradleLauncher.java:193)
    at org.gradle.internal.Transformers$4.transform(Transformers.java:169)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:106)
    at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:56)
    at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:193)
    at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:119)
    at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:102)
    at org.gradle.launcher.exec.GradleBuildController.run(GradleBuildController.java:71)
    at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
    at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:41)
    at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:26)
    at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:75)
    at org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:49)
    at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:44)
    at org.gradle.tooling.internal.provider.ServicesSetupBuildActionExecuter.execute(ServicesSetupBuildActionExecuter.java:29)
    at org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:47)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
    at org.gradle.util.Swapper.swap(Swapper.java:38)
    at org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:60)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:72)
    at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
    at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:120)
    at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
    at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:297)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
    at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
Caused by: org.gradle.api.GradleException: There were failing tests. See the report at: file:///D:/dev/mobile/TestProject/app/build/reports/androidTests/connected/index.html
    at com.android.build.gradle.internal.tasks.DeviceProviderInstrumentTestTask.runTests(DeviceProviderInstrumentTestTask.java:160)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.doExecute(DefaultTaskClassInfoStore.java:141)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:134)
    at org.gradle.api.internal.project.taskfactory.DefaultTaskClassInfoStore$StandardTaskAction.execute(DefaultTaskClassInfoStore.java:123)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:632)
    at org.gradle.api.internal.AbstractTask$TaskActionWrapper.execute(AbstractTask.java:615)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:95)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:76)
    ... 70 more


BUILD FAILED

I get same error when try to run Espresso test from Android Studio 2.3

from wiremock.

alexei-28 avatar alexei-28 commented on August 19, 2024

I found solutions of problem:

  1. If you use Android 5.0- (e.g. Android 4.3) then you MUST use Wiremock version 2.0.8-beta

androidTestCompile 'com.github.tomakehurst:wiremock:2.0.8-beta'

  1. If you use Android 5.0+ you can you use any Wiremock version (e.g. 2.5.0)

androidTestCompile 'com.github.tomakehurst:wiremock:2.6.0'

P.S. Maybe this is a Multidex issues.

from wiremock.

maximelebastard avatar maximelebastard commented on August 19, 2024

Ok but what if you want to use it on Android 5.0- AND Android 5.0+ ?

I can get Wiremock working on Android 5.0, but I still have a failure on :app:transformClassesWithMultidexlistForDebugAndroidTest task on Android 4.3

I also had to compile jetty-http aside, because the class HttpScheme from Jetty was not found on Android 4.3 (but was found on Android 5.0).

 // Wiremock
    androidTestCompile('com.github.tomakehurst:wiremock:2.0.8-beta') {
        //Using Android Version Instead
        exclude group: 'org.apache.httpcomponents', module: 'httpclient'

        //Was getting a classpath conflict for org.objectweb.asm.AnnotationVisitor which is a part of 'net.minidev:asm'
        exclude group: 'asm', module: 'asm'

        //Was getting this warning, so decided to ignore this version included by WireMock.
        //Warning:Dependency org.json:json:20090211 is ignored as it may be conflicting with the internal version provided by Android.
        //In case of problem, please repackage with jarjar to change the class packages
        exclude group: 'org.json', module: 'json'

        //Jetty was not providing org/eclipse/jetty/http/HttpScheme as expected
        exclude group: 'org.eclipse.jetty', module: 'jetty-http'
    }
    androidTestCompile('org.apache.httpcomponents:httpclient-android:4.3.5.1')
    androidTestCompile('org.eclipse.jetty:jetty-http:9.4.6.v20170531')

from wiremock.

tomakehurst avatar tomakehurst commented on August 19, 2024

Closing this as it has become a bit unfocussed.

I'm more than happy to take specific suggestions (and PRs) from the Android community on how to improve the dev experience.

from wiremock.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.