'error: An item with the same key has already been added Visual Studio Ant build step
I have a custom solution generated with cmake, one of the projects has to be akin to a VS C++ Cross Platform .Packiging.androidproject (ant build), but this is geenerated as a .vcxproj with a project type gui ID, however the property sheets generate properly for a packaging project.
cmake_minimum_required( VERSION 3.21 FATAL_ERROR )
SET( ${PROJECT_NAME}_GUID_CMAKE "39E2626F-3545-4960-A6E8-258AD8476CE5" CACHE INTERNAL
"Project GUID")
#include_external_msproject( "Project.Packaging.androidproject"
"${CMAKE_CURRENT_LIST_DIR}/path" TYPE "{39E2626F-3545-4960-A6E8-
258AD8476CE5}" )
# Think this only works for QT
set( ANDROID_PACKAGE_SOURCE_DIR "./" )
set( Android_Core_Packaging
"${CMAKE_CURRENT_SOURCE_DIR}/AndroidManifest.xml"
"${CMAKE_CURRENT_SOURCE_DIR}/build.xml"
"${CMAKE_CURRENT_SOURCE_DIR}/project.properties"
"${CMAKE_CURRENT_SOURCE_DIR}/res/values/strings.xml"
)
add_executable( "${TargetName}" ${Android_Core_Packaging} )
set_target_properties( "${TargetName}"
PROPERTIES
VS_GLOBAL_ROOTNAMESPACE "${PROJECT_DEP_NAME}"
VS_CONFIGURATION_TYPE Application
VS_USER_PROPS
"$(AndroidTargetsPath)/Android.Default.props;
$(AndroidTargetsPath)/Android.props;
$(AndroidTargetsPath)/Android.targets"
ANDROID_SKIP_ANT_STEP false
ANDROID_GUI 1
LINKER_LANGUAGE CXX
SUFFIX ".apk"
ARCHIVE_OUTPUT_DIRECTORY "${CMAKE_CURRENT_BINARY_DIR}/$<PLATFORM_ID>/$<CONFIG>"
COMPILE_OPTIONS ""
)
add_dependencies( "${TargetName}" "${PROJECT_DEP_NAME}" )
file( GLOB resource_value_files LIST_DIRECTORIES TRUE
"${CMAKE_CURRENT_SOURCE_DIR}/res/values/*.xml"
)
source_group( "res\\values"
FILES
${resource_value_files}
)
After clicking run in VS2022 the Ant build starts but fails in: C:\Program Files\Microsoft Visual Studio\2022\Professional\Msbuild\Microsoft\VC\v170\Application Type\Android\3.0\Android.Common.Targets : line 256 with a really dumb error message: error: An item with the same key has already been added.
It gets as far as making the .recipe files, I have pointed the Output & Intermediate directories at the same location to ensure it can find all the files.
But looking at the Android.Common.Targets line it seems to be failing upon checking project type, maybe the GUID.... idk.
FYI: include_external_msproject does not work, cmake fails, guess it only works for .vcxproj, tried pre-generating a proper .androidproj and linking it into the build tree with the correct project type GUID.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
