Welcome, Guest. Please login or register. Did you miss your activation email?

Author Topic: Android build problem  (Read 9972 times)

0 Members and 1 Guest are viewing this topic.

sergioawd

  • Newbie
  • *
  • Posts: 9
    • View Profile
Android build problem
« on: July 21, 2016, 12:59:02 am »
Hello everyone, I followed this tutorial (https://github.com/SFML/SFML/wiki/Tutorial:-Building-SFML-for-Android), and when I get to the point of building get this error, I searched the Internet and this forum but can not find solution. Thank you.

Code: [Select]
C:\SFML-master\examples\android>ndk-build
Android NDK: jni/Android.mk: Cannot find module with tag 'sfml' in import path 
Android NDK: Are you sure your NDK_MODULE_PATH variable is properly defined ?   
Android NDK: The following directories were searched:
Android NDK:
jni/Android.mk:17: *** Android NDK: Aborting.    .  Stop.

Edit: Windows system.
« Last Edit: July 21, 2016, 01:24:27 pm by sergioawd »

DarkRoku12

  • Full Member
  • ***
  • Posts: 203
  • Lua coder.
    • View Profile
    • Email
Re: Android build problem
« Reply #1 on: July 21, 2016, 06:37:45 am »
Are you using Windows or Linux?

Please, in order to help you we need you to provide the most information you can.
I would like a spanish/latin community...
Problems building for Android? Look here

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 878
    • View Profile
Re: Android build problem
« Reply #2 on: July 21, 2016, 08:54:52 am »
Sounds like you forgot to actually "install" SFML after building.

Check the folder <NDK>\source\sfml to see whether it actually exists.

If it doesn't something went wrong while building or installing.

sergioawd

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Android build problem
« Reply #3 on: July 21, 2016, 01:13:46 pm »
Are you using Windows or Linux?

Please, in order to help you we need you to provide the most information you can.

Windows sorry

sergioawd

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Android build problem
« Reply #4 on: July 21, 2016, 01:23:24 pm »
Sounds like you forgot to actually "install" SFML after building.

Check the folder <NDK>\source\sfml to see whether it actually exists.

If it doesn't something went wrong while building or installing.

In the ndk\sources not include sfml folder...

sergioawd

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Android build problem
« Reply #5 on: July 21, 2016, 02:07:07 pm »
I've been watching this post by DarkRoku http://en.sfml-dev.org/forums/index.php?topic=19298, and copy the floder sfml in my sdk/sources but the error is this now

Code: [Select]
C:\SFML-master\examples\android>ndk-build
[armeabi-v7a] Install        : libsfml-activity.so => libs/armeabi-v7a/libsfml-activity.so
[armeabi-v7a] Compile++      : sfml-example <= main.cpp
[armeabi-v7a] Prebuilt       : libsfml-graphics.so <= <NDK>/sources/sfml/lib/armeabi-v7a/
[armeabi-v7a] Prebuilt       : libsfml-audio.so <= <NDK>/sources/sfml/lib/armeabi-v7a/
[armeabi-v7a] Prebuilt       : libsfml-network.so <= <NDK>/sources/sfml/lib/armeabi-v7a/
[armeabi-v7a] Prebuilt       : libc++_shared.so <= <NDK>/sources/cxx-stl/llvm-libc++/libs/armeabi-v7a/thumb/
[armeabi-v7a] Prebuilt       : libsfml-window.so <= <NDK>/sources/sfml/lib/armeabi-v7a/
[armeabi-v7a] Prebuilt       : libsfml-system.so <= <NDK>/sources/sfml/lib/armeabi-v7a/
[armeabi-v7a] SharedLibrary  : libsfml-example.so
./obj/local/armeabi-v7a/objs/sfml-example/main.o:main.cpp:function vibrate(sf::Time): error: undefined reference to 'sf::getNativeActivity()'
./obj/local/armeabi-v7a/objs/sfml-example/main.o:main.cpp:function main: error: undefined reference to 'sf::String::String(char const*, std::__ndk1::locale const&)'
./obj/local/armeabi-v7a/objs/sfml-example/main.o:main.cpp:function main: error: undefined reference to 'sf::Texture::loadFromFile(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&, sf::Rect<int> const&)'
./obj/local/armeabi-v7a/objs/sfml-example/main.o:main.cpp:function main: error: undefined reference to 'sf::Music::openFromFile(std::__ndk1::basic_string<char, std::__ndk1::char_traits<char>, std::__ndk1::allocator<char> > const&)'
C:/Android/NDK/build//../sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function sf::priv::main(sf::priv::ActivityStates*): error: undefined reference to 'myCustomEntryPoint(int, char**, ANativeActivity*)'
C:/Android/NDK/build//../sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function std::__1::basic_streambuf<char, std::__1::char_traits<char> >::~basic_streambuf(): error: undefined reference to 'std::__1::locale::~locale()'
C:/Android/NDK/build//../sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function std::__1::basic_streambuf<char, std::__1::char_traits<char> >::~basic_streambuf(): error: undefined reference to 'std::__1::locale::~locale()'
C:/Android/NDK/build//../sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function ANativeActivity_onCreate: error: undefined reference to 'std::__1::ios_base::clear(unsigned int)'
C:/Android/NDK/build//../sources/sfml/lib/armeabi-v7a/libsfml-main.a(MainAndroid.cpp.o):MainAndroid.cpp:function onDestroy(ANativeActivity*): error: undefined reference to 'std::__1::locale::~locale()'
collect2.exe: error: ld returned 1 exit status
make: *** [obj/local/armeabi-v7a/libsfml-example.so] Error 1
« Last Edit: July 21, 2016, 02:32:33 pm by sergioawd »

DarkRoku12

  • Full Member
  • ***
  • Posts: 203
  • Lua coder.
    • View Profile
    • Email
Re: Android build problem
« Reply #6 on: July 21, 2016, 03:24:59 pm »
You should build SFML libraries.

On windows you will need to use: MinGW (using -G "MSYS Makefiles" for CMake).
I would like a spanish/latin community...
Problems building for Android? Look here

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 878
    • View Profile
Re: Android build problem
« Reply #7 on: July 21, 2016, 04:07:39 pm »
That's now a problem that should be fixed in the latest version from GitHub. Check out master branch, build, install, then try again.

sergioawd

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Android build problem
« Reply #8 on: July 21, 2016, 08:34:26 pm »
That's now a problem that should be fixed in the latest version from GitHub. Check out master branch, build, install, then try again.

Ok, try it.

sergioawd

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Android build problem
« Reply #9 on: July 26, 2016, 05:43:48 am »
Download the new SFML-Master and have this error when ndk-build, and use the main.cpp from the folder SFML-master / examples / android
Code: [Select]
C:\SFML-master\examples\android>ndk-build
[armeabi-v7a] Compile++ thumb: sfml-example <= main.cpp
jni/main.cpp:1:27: fatal error: SFML/System.hpp: No such file or directory
 #include <SFML/System.hpp>
                           ^
compilation terminated.
make: *** [obj/local/armeabi-v7a/objs/sfml-example/main.o] Error 1

and if copy the folder SFML libs to C:\SFML-master\examples\android\jni show this errors:
Code: [Select]
C:\SFML-master\examples\android>ndk-build
[armeabi-v7a] Compile++ thumb: sfml-example <= main.cpp
[armeabi-v7a] Prebuilt       : libstlport_shared.so <= <NDK>/sources/cxx-stl/stlport/libs/armeabi-v7a/thumb/
[armeabi-v7a] SharedLibrary  : libsfml-example.so
jni/main.cpp:24: error: undefined reference to 'sf::getNativeActivity()'
jni/main.cpp:57: error: undefined reference to 'sf::Time::asMilliseconds() const'
jni/SFML/Graphics/Sprite.hpp:47: error: undefined reference to 'sf::Transformable::~Transformable()'
jni/SFML/Graphics/Sprite.hpp:47: error: undefined reference to 'vtable for sf::Sprite'
C:/Android/NDK/build//../toolchains/arm-linux-androideabi-4.9/prebuilt/windows-x86_64/bin/../lib/gcc/arm-linux-androideabi/4.9/../../../../arm-linux-androideabi/bin/ld.exe: the vtable symbol may be undefined because the class is missing its key function (see go/missingkeymethod)
jni/main.cpp:78: error: undefined reference to 'sf::VideoMode::getDesktopMode()'
jni/main.cpp:78: error: undefined reference to 'sf::String::String(char const*, std::locale const&)'
jni/main.cpp:78: error: undefined reference to 'sf::RenderWindow::RenderWindow(sf::VideoMode, sf::String const&, unsigned int, sf::ContextSettings const&)'
jni/main.cpp:80: error: undefined reference to 'sf::Texture::Texture()'
jni/main.cpp:81: error: undefined reference to 'sf::Texture::loadFromFile(std::string const&, sf::Rect<int> const&)'
jni/main.cpp:84: error: undefined reference to 'sf::Sprite::Sprite(sf::Texture const&)'
jni/main.cpp:85: error: undefined reference to 'sf::Transformable::setPosition(float, float)'
jni/main.cpp:86: error: undefined reference to 'sf::Texture::getSize() const'
jni/main.cpp:86: error: undefined reference to 'sf::Texture::getSize() const'
jni/main.cpp:86: error: undefined reference to 'sf::Transformable::setOrigin(float, float)'
jni/main.cpp:88: error: undefined reference to 'sf::Music::Music()'
jni/main.cpp:89: error: undefined reference to 'sf::Music::openFromFile(std::string const&)'
jni/main.cpp:90: error: undefined reference to 'sf::Music::~Music()'
jni/main.cpp:92: error: undefined reference to 'sf::SoundStream::play()'
jni/main.cpp:94: error: undefined reference to 'sf::RenderTarget::getDefaultView() const'
jni/main.cpp:96: error: undefined reference to 'sf::Window::isOpen() const'
jni/main.cpp:100: error: undefined reference to 'sf::Window::pollEvent(sf::Event&)'
jni/main.cpp:105: error: undefined reference to 'sf::Window::close()'
jni/main.cpp:108: error: undefined reference to 'sf::View::setSize(float, float)'
jni/main.cpp:109: error: undefined reference to 'sf::View::setCenter(float, float)'
jni/main.cpp:110: error: undefined reference to 'sf::RenderTarget::setView(sf::View const&)'
jni/main.cpp:115: error: undefined reference to 'sf::Transformable::setPosition(float, float)'
jni/main.cpp:124: error: undefined reference to 'sf::RenderTarget::clear(sf::Color const&)'
jni/main.cpp:125: error: undefined reference to 'sf::RenderTarget::draw(sf::Drawable const&, sf::RenderStates const&)'
jni/main.cpp:126: error: undefined reference to 'sf::Window::display()'
jni/main.cpp:88: error: undefined reference to 'sf::Music::~Music()'
jni/main.cpp:80: error: undefined reference to 'sf::Texture::~Texture()'
jni/main.cpp:127: error: undefined reference to 'sf::RenderWindow::~RenderWindow()'
jni/main.cpp:82: error: undefined reference to 'sf::Texture::~Texture()'
jni/main.cpp:82: error: undefined reference to 'sf::RenderWindow::~RenderWindow()'
jni/main.cpp:128: error: undefined reference to 'sf::Color::White'
jni/main.cpp:128: error: undefined reference to 'sf::RenderStates::Default'
collect2.exe: error: ld returned 1 exit status
make: *** [obj/local/armeabi-v7a/libsfml-example.so] Error 1
« Last Edit: July 26, 2016, 06:14:43 am by sergioawd »

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 878
    • View Profile
Re: Android build problem
« Reply #10 on: July 27, 2016, 09:20:03 am »
You shouldn't have to copy files on your own. Go to your SFML build directory (for Android) and run the following command:

Code: [Select]
cmake --build . --target install --config Release
The last few lines should tell you about copying the files to your Android NDK directory.

After that, go to "examples/android" and run the following to build the example:

Code: [Select]
android update project --target 1 --path . --name SFML-Example
ndk-build
ant debug

sergioawd

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Android build problem
« Reply #11 on: July 28, 2016, 06:16:57 am »
You shouldn't have to copy files on your own. Go to your SFML build directory (for Android) and run the following command:

Code: [Select]
cmake --build . --target install --config Release
The last few lines should tell you about copying the files to your Android NDK directory.

After that, go to "examples/android" and run the following to build the example:

Code: [Select]
android update project --target 1 --path . --name SFML-Example
ndk-build
ant debug

Thank you for your reply.
Code: [Select]
cmake --build . --target install --config ReleaseThis create in my nkd sources the sfml source, this is all ok.

I remove folder SFML in  C:\SFML-master\examples\android\jni
And show this error now:
Code: [Select]
C:\SFML-master\examples\android>ndk-build
[armeabi-v7a] Compile++ thumb: sfml-example <= main.cpp
jni/main.cpp:1:27: fatal error: SFML/System.hpp: No such file or directory
 #include <SFML/System.hpp>
                           ^
compilation terminated.
make: *** [obj/local/armeabi-v7a/objs/sfml-example/main.o] Error 1

What is the problem?

Thank you.


Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 878
    • View Profile
Re: Android build problem
« Reply #12 on: July 29, 2016, 09:16:36 am »
What's your NDK version? For some reason it can't find the header files.

There should be a directory <NDK root>/sources/sfml/include with SFML's header files. If it's there, there might be something off with your environment configuration.

sergioawd

  • Newbie
  • *
  • Posts: 9
    • View Profile
Re: Android build problem
« Reply #13 on: July 29, 2016, 04:17:51 pm »
What's your NDK version? For some reason it can't find the header files.

There should be a directory <NDK root>/sources/sfml/include with SFML's header files. If it's there, there might be something off with your environment configuration.

The NDK Version is the last version r12b.
Yes the folder C:\Android\NDK\sources\sfml\include\SFML exists and exists files hpp.

And the path in my environment configuration is good is this:
- ANDROID_NDK: C:/Android/NDK
- PATH: C:\Android\NDK and try this also C:/Android/NDK

I changed the folder C:\Android\NDK\sources\sfml\lib armeabi for armeabi-v7a, and build this (I do not know if it is ok):
Code: [Select]
C:\SFML-master\examples\android>ndk-build
[armeabi-v7a] Install        : libsfml-activity.so => libs/armeabi-v7a/libsfml-activity.so
[armeabi-v7a] Install        : libsfml-example.so => libs/armeabi-v7a/libsfml-example.so
[armeabi-v7a] Install        : libsfml-system.so => libs/armeabi-v7a/libsfml-system.so
[armeabi-v7a] Install        : libsfml-window.so => libs/armeabi-v7a/libsfml-window.so
[armeabi-v7a] Install        : libsfml-graphics.so => libs/armeabi-v7a/libsfml-graphics.so
[armeabi-v7a] Install        : libsfml-audio.so => libs/armeabi-v7a/libsfml-audio.so
[armeabi-v7a] Install        : libsfml-network.so => libs/armeabi-v7a/libsfml-network.so
[armeabi-v7a] Install        : libstlport_shared.so => libs/armeabi-v7a/libstlport_shared.so
[armeabi-v7a] Install        : libopenal.so => libs/armeabi-v7a/libopenal.so
But not create in the folder C:\SFML-master\examples\android\bin the apk file...

And execute ant debug and show this errors:

Code: [Select]
Unable to locate tools.jar. Expected to find it in C:\Program Files\Java\jre1.8.0_101\lib\tools.jar
Buildfile: C:\SFML-master\examples\android\build.xml

-set-mode-check:

-set-debug-files:

-check-env:
 [checkenv] Android SDK Tools Revision 24.3.2
 [checkenv] Installed at C:\Users\Sergio\AppData\Local\Android\sdk

-setup:
     [echo] Project Name: SFML-Example
  [gettype] Project Type: Application

-set-debug-mode:

-debug-obfuscation-check:

-pre-build:

-build-setup:
[getbuildtools] Using latest Build Tools: 23.0.3
     [echo] Resolving Build Target for SFML-Example...
[gettarget] Project Target:   Android 4.2.2
[gettarget] API level:        17
     [echo] ----------
     [echo] Creating output directories if needed...
     [echo] ----------
     [echo] Resolving Dependencies for SFML-Example...
[dependency] Library dependencies:
[dependency] No Libraries
[dependency]
[dependency] ------------------
     [echo] ----------
     [echo] Building Libraries with 'debug'...
   [subant] No sub-builds to iterate on

-code-gen:
[mergemanifest] Found Deleted Target File
[mergemanifest] Merging AndroidManifest files into one.
[mergemanifest] Manifest merger disabled. Using project manifest only.
     [echo] hasCode = false. Skipping aidl/renderscript/R.java

-pre-compile:

-compile:
     [echo] hasCode = false. Skipping...

-post-compile:

-obfuscate:

-dex:
     [echo] hasCode = false. Skipping...

-crunch:

BUILD FAILED
C:\Users\Sergio\AppData\Local\Android\sdk\tools\ant\build.xml:911: Execute failed: java.io.IOException: Cannot run program "${aapt}" (in directory "C:\SFML-master\examples\android"): CreateProcess error=2, El sistema no puede encontrar el archivo especificado
        at java.lang.ProcessBuilder.start(Unknown Source)
        at java.lang.Runtime.exec(Unknown Source)
        at org.apache.tools.ant.taskdefs.launcher.Java13CommandLauncher.exec(Java13CommandLauncher.java:58)
        at org.apache.tools.ant.taskdefs.Execute.launch(Execute.java:426)
        at org.apache.tools.ant.taskdefs.Execute.execute(Execute.java:440)
        at org.apache.tools.ant.taskdefs.ExecTask.runExecute(ExecTask.java:629)
        at org.apache.tools.ant.taskdefs.ExecTask.runExec(ExecTask.java:670)
        at org.apache.tools.ant.taskdefs.ExecTask.execute(ExecTask.java:496)
        at org.apache.tools.ant.UnknownElement.execute(UnknownElement.java:293)
        at sun.reflect.GeneratedMethodAccessor4.invoke(Unknown Source)
        at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
        at java.lang.reflect.Method.invoke(Unknown Source)
        at org.apache.tools.ant.dispatch.DispatchUtils.execute(DispatchUtils.java:106)
        at org.apache.tools.ant.Task.perform(Task.java:348)
        at org.apache.tools.ant.Target.execute(Target.java:435)
        at org.apache.tools.ant.Target.performTasks(Target.java:456)
        at org.apache.tools.ant.Project.executeSortedTargets(Project.java:1405)
        at org.apache.tools.ant.Project.executeTarget(Project.java:1376)
        at org.apache.tools.ant.helper.DefaultExecutor.executeTargets(DefaultExecutor.java:41)
        at org.apache.tools.ant.Project.executeTargets(Project.java:1260)
        at org.apache.tools.ant.Main.runBuild(Main.java:854)
        at org.apache.tools.ant.Main.startAnt(Main.java:236)
        at org.apache.tools.ant.launch.Launcher.run(Launcher.java:285)
        at org.apache.tools.ant.launch.Launcher.main(Launcher.java:112)
Caused by: java.io.IOException: CreateProcess error=2, El sistema no puede encontrar el archivo especificado
        at java.lang.ProcessImpl.create(Native Method)
        at java.lang.ProcessImpl.<init>(Unknown Source)
        at java.lang.ProcessImpl.start(Unknown Source)
        ... 24 more

Total time: 0 seconds

Thank you

« Last Edit: July 29, 2016, 04:27:29 pm by sergioawd »

Mario

  • SFML Team
  • Hero Member
  • *****
  • Posts: 878
    • View Profile
Re: Android build problem
« Reply #14 on: July 30, 2016, 03:48:03 pm »
You shouldn't copy/move/rename files. You essentially put code generated for ARM v7 into the folder where there's code for ARM v6.

But this shouldn't cause the other problem. There's obviously something wrong or broken with your SDK, if ant fails.