conan-io / docs

conan.io reStructuredText documentation
http://docs.conan.io
MIT License
110 stars 360 forks source link

[question] Clarification of run statement in documentation for cross building to Android #3633

Open zflat opened 8 months ago

zflat commented 8 months ago

At the very end of the https://github.com/conan-io/docs/blob/develop2/examples/cross_build/android/ndk.rst example there is the statement:

Unless you have access to a root Android device, running the test application or using the built library is not possible directly so it is more common to build an Android application that uses the hello library.

This is a pretty long sentence and I don't understand what is trying to be stated. Is it saying that this example is for a library only (Library module)? Can a similar approach be used to build an app (App module)? Or can an android app only be built from android studio as described at https://github.com/conan-io/docs/blob/develop2/examples/cross_build/android/android_studio.rst?

memsharded commented 8 months ago

Hi @zflat

Thanks for your question. I agree that that sentence is not very clear. It refers to the test_package/conanfile.py code:

    def build(self):
        cmake = CMake(self)
        cmake.configure()
        cmake.build()

    def layout(self):
        cmake_layout(self)

    def test(self):
        if can_run(self):
            cmd = os.path.join(self.cpp.build.bindir, "example")
            self.run(cmd, env="conanrun")

And that the can_run() will return by default False and that the example application will not be launched, because it will fail to run in a normal windows/linux/osx machine.

This is not really related to how libraries are used by real android apps, it is just about the typical creation of an executable in test_package. For Android, the test_package will at least guarantee that the headers can be found, the library can be found and be linked, etc.

Please let me know if this clarifies the issue a bit.

zflat commented 7 months ago

If I understand your clarification, I would like to suggest some edits to make this more clear:

- Unless you have access to a root Android device, running the test application or using the built library is not possible directly so it is more common to build an Android application that uses the hello library.
+ The non-native test application is not possible to run on the same architecture as your local computer. Directly running the test application or using the built library is possible if you use a root Android device. It is more common to build an Android application that uses the hello library and test using typical Android development workflows.