1

Can someone help me with this error, I can't seem to identify the problem. I am also new in using Scons. I need to get through this to obtain the .aar and .apk files. I am using Iotivity for a project that allows users to share transfer images between devices of any platform without internet.

Command Prompt:

   C:\Users\derrick\Desktop\iotivity-2.0.1.1\iotivity-2.0.1.1>scons TARGET_OS=android
    scons: Reading SConscript files ...
    Processing using SCons version 3.1.1
    Python 2.7.17 (v2.7.17:c2f86d86e6, Oct 19 2019, 21:01:17) [MSC v.1500 64 bit (AMD64)] on win32
    NameError: name 'host_arch' is not defined:
      File "C:\Users\derrick\Desktop\iotivity-2.0.1.1\iotivity-2.0.1.1\SConstruct", line 32:
        SConscript('build_common/SConscript')
      File "c:\python27\lib\site-packages\scons\SCons\Script\SConscript.py", line 668:
        return method(*args, **kw)
      File "c:\python27\lib\site-packages\scons\SCons\Script\SConscript.py", line 605:
        return _SConscript(self.fs, *files, **subst_kw)
      File "c:\python27\lib\site-packages\scons\SCons\Script\SConscript.py", line 286:
        exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
      File "C:\Users\derrick\Desktop\iotivity-2.0.1.1\iotivity-2.0.1.1\build_common\SConscript", line 1025:
        env.SConscript(target_os + '/SConscript')
      File "c:\python27\lib\site-packages\scons\SCons\Script\SConscript.py", line 605:
        return _SConscript(self.fs, *files, **subst_kw)
      File "c:\python27\lib\site-packages\scons\SCons\Script\SConscript.py", line 286:
        exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
      File "C:\Users\derrick\Desktop\iotivity-2.0.1.1\iotivity-2.0.1.1\build_common\android\SConscript", line 19:
        SConscript('#/extlibs/android/ndk/SConscript')
      File "c:\python27\lib\site-packages\scons\SCons\Script\SConscript.py", line 668:
        return method(*args, **kw)
      File "c:\python27\lib\site-packages\scons\SCons\Script\SConscript.py", line 605:
        return _SConscript(self.fs, *files, **subst_kw)
      File "c:\python27\lib\site-packages\scons\SCons\Script\SConscript.py", line 286:
        exec(compile(scriptdata, scriptname, 'exec'), call_stack[-1].globals)
      File "C:\Users\derrick\Desktop\iotivity-2.0.1.1\iotivity-2.0.1.1\extlibs\android\ndk\SConscript", line 24:
        if host_arch in ['x86_64']:
Derrick
  • 13
  • 3

1 Answers1

0

It's broken. I guess I'm the one who broke it when I tried to clean up that part of the build some years ago. The iotivity project CI system does not build android binaries on a windows host, it uses a linux builder for that, and I guess no developer did either so nothing detected the problem, which as the error message says, is that host_arch is undefined. This is not fundamental to iotivity, it's just dependency work to set up the Android NDK; once you have one set up this stuff is skipped for subsequent builds. The previous version switched on target_arch which wasn't right - the bundle to get depends on the host, not on what you're building for. I think the Android project stopped supporting 32-bit bundles a while back anyway so the simplest way to move forward is to remove the test (unless for some reason you have 32-bit Windows). That is, change this chunk starting with line 23:

else:
    if host_arch in ['x86_64']:
        ndk_url = ndk_url_base + '-windows-x86_64.exe'
    else:
        ndk_url = ndk_url_base + '-windows-x86.exe'
    ndk_bundle = 'android-ndk-' + NDK_VER + '.exe'

to the simpler form:

else:
    ndk_url = ndk_url_base + '-windows-x86_64.exe'
    ndk_bundle = 'android-ndk-' + NDK_VER + '.exe'

(if it wasn't clear, that meant edit the file in the last line of the traceback, C:\Users\derrick\Desktop\iotivity-2.0.1.1\iotivity-2.0.1.1\extlibs\android\ndk\SConscript)

Mats Wichmann
  • 800
  • 6
  • 6
  • Hi Wichmann, after I was able to download the ndk, there was another error, `AttributeError: 'module' object has no attribute 'EnvironmentError': ... File "C:\Users\derrick\Desktop\iotivity-2.0.1.1\iotivity-2.0.1.1\extlibs\boost\SConscript", line 90: raise SCons.Errors.EnvironmentError(msg)` – Derrick Nov 25 '19 at 07:35
  • That's the result of an SCons change, since Python already defines `EnvironmentError` it was considered a bad idea for SCons to also use it, so it's now called `SConsEnvironmentError`. Nobody's updated iotivity for that chance, evidently. – Mats Wichmann Nov 25 '19 at 16:02