Android Dex: trouble processing "javax/transaction/xa/XAException.class": - build

I am trying to build my project in the new Android Studio IDE and am unable to. I get this error but I cannot find where this class is being used.
I found this: https://groups.google.com/forum/?fromgroups#!topic/android-platform/abxNKTFkuj8
According to that page it is caused by the IDE trying to build the android.jar library. However I can't find a reference to it n my Project Structure dialog.
Conversion to Dalvik format failed with error 1 in Android 4?
None of my classes start with the java.* prefix.
This is my project lib view:
It seems as though something is different with Android Studio, my project builds fine with both Ant and Eclipse.

The problem was related to ActionBarSherlock being built and using the support-v4 library too. The solution was to change the dependencies in the Library settings in Android Studio. Since I was already including ActionBarSherlock as a jar I just excluded it from being built at all.
This question helped: Intellij: android-support-v4.jar in included in actionBarSherlock and Project => IllegalArgumentException

Related

I'm trying to use native C++ libraries in a MAUI app and cannot get it working for MacOS/iOS

There's a great article here that describes how to use native C++ libraries in Xamarin/C#, and I would assume that this would extend to MAUI: https://learn.microsoft.com/en-us/xamarin/cross-platform/cpp/
I followed these instructions, and put together an end-to-end demo solution of it here: https://github.com/whodges/bindingsample. This does require that you link Visual Studio to a MacBook to build the full solution.
That example essentially uses the default MAUI template, and modifies it slightly so that the actual 'click counter' value is set and retrieved from a native library on a per-platform basis. For Windows, that's a C++ DLL (works great). For Android, that's a .so library (works great). And for iOS, that's a static .a library, and here's where I'm running into trouble: when I try to launch this app using the iOS Simulator, it fails with a clang++ error, and something along the lines of "Could not extract the native library 'libCounteriOS.a' from .../obj/Debug/net6.0-ios/iossimulator-x64/linker-cache/libCounteriOS.a'. Please ensure the native library was properly embedded in the managed assembly (if the assembly was built using a binding project, the native library must be included in the project, and its Build Action must be 'ObjcBindingNativeLibrary')".
I created a C# .NET iOS Binding Library project (Counter.iOS in my example), and this is supposed to bundle libCounteriOS.a, which is generated when CounteriOS (a C++ project) is compiled. First, when Counter.iOS is built using Visual Studio on Windows, it fails to generate the Counter.resources folder in its 'bin' folder, along with the subsequent 'manifest' file. When I use Visual Studio for Mac, these files do get generated. So, I stuck with Visual Studio for Mac to build the iOS.Counter project (everything else is built with Visual Studio on Windows).
Regardless, I still get the "could not extract the native library" error I described. I've tried setting the library file's Build Action in Counter.iOS to ObjcBindingNativeLibrary, but that just results in an unhelpful "Build failed - see build log for details" error in Visual Studio for Mac, and I cannot find said log file for the life of me. On top of that, it's not an Objective C library anyway - it's a C++ one - so I'm not sure if this step is actually appropriate. Does it have to be Objective C? The Xamarin article suggests otherwise, and the native reference option 'Is C++' is there as well. I've also tried setting libCounteriOS.a's Build Action to 'BundleResource' - no luck with that either. I've tried it with .NET 7.0 as well - also no luck there.
I'm really at a loss. Is this even possible? It doesn't seem to work and I've been poking at it for weeks on it. That Xamarin article seems to suggest it should be possible. Any help would be greatly appreciated.

How to build&run Unreal C++ project on Linux?

I'm trying to build my first Unreal C++ project on Linux.
I built the engine from source in accordance with "Linux Quick Start" guide. Then I installed Qt Creator and followed the "How to Set up Qt Creator for UE4" guide.
I successfully set up and ran UE4Editor, and created a new C++ project. Unfortunately when I try running the project it complains:
And when I press "yes" this error message is shown:
Here's the error message from the logs:
ERROR: Building would modify the following engine files:
/media/redacted-disk/UnrealEngine/Engine/Binaries/Linux/Android/UE4Editor.modules
/media/redacted-disk/UnrealEngine/Engine/Binaries/Linux/Linux/UE4Editor.modules
/media/redacted-disk/UnrealEngine/Engine/Binaries/Linux/UE4Editor.modules
/media/redacted-disk/UnrealEngine/Engine/Plugins/2D/Paper2D/Binaries/Linux/UE4Editor.modules
/media/redacted-disk/UnrealEngine/Engine/Plugins/AI/AISupport/Binaries/Linux/UE4Editor.modules
... many more
I tried rebuilding UE4 from IDE, then building again - but the error still persists. Same thing happens if I try starting UE4Editor from the engine files and opening the project from there.
What could cause this error? Why does it even try to rebuild the engine when I'm tring run a project?
I have the following script to add the paths to the engine scripts and binaries to my PATH:
UNREAL_HOME="/path/to/source/of/UnrealEngine"
UNREAL_SCRIPTS="${UNREAL_HOME}/Engine/Build/BatchFiles"
UNREAL_SCRIPTS_LINUX="${UNREAL_HOME}/Engine/Build/BatchFiles/Linux"
UNREAL_BINS="${UNREAL_HOME}/Engine/Binaries/Linux"
PATH="${PATH}:${UNREAL_BINS}:${UNREAL_SCRIPTS}:${UNREAL_SCRIPTS_LINUX}"
export PATH
Then I run UE4Editor '/absolute/path/to/project.uproject' from within the directory of my project.
I never create a project inside the source tree of the engine. Paths should absolutely be different.
I use VS-Code as the IDE. This is what works best from my experience. QT-Creator will work only if you create an include files with lots of #define that are missing from the .pro files created by unreal.
You can configure VS-Code to have an intelli-sense like completion by installing the C# and C/C++ extensions. I had to install mono in order to get OmniSharp working (this is the server than handles the autocompletion for VS-Code). Here is an extract of my VS-Code settings.json file:
"omnisharp.path": "/home/myuser/.vscode/extensions/ms-dotnettools.csharp-1.23.9/.omnisharp/1.37.6/omnisharp/OmniSharp.exe",
"omnisharp.monoPath": "/usr/bin/mono",
You can also install the C++ Helper extensions which is usefull for creating methods, classes, and so on.
In the directory of your project run 'make YOURPROJECTNAMEEditor', then you can run 'open YOURPROJECTNAME.uproject' and it should open.

unable to start program QuantLib-vc120-mt-gd.lib

I have installed Visual Studio Community 2013, QuantLib and Boost and have gone through the steps of building the complete quantlib project as per http://quantlib.org/install/vc10.shtml guidelines.
I created a new project under QuantLib_vc11.
I both built Quantlib and the project in Debug Mode. No errors.
Then when I try to debug, I have the following error:
unable to start program QuantLib-vc120-mt-gd.lib_
Do you know where it comes from?
And another question, can we use QuantLib with CodeBlocks?
Thanks.
You're debugging with the QuantLib project as the startup project. Since
QuantLib-vc120-mt-gd.lib is a library, and not an executable file, the debugger rightly complains that it can't start it.
Before launching the debugger, select your new project as the start-up project instead. (I'm assuming that your new project defines a main function and creates an executable, right?) This will cause the debugger to start your program with QuantLib linked.
As for CodeBlocks: there's no included project for it, but QuantLib works with most (if not all) compilers it supports. Creating a new project in CodeBlocks and adding all the sources in the ql folder should enable you to create QuantLib. Note that you'll have to tell CodeBlocks to create a library; I'm not familiar with the IDE, so I'm not able to advise on how to do that.

Can I edit my C++ project in Xcode (with jump to definition/auto completion) without building the project?

I'm working on a C++ project. My company has an internal build system which runs on Linux only. I'm not able to build the project on my mac. I would try to edit my C++ code with Xcode. I'd like to have at least 'jump to definition' and 'auto completion'. I created an empty project in Xcode and imported my files in there. It shows 'Symbol not found' when I tried to jump to definition. Is it possible to let Xcode parse my code without building the project?

Building ActiveQt (COM) applications with MinGW

I am using Qt 4.6.3 with MinGW on Windows to build Qt apps and now need to add a COM interface to my application. I enabled ActiveQt but was getting post-link errors because I was missing a copy of the MIDL compiler. I downloaded a copy of the latest MS Windows SDK, which includes MIDL, but now MIDL complains it cannot find cl.exe. The only conclusion I can draw is that you can only build ActiveQt applications using the MS compiler, which I would rather avoid. Is a way to get this working with MinGW or am I out of luck?
Using the MS compiler and tools seems to be the only reliable way to get this working.
Well, you can build ActiveQt with MinGW, but using a bunch of COM stuff on top of that may not be possible, because it may or may not be present in MinGW. Some thoughts:
Using any MS SDK tools with MinGW won't work (exception is mingw.org + DXSDK which should work most of the time).
Are you sure you are linking all necessary libraries when compiling? I can't help more if you don't show the exact error messages.
The mingw-w32/w64 project tries to provide a completer "Windows SDK for GCC"; it may contain the libraries/files you are looking for. They provide a x64 and x86 compiler, and pretty good DX support. I have no experience with their COM stuff, but I believe it would be a bit more complete than mingw.org's. You can always contact the developers on the forums or mailing list, they are very helpful.
You could try the Wine implementation of midl, widl. See the Wine wiki page regarding building on Windows.
If you want to give it a quick run, get wine-prgs-0.9.14-mingw.zip and see how it works.
I agree with Rob's second post: it's a very bad thing using mingw for construction of ActiveX objects. Mingw has some bugs regarding ActiveX: https://bugzilla.mozilla.org/show_bug.cgi?id=203299 and also: https://qt.gitorious.org/qt/qt/merge_requests/2710. I kill the whole day to discover it. Use Qt for MSVS instead and all will be ok. ;)
I've solved this problem next way:
Got QtCreator, Msys2 and VS2015 Community installed.
Launching Qt Creator with batch script:
#echo off
call "C:\Program Files (x86)\Microsoft Visual Studio 14.0\VC\vcvarsall.bat" x86 8.1
setlocal
set MSYSTEM=MINGW32
set MSYS2_PATH_TYPE=inherit
start "" "C:\msys64\usr\bin\mintty" -i /msys2.ico -e /usr/bin/bash --login -c "/c/Qt/Tools/QtCreator/bin/qtcreator.exe"
exit /b 0
I am launching QtCreator out of Msys2 envioronment because it provides standart Unix tools needed to build 3rd party in my project.
So in theory this is not mandatory to have Msys2 for you.
Please note: do not use WinSDK 10.0 (or above) because it does not have midl.exe in PATH variable.
Doing this way will create PATH environment variable with Qt Creator on top priority (so you will use gcc from Qt installation), Msys2 next (so you can use standard Unix tools) and MSVC and WinSDK 8.1 at last place (so while building you will find midl compiler).
Right now I succeed building dll and passed it to midl form WinSDK, but as for now I am stil trying to register it in system.
I did actually succeed in creating and invoking in-process and out-of-process servers using QT+mingw-w64 today, so here is a write-up.
This was based on the instructions at https://doc.qt.io/qt-5/activeqt-server.html , although they were written for the Windows-native build of QT and using MSVC, so some changes were needed .
Tools installed
MSYS2 updated to latest version (as of 29 Oct 2020).
qtcreator and mingw64/mingw-w64 (64-bit target), installed via MSYS2.
Package mingw64/mingw-w64-x86_64-qt5-static installed (this causes the "Qt5 Static" kits in qtcreator to be enabled).
Visual Studio 2019 Community edition (this provides midl.exe).
https://github.com/lucasg/Dependencies - lucasg Dependencies walker. (Not essential but good for checking your static build worked).
Creating the COM DLL (without a type library yet)
These steps assume prior familiarity with QtCreator+qmake for "normal" executables.
Copy the example project from qtactiveqt/examples/activeqt/simple . I actually couldn't find this anywhere in the MSYS2 installation of QT so I cloned the QT source directly and picked out the example.
In the Kit Management in QtCreator, I selected the qt5-static 64-bit kit. This is to avoid any issues due to DLLs not being found at runtime.
This example is an out-of-process server, so to change to in-process, add to the simple.pro file the lines: TEMPLATE=lib and CONFIG += dll.
Enable static linking in GCC as I describe in this answer: https://stackoverflow.com/a/64583309/1505939
Build the project . This will give a warning that it couldn't read simple_res.o but that can be ignored. This should successfully create the output file simpleax.dll, but then there are some error messages to do with widl not found -- which we will address in the next section.
Writing the type library to the DLL
Other Windows tools (e.g. regsvr32, and any other client who wants to use the DLL) expects to be able to read the type library out of the DLL.
The DLL which was created in the previous steps does not contain a type library. I think this is because none of our toolchain tools know how to create a type library. Instead, we have to use midl.exe supplied with VS Community to generate the type library.
In QtCreator there is a post-build script that's supposed to invoke midl . However that doesn't work in the MSYS2 flavour of QtCreator. It seems it was only written for the native flavour using MSVC as the kit.
So we have to manually do the post-processing, which involves:
In the MSYS2 shell, go to the directory of simpleax.dll.
Run this command: idc simpleax.dll -idl simpleax.idl -version 1.0
Start the "x64 Native Tools Command Prompt" start menu item that came with the VS Community installation.
Navigate to the directory of simpleax.dll
Run the command: midl simpleax.idl /nologo /tlb simpleax.tlb. (Note - just adding midl to the MSYS2 path doesn't work as it can't then find a bunch of other dependencies).
Back in the MSYS2 shell, go idc simpleax.dll -tlb simpleax.tlb.
Note that you only need to do all this if the type library changes (i.e. you make a change to the class definition of your exported COM objects). If just rebuilding the project then only the last step would be needed, which you probably can add as a manual build step in the QtCreator config.
Registration and run test
Congratulations! You should now be able to open an elevated command prompt and run regsvr32 simpleax.dll and have it succeed. (If it doesn't work, run dependencies -chain simpleax.tlb and then at the end it will list any DLL dependencies).
After registration succeeded, I was able to invoke the COM object using VS Community (New C++ Console project, and #import "D:\path\to\simpleax.dll", build, and then it creates a .tlh C++ header file that contains wrappers for the DLL).
Cleaning up the type library
The type library that was created contains a whole bunch of annoying QT guff. I discovered that if you want to create a COM object that's not an ActiveX control, you can use QObject instead of QWidget as the base class. Then you don't get most of the guff that is to do with GUI elements.
Also, taking out the Q_CLASSINFO("EventsID",... line from the COM object's class definition means you don't get all the source/sink guff in the type library (for some reason it decides it has to put all the QT event sinking stuff in there).
After doing that, there is only about one screenful of guff left, including the definition of QPoint and so on, that I would consider to be a bug on the part of QT (since the stuff is not needed). I found I could just remove that from the .idl file prior to invoking midl, and hey presto we have a clean interface that can be published.
The out-of-process server
This also worked for me, identical to the above steps but without step 3 (i.e. leave it as app instead of lib). The procedure for attaching the type library via midl is the same.
Registering the type library via testobject.exe -regserver gives no message to tell you if it succeeded or failed, so another way is to use idc -regserver testobject.exe from elevated MSYS2 prompt, then it will give you a failure message.
I was able to invoke the object via VS Community just the same as for the in-process server.
Further issues still to work out
Figure out how to do this in CMake.
Automate the post-build type library procedure.
Get non-static linking working.
Automate removal of the type library guff (or report a bug)