Android build on macOS


#1

I’m trying to build cinder latest git for android on macOS and found that the guide here is a bit outdated.
Managed to run proj/android/fullbuild-armeabi-v7a after the following 2 changes were made:

diff --git a/proj/android/CMakeLists.txt b/proj/android/CMakeLists.txt
index 76f181573..2d6ce8060 100644
--- a/proj/android/CMakeLists.txt
+++ b/proj/android/CMakeLists.txt
@@ -408,7 +408,7 @@ else()
     set( CMAKE_STRIP        ${NKD_TOOLCHAIN_ROOT}/bin/${NDK_TOOLCHAIN_PREFIX}-strip  CACHE FILEPATH "" FORCE )
 endif()
 
-get_filename_component( CINDER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.." ABSOLUTE )
+#get_filename_component( CINDER_DIR "${CMAKE_CURRENT_SOURCE_DIR}/.." ABSOLUTE )
 set( CINDER_INC_DIR ${CINDER_DIR}/include )
 set( CINDER_SRC_DIR ${CINDER_DIR}/src )
 set( BOOST_INC_DIR ${CINDER_DIR}/boost )
diff --git a/src/cinder/Json.cpp b/src/cinder/Json.cpp
index 32a0d6c34..e98f36e07 100755
--- a/src/cinder/Json.cpp
+++ b/src/cinder/Json.cpp
@@ -534,7 +534,7 @@ JsonTree* JsonTree::getNodePtr( const string &relativePath, bool caseSensitive,
         // The key is numeric
 		if( isIndex( *pathIt ) ) {
             // Find child which uses this index as its key
-			uint32_t index = std::stoi( *pathIt );
+			uint32_t index = stoi( *pathIt );
 			uint32_t i = 0;
 			for ( node = curNode->getChildren().begin(); node != curNode->getChildren().end(); ++node, i++ ) {
 				if ( i == index ) {

Although the second step described by @rich.e in Looking for some guidance on how Android Apps are built fails to build.
Changed the following to be able to run gradle:

diff --git a/proj/android/libcinder_java/build.gradle b/proj/android/libcinder_java/build.gradle
index 574631d5d..423c42cc3 100644
--- a/proj/android/libcinder_java/build.gradle
+++ b/proj/android/libcinder_java/build.gradle
@@ -4,7 +4,7 @@ buildscript {
     repositories {
         jcenter()
         flatDir {
-            dirs "${projectDir}/../../tools/android/CinderAppBuild/repo"
+            dirs "${projectDir}/../../../tools/android/CinderAppBuild/repo"
         }
     }
     dependencies {

but the build exits with the following errors:

/Users/gabor/projects/cinder/proj/android/libcinder_java/app/src/main/java/org/libcinder/exampleapp/CameraOrientLockedActivity.java:18: error: package org.libcinder.hardware does not exist
import org.libcinder.hardware.Camera;
                             ^
/Users/gabor/projects/cinder/proj/android/libcinder_java/app/src/main/java/org/libcinder/exampleapp/CameraOrientLockedActivity.java:23: error: package Camera does not exist
public class CameraOrientLockedActivity extends Activity implements TextureView.SurfaceTextureListener, Button.OnClickListener, Camera.DisplayLayoutListener {
                                                                                                                                      ^
/Users/gabor/projects/cinder/proj/android/libcinder_java/app/src/main/java/org/libcinder/exampleapp/CameraOrientLockedActivity.java:29: error: cannot find symbol
    private Camera mCamera;
            ^
  symbol:   class Camera
  location: class CameraOrientLockedActivity
/Users/gabor/projects/cinder/proj/android/libcinder_java/app/src/main/java/org/libcinder/exampleapp/CameraPreviewActivity.java:18: error: package org.libcinder.hardware does not exist
import org.libcinder.hardware.Camera;
                             ^
/Users/gabor/projects/cinder/proj/android/libcinder_java/app/src/main/java/org/libcinder/exampleapp/CameraPreviewActivity.java:25: error: package Camera does not exist
               Camera.DisplayLayoutListener
                     ^
/Users/gabor/projects/cinder/proj/android/libcinder_java/app/src/main/java/org/libcinder/exampleapp/CameraPreviewActivity.java:31: error: cannot find symbol
    private Camera mCamera;
            ^
  symbol:   class Camera
  location: class CameraPreviewActivity
/Users/gabor/projects/cinder/proj/android/libcinder_java/app/src/main/java/org/libcinder/exampleapp/UrlLoaderActivity.java:17: error: package org.libcinder.net does not exist
import org.libcinder.net.UrlLoader;
                        ^
/Users/gabor/projects/cinder/proj/android/libcinder_java/app/src/main/java/org/libcinder/exampleapp/CameraDeviceListActivity.java:111: error: package org.libcinder.hardware does not exist
                    String fmtStr = org.libcinder.hardware.Camera.imageFormatString(fmt);
                                                          ^
/Users/gabor/projects/cinder/proj/android/libcinder_java/app/src/main/java/org/libcinder/exampleapp/CameraOrientLockedActivity.java:111: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/gabor/projects/cinder/proj/android/libcinder_java/app/src/main/java/org/libcinder/exampleapp/CameraPreviewActivity.java:113: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/gabor/projects/cinder/proj/android/libcinder_java/app/src/main/java/org/libcinder/exampleapp/UrlLoaderActivity.java:93: error: cannot find symbol
                    UrlLoader loader = new UrlLoader();
                    ^
  symbol:   class UrlLoader
  location: class RunThread
/Users/gabor/projects/cinder/proj/android/libcinder_java/app/src/main/java/org/libcinder/exampleapp/UrlLoaderActivity.java:93: error: cannot find symbol
                    UrlLoader loader = new UrlLoader();
                                           ^
  symbol:   class UrlLoader
  location: class RunThread
Note: /Users/gabor/projects/cinder/proj/android/libcinder_java/app/src/main/java/org/libcinder/exampleapp/CameraDeviceListActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
12 errors
:app:compileDebugJavaWithJavac FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Is this step necessary or is it enough to use the libcinder-[debug/release].aar files from git?

Any help would be appreciated.

-Gabor


#2

I believe that currently you don’t need to rebuild the libcinder_java project unless you’re modifying something in the java layer - the most updated .aar’s are shipped. But I imagine those build errors are another side effect of the paths changing when we reorganized the repo in 0.9.1.

Also it would be much appreciated that if someone does get this building again (or even improvements), we could merge it back into master branch. Even though it is still considered experimental until there is more developer support, would be great to have it building.