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

Android Support #19

Closed
eugenio1590 opened this issue Dec 13, 2019 · 18 comments
Closed

Android Support #19

eugenio1590 opened this issue Dec 13, 2019 · 18 comments
Labels
bug 🐞 Something isn't working help wanted 🆘 Extra attention is needed

Comments

@eugenio1590
Copy link

Hi @serpro69

Can I use this library in an android project? Currently, I added this dependency and I get the following error:

faker.internet.email()

java.util.NoSuchElementException: Category with name 'NAME' not found

	at io.github.serpro69.kfaker.FakerService.fetchCategory(FakerService.kt:130)
	at io.github.serpro69.kfaker.provider.AbstractFakeDataProvider$resolve$1.invoke(AbstractFakeDataProvider.kt:54)
	at io.github.serpro69.kfaker.provider.AbstractFakeDataProvider$resolve$1.invoke(AbstractFakeDataProvider.kt:14)
	at io.github.serpro69.kfaker.provider.AbstractFakeDataProvider.returnOrResolveUnique(AbstractFakeDataProvider.kt:116)
	at io.github.serpro69.kfaker.provider.AbstractFakeDataProvider.returnOrResolveUnique$default(AbstractFakeDataProvider.kt:109)
	at io.github.serpro69.kfaker.provider.AbstractFakeDataProvider.resolve(AbstractFakeDataProvider.kt:67)
	at io.github.serpro69.kfaker.provider.Name.name(Name.kt:19)
	at io.github.serpro69.kfaker.provider.Internet.email(Internet.kt:20)
	at io.github.serpro69.kfaker.provider.Internet.email$default(Internet.kt:18)
@serpro69
Copy link
Owner

Hi. Thanks for reporting. I haven't tried using it in an Android project, but I'll look into it.

@eugenio1590
Copy link
Author

Hi. Thanks for reporting. I haven't tried using it in an Android project, but I'll look into it.

Perfect. Thanks.

@serpro69
Copy link
Owner

serpro69 commented Feb 1, 2020

I can't seem to reproduce this issue using latest Android Studio

I used this sample project to run the tests: https://github.com/android/testing-samples/tree/master/unit/BasicSample

And the test:

public class EmailValidatorTest {
    @Test
    public void testKotlinFaker() {
        Faker faker = new Faker();

        String name = faker.getInternet().email();
        System.out.println("name = " + name);
    }
}

prints out:

name = clarita.wiza@yahoo.com

Process finished with exit code 0

Tried running both from command line and the IDE.
Can you provide a minimal reproducible example for the issue you're facing?

@serpro69 serpro69 added the needs info ❓ Further information is requested label Feb 1, 2020
@eugenio1590
Copy link
Author

Hi @serpro69 , I replicated this issue on my android project but I do not have time now to replicate using another project of Android. I am sorry for that. But If you see this "test" project you can see the same problem. This is a maven project with spring. Please let me know if it is a missing dependency or if I need to use another version of the Faker library. Thanks.

@serpro69
Copy link
Owner

serpro69 commented Feb 6, 2020

Thanks @eugenio1590, I'll check it out.

@serpro69
Copy link
Owner

serpro69 commented Feb 6, 2020

I couldn't reproduce the issue with your test project either.

Here's the full output of the test run (I've added a printout for the name variable) which you can also see in the console output.

✓ ~/Projects/personal/clones/issues/maven-kotlin-faker→ ./mvnw clean test                                                                                                                                                           [17:11:16]
[INFO] Scanning for projects...
[INFO]
[INFO] --------------------------< com.example:demo >--------------------------
[INFO] Building demo 0.0.1-SNAPSHOT
[INFO] --------------------------------[ jar ]---------------------------------
[INFO]
[INFO] --- maven-clean-plugin:3.1.0:clean (default-clean) @ demo ---
[INFO] Deleting /home/sergio/Projects/personal/clones/issues/maven-kotlin-faker/target
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:resources (default-resources) @ demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] Copying 1 resource
[INFO] Copying 0 resource
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:compile (default-compile) @ demo ---
[INFO] Nothing to compile - all classes are up to date
[INFO]
[INFO] --- kotlin-maven-plugin:1.3.61:compile (compile) @ demo ---
[INFO] Applied plugin: 'spring'
[INFO]
[INFO] --- maven-resources-plugin:3.1.0:testResources (default-testResources) @ demo ---
[INFO] Using 'UTF-8' encoding to copy filtered resources.
[INFO] skip non existing resourceDirectory /home/sergio/Projects/personal/clones/issues/maven-kotlin-faker/src/test/resources
[INFO]
[INFO] --- maven-compiler-plugin:3.8.1:testCompile (default-testCompile) @ demo ---
[INFO] Changes detected - recompiling the module!
[INFO]
[INFO] --- kotlin-maven-plugin:1.3.61:test-compile (test-compile) @ demo ---
[INFO] Applied plugin: 'spring'
[INFO]
[INFO] --- maven-surefire-plugin:2.22.2:test (default-test) @ demo ---
[INFO]
[INFO] -------------------------------------------------------
[INFO]  T E S T S
[INFO] -------------------------------------------------------
[INFO] Running com.example.demo.DemoApplicationTests
tiffaney.lehner@gmail.com
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 1.058 s - in com.example.demo.DemoApplicationTests
[INFO]
[INFO] Results:
[INFO]
[INFO] Tests run: 1, Failures: 0, Errors: 0, Skipped: 0
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
[INFO] ------------------------------------------------------------------------
[INFO] Total time:  8.051 s
[INFO] Finished at: 2020-02-06T17:11:25+01:00
[INFO] ------------------------------------------------------------------------

@serpro69
Copy link
Owner

serpro69 commented Feb 6, 2020

Could this #20 be related? Can you try explicitly setting the jackson-module-kotlin version to 2.10.1?

@eugenio1590
Copy link
Author

Ok, I am using Intellij to run the tests. I can try using the command line to verify it.

@serpro69
Copy link
Owner

serpro69 commented Feb 6, 2020

I tried both actually. But yes, it could be something wrong with your intellij setup.

@eugenio1590
Copy link
Author

I get the same error. You can close this issue for now if you want. Thanks for your help.

@serpro69
Copy link
Owner

serpro69 commented Feb 7, 2020

I don't mind keeping it open for awhile, but I need more details to reproduce it.
I'll try to reproduce it on a VM box when I have some time. If it works there as well it must be something with your setup.

@serpro69
Copy link
Owner

serpro69 commented Feb 7, 2020

I've tried to reproduce it on a VM box with a spring-boot maven project and it works there as well, hence closing this as not reproducible.
Feel free to re-open if you can provide more details on how to reproduce this.

@serpro69 serpro69 closed this as completed Feb 7, 2020
@serpro69 serpro69 added invalid 🚫 This doesn't seem right and removed needs info ❓ Further information is requested labels Feb 7, 2020
@mcheung610
Copy link

mcheung610 commented Sep 20, 2021

I ran into the same problem. I think this is a bug that only happens in the windows environment.

@serpro69 Is it possible to re-open this?

@serpro69
Copy link
Owner

@mcheung610 , I've re-opened this, but I'm not sure how to reproduce it. I don't have a windows machine and virtualbox was broken in Ubuntu 2004 for me last time that I checked it. I'll try to check it once more when I have the time, but feel free to submit a PR for the fix also.
What version are you using?

@serpro69 serpro69 reopened this Sep 22, 2021
@serpro69 serpro69 added bug 🐞 Something isn't working help wanted 🆘 Extra attention is needed and removed invalid 🚫 This doesn't seem right labels Sep 22, 2021
@serpro69
Copy link
Owner

serpro69 commented Oct 3, 2021

@mcheung610 / @eugenio1590 , I've made another fix for android in #90 . Can you try to run latest version and see if this issue still persists with that fix?

@serpro69
Copy link
Owner

This issue has been w/o action for quite some time now, so I'm going to close it.
If you still face problems with android @mcheung610 / @eugenio1590 - feel free to re-open.
Thanks

@drindt
Copy link

drindt commented Apr 30, 2024

I have a maybe similar problem. By invoke faker.address.city() the stack trace is the result. It is clear to me that the compose tooling framework is a bit different to the instrumentation test. The question is why the others work but not the city()?

@serpro69
Copy link
Owner

serpro69 commented Apr 30, 2024

Hi @drindt ,
That looks strange. address.city() makes a call to Name provider (ref:

city:
- "#{city_prefix} #{Name.first_name}#{city_suffix}"
- "#{city_prefix} #{Name.first_name}"
- "#{Name.first_name}#{city_suffix}"
- "#{Name.last_name}#{city_suffix}"
), which for some reason is not found and hence the exception is thrown.
I suppose the "others" that do work for you don't invoke functions from other providers (like in this case address.city() will call i.e. name.firstName()), which is why they might work and city() not. The question is, why city() doesn't work... :)
Would you be able to provide an example repo where this can be reproduced?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐞 Something isn't working help wanted 🆘 Extra attention is needed
Projects
None yet
Development

No branches or pull requests

4 participants