16. February 2020

Unable to upload Xamarin app with C/C++ code to Google Play – solution

After finishing release build of your Android application with Xamarin – Visual Studio 2019 you may experience the following error when uploading the app to Google Play Console:

Warning!
This release is not compliant with Google Play 64-bit requirement.

The following APKS or App Bundles are available to 64-bit devices, 
but they only have 32-bit native code: 1000.

Even when your application contains ARM and ARM64, it might still happen that Google refuses to accept your app and returns just the same error message.

The reason is simple: Google requires that your app with native code bundled as AAB (which is ZIP) contains also libraries for 64-bit platform. It does not matter which architecture.

The error is often caused by building application also for Intel platform because emulators on Intel are faster. There are two options to resolve the issue:

  • remove Intel platform from release build
  • add also 64-bit version for Intel platform to release build

Google is checking each platform and your .so files should be mirrored for 32-bit and 64-bit. If your bundle is not consistent then Google will refuse your application.

To fix this problem open Visual Studio 2019. Click your project in Solution Explorer. Open Properties (ALT+Enter).

Click Android Options, scroll down to Advanced button. Click Advanced button.

Uncheck all Intel platform (or check them all, based on your preference) and click Close.

Press CTRL+S to save changes. Create a new archive of your application (menu Build – Archive…)

Upload the new AAB.

If you don’t know how to switch to AAB, just go back to Android Options. Search for Android Package Format and select ‘bundle’.

19. September 2019

Xamarin Visual Studio – Error ADB0020 Android ABI mismatch

Following error message might pop-up when you to run Xamarin app on Android:

Error ADB0020: Android ABI mismatch. You are deploying an app supporting ‘armeabi-v7a’ ABIs to an incompatible device of ABI ‘x86’. You should either create an emulator matching one of your app’s ABIs or add ‘x86’ to the list of ABIs your app builds for.

Here is how you can resolve it.

In Solution Explorer select your project.

Right-click and select Properties or press Alt+Enter.

Select Android Options, scroll down. In right bottom corner click Advanced button.

From the drop down menu select desired architecture, e.g. x86_x64.

Note: After changing any checkbox it is necessary to wait a bit so that Visual Studio syncs the preferences.

Now you should be able to run the project.

17. November 2013

How to build sample applications from Adobe Illustrator SDK CC by Microsoft Visual Studio 2013 Express

Let’s try to build sample applications from Adobe Illustrator SDK CC with Express version of Visual Studio.

Adobe Illustrator SDK is available at: http://www.adobe.com/devnet/illustrator/sdk.html

In readme file Adobe explicitly states requirement that you should use Microsoft Visual C++ 10 (Visual Studio 2010 SP1). Hm.

Unzip directory with SDK and go to samples directory. Let’s start with LiveDropShadow sample.

Double click LiveDropShadow.vcxproj to open project in Visual Studio 2013. Hit F7 to build the project.

You’ll get error message:

Error 1 error MSB8020: The build tools for Visual Studio 2010 (Platform Toolset = ‘v100’) cannot be found. To build using the v100 build tools, please install Visual Studio 2010 build tools.  Alternatively, you may upgrade to the current Visual Studio tools by selecting the Project menu or right-click the solution, and then selecting “Upgrade Solution…”. C:\Program Files (x86)\MSBuild\Microsoft.Cpp\v4.0\V120\Microsoft.Cpp.Platform.targets

illustrator-wrong-target

Go to menu Project and select Retarget solution:

illustrator-retarget-project

This action converts project into project for VS 2013. Hit F7 for build.

After several seconds compilation fails and you’ll get another error message:

Error 20 error RC1015: cannot open include file ‘afxres.h’. C:\idea\Adobe Illustrator CC SDK\samplecode\LiveDropShadow\Resources\LiveDropShadow.rc 26 1 LiveDropShadow

illustrator-visualstudio

Double click error message and you’ll see problematic code.

illustrator-problematic-code-01

Problematic is include of afxres.h. It is reference to MFC library which is not part of Visual Studio Express 2013 edition. MFC is available only in Professional version. Do not worry. For many plugins you do not need MFC.

You can disable this include. There is also another problem few lines below with language code. We can disable this line of code for time being.

illustrator-problematic-code-02Hit F7. You’ll get error message that points into VersionInfo.rc file. There are several defines referencing MFC. You can disable those line for time being. (FILEFLAGMASK, FILEOS, FILETYPE, FILESUBTYPE)

illustrator-problematic-code-03

Hit F7 and now you’ll get AIP package :)

illustrator-visualstudio-success-build

Open Illustrator and configure path to Additional Plug-ins folder. Click Edit – Preferences – Plug-ins & Scratch Disks and set path to the folder where Visual Studio produced that aip file. It will be in directory Adobe Illustrator CC SDK\samplecode\output\win….

illustrator-preferences

Click OK, restart Illustrator.

Tadaaa, plug-in is working:

illustrator-working-01

Result:

illustrator-working-02

For more information about plug-ins read getting-started-guide.pdf document in SDK directory docs\guides. :-)

 

15. December 2011

How to define C++ macro with string content and pass it to MSbuild

Imagine that we have C++ project e.g. for Visual Studio 2008. It is possible to build this project just by msbuild command:

msbuild MyProject.vcproj /p:Configuration="Release"

Let say that we want to use #define in the source code. It is necessary to define it in Configuration Properties > C++ > Command Line:

/DSIMPLE_DEFINE

This just pass SIMPLE_DEFINE as flag.

How to deal with string define which should behave like string? E.g.:

#define URL "https://georgik.rocks"

The trick is in escaping quotes. We can add following define to Command Line:

/DURL=\"https://georgik.rocks\"

It will transform into .vcproj file:

AdditionalOptions="/DURL=\"https://georgik.rocks\""

Let’s make one more step.

How to acquire such a define from environment variable? E.g. with following build.bat file:

set URL="https://georgik.rocks"
msbuild MyProject.vcproj /p:Configuration="Release"

It requires only small modification of .vcproj file:

AdditionalOptions="/DURL=\"$(URL)\""

;-)

Small recap of flow: set env variable – pass it to XML – pass it compiler – pass it to code

14. October 2011

_ITERATOR_DEBUG_LEVEL’: value ‘0’ doesn’t match value ‘2’

Update 16.10. 2011: new information added to article.

I was trying to compile an application with Visual Studio 2010 which has some dependency on GDAL open source library.

Everything went ok. GDAL compiled without problem from VS and also from command line:

nmake -f makefile.vc MSVC_VER=1600 DEBUG=1

Compilation of application based on GDAL was also ok. The only problem was when I switched project from Release mode to Debug mode. Linker was throwing a lot of messages like this:

'error LNK2038: mismatch detected for _ITERATOR_DEBUG_LEVEL': 
value '0' doesn't match value '2' in vrtizer.obj

I found some explanation that new version of VS has _ITERATOR_DEBUG_LEVEL set to 2 in Debug mode. It means that there are some extra security controls over iterators to detect memory leaks and other problematic stuff with iterators.

After longer research I came to realization that GDAL is compiled with /MD switch and my application wasn’t. The solution was easy. I just added /MD and Debug mode of app start working like a charm.

Quote from MSDN about /MD compiler switch:

Defines _MT and _DLL so that both multithread- and DLL-specific versions of the run-time routines are selected from the standard .h files. This option also causes the compiler to place the library name MSVCRT.lib into the .obj file.
Applications compiled with this option are statically linked to MSVCRT.lib. This library provides a layer of code that allows the linker to resolve external references. The actual working code is contained in MSVCR71.DLL, which must be available at run time to applications linked with MSVCRT.lib.

Update 16.10. 2011

/MD solved problem, but there was another warning: Command line warning D9025: overriding ‘/MDd’ with ‘/MD’.

To solve Iterator issue for GDAL you need to compile DEBUG version of gdal.lib with switch /MDd instead of default /MD.

Just open nmake.opt file and replace /MD in lines with DEBUG definition by /MDd.

There are two lines with MD:

OPTFLAGS= $(CXX_ANALYZE_FLAGS) /nologo /MDd /EHsc /Zi /W4 /D_CRT_SECURE_NO_DEPRECATE 
/D_CRT_NONSTDC_NO_DEPRECATE /Fd$(GDAL_ROOT)\gdal$(VERSION).pdb /DDEBUG
OPTFLAGS=   /nologo /MDd /EHsc /GR /Zi /W4 /Fd$(GDAL_ROOT)\gdal$(VERSION).pdb  /DDEBUG

Then rebuild GDAL:

nmake -f makefile.vc clean
nmake -f makefile.vc MSVC_VER=1600 DEBUG=1