Can the same install of OF be used for Desktop and Android?

Hi! So far I have built Desktop apps, but I would like to target Android too. I followed https://github.com/openframeworks/openFrameworks/blob/master/docs/android_studio.md without much luck.

I run
./projectGenerator -o"/home/funpro/src/openFrameworks" -a"" -p"linuxarmv6l,linuxarmv7l" "/home/funpro/src/openFrameworks/examples/android/androidEmptyExample"

which produces an empty .qbs file, a config.make, and a Makefile. If I load the project folder into Android Studio, no files are displayed.

Also, Android Studio did not ask for the NDK location, nor the option was visible inside the Project Settings window.

I then tried creating a new Android Studio project with C++, which triggered the downloading of NDK 15 and later of cmake (weird, because I already had cmake in my system). This new project successfully runs on a device.

Should I have two different copies of OF, one for Desktop and one for Android?

i think the correct -p should be -p"android"

Thank you! So happy to see it working :slight_smile:

I had to do two things to fix this issue:

08-02 15:32:14.174 18239-18239/cc.openframeworks.androidEmptyExample E/art: ClassLinker::FindClass not found:Lcc/openframeworks/androidEmptyExample/OFActivity;
08-02 15:32:14.175 18239-18239/cc.openframeworks.androidEmptyExample D/AndroidRuntime: Shutting down VM
08-02 15:32:14.178 18239-18239/cc.openframeworks.androidEmptyExample E/AndroidRuntime: FATAL EXCEPTION: main
                                                                                       Process: cc.openframeworks.androidEmptyExample, PID: 18239
                                                                                       java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{cc.openframeworks.androidEmptyExample/cc.openframeworks.androidEmptyExample.OFActivity}: java.lang.ClassNotFoundException: Didn't find class "cc.openframeworks.androidEmptyExample.OFActivity" on path: DexPathList[[zip file "/data/app/cc.openframeworks.androidEmptyExample-2/base.apk"],nativeLibraryDirectories=[/data/app/cc.openframeworks.androidEmptyExample-2/lib/arm, /vendor/lib, /system/lib]]
                                                                                           at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2256)
                                                                                           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2407)
                                                                                           at android.app.ActivityThread.access$700(ActivityThread.java:155)
                                                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317)
                                                                                           at android.os.Handler.dispatchMessage(Handler.java:102)
                                                                                           at android.os.Looper.loop(Looper.java:135)
                                                                                           at android.app.ActivityThread.main(ActivityThread.java:5298)
                                                                                           at java.lang.reflect.Method.invoke(Native Method)
                                                                                           at java.lang.reflect.Method.invoke(Method.java:372)
                                                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:911)
                                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706)
                                                                                        Caused by: java.lang.ClassNotFoundException: Didn't find class "cc.openframeworks.androidEmptyExample.OFActivity" on path: DexPathList[[zip file "/data/app/cc.openframeworks.androidEmptyExample-2/base.apk"],nativeLibraryDirectories=[/data/app/cc.openframeworks.androidEmptyExample-2/lib/arm, /vendor/lib, /system/lib]]
                                                                                           at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
                                                                                           at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
                                                                                           at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
                                                                                           at android.app.Instrumentation.newActivity(Instrumentation.java:1066)
                                                                                           at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2246)
                                                                                           at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2407) 
                                                                                           at android.app.ActivityThread.access$700(ActivityThread.java:155) 
                                                                                           at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1317) 
                                                                                           at android.os.Handler.dispatchMessage(Handler.java:102) 
                                                                                           at android.os.Looper.loop(Looper.java:135) 
                                                                                           at android.app.ActivityThread.main(ActivityThread.java:5298) 
                                                                                           at java.lang.reflect.Method.invoke(Native Method) 
                                                                                           at java.lang.reflect.Method.invoke(Method.java:372) 
                                                                                           at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:911) 
                                                                                           at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:706) 
                                                                                       	Suppressed: java.lang.ClassNotFoundException: cc.openframeworks.androidEmptyExample.OFActivity
                                                                                           at java.lang.Class.classForName(Native Method)
                                                                                           at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
                                                                                           at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
                                                                                           at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
                                                                                           		... 13 more
                                                                                        Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
  1. Inside srcJava/, rename (refactor) the class name from cc.openframeworks.APP_NAME to cc.openframeworks.androidEmptyExample.
  2. Replace APP_NAME with androidEmptyExample in the first line of OFActivity.java.

It seems like these placeholder variables should have been renamed by the project generator, but weren’t.

When I run the projectGenerator it shows an error. Maybe related?

[notice ] -----------------------------------------------
[notice ] setting OF path to: /home/funpro/src/openFrameworks
[notice ] from -o option
[notice ] target platform is: android
[notice ] updating project /home/funpro/src/openFrameworks/examples/android/androidEmptyExample
[ error ] ofDirectory: copyTo(): source directory does not exist
[warning] ofDirectory: copyTo(): dest ""/home/funpro/src/openFrameworks/examples/android/androidEmptyExample/res"" already exists, set bool overwrite to true to overwrite it
[warning] ofDirectory: copyTo(): dest ""/home/funpro/src/openFrameworks/examples/android/androidEmptyExample/srcJava"" already exists, set bool overwrite to true to overwrite it
[ error ] ofDirectory: copyTo(): source directory does not exist
[notice ] saving addons.make
[notice ] project updated! 
[notice ] -----------------------------------------------

can you open an issue? there was some refactoring of the android part recently and there might be some things missing