I started my first attempt to move one of my OF projects to Android, was able to build & deploy example projects, ran the Android Project Generator (on Windows) telling it to import my existing OF project, but building fails during compile with:
C:\OF0.10.0And\addons\ofxAndroid\src/ofAppAndroidWindow.cpp:265: error: undefined reference to ‘ofAndroidApplicationInit()’
C:\OF0.10.0And\addons\ofxAndroid\src/ofAppAndroidWindow.cpp:270: error: undefined reference to ‘ofAndroidActivityInit()’
This seems like framework code, and I’m surprised not to find any search results in the OF documentation, or this forum, for ofAndroidApplicationInit.
Any clues what might be occurring and how to correct it?
Does the Android Project Generator not allow me to import non-Android projects?
Should I just take a working example and manually move my project’s code in there?
the main.cpp for desktop and android is different and includes this function that the calls main if i remember well. make sure that your main file looks like the ones in the android examples.
Ok that part was easy. Yes, the Android example main.cpp includes simple definitions of those functions, which when added, makes that go away.
Now I see the next set of errors, which seems to imply I need to also provide access to some sort of:
I gather I should go through the example and see what libraries it might be linking to to provide these things.
you are probably just missing to add ofxAndroid?
I tried doing that in my ofApp.h to match the androidEmptyExample, but that wasn’t seeming to help, so…
I got it to build by a brute-force approach where I just moved the build-able example app out of Examples into MyApps and copied my src and bin/data contents on top of that project, and it built and ran just fine.
I see Android Studio does seem to think ofxAndroid, ofxGUI, and ofxAccelerometer are source modules to build and do something with, even though my code in src doesn’t refer to any of them.
I’m not sure if I should try to figure out the other project files to understand how that works, or just happily work keep working inside my src subfolder and be glad it builds and runs by whatever magic that happens.
That project I got to build above (by copying the C++ code files from an OF project I developed in Linux into copied androidGUIExample project folders) still builds in Android Studio, but I tried to build androidVideoExample, and got the exact same list of build errors from it.
Is this perhaps the same issue as mentioned in the other recent Android Studio questions:
And am I right in thinking then that the known solutions are either to find a working project and move in the source code like I did, or to revert to an earlier Android Studio version that didn’t deprecate/abandon the way OF sets up projects?
In case this helps anyone (or me in future if/when I forget this again):
So, having got my project to build for Android, I did some work on it in other platforms, then copied my new code back to my Android project, and ran into this again. This time all I did was add:
//application scope init
//activity scope init
To main.cpp, and that got it building.