Unable to load resource for composite template - gtk3

I have a very basic GTK application written in Vala (non-working source tree here), which intend to load the resources for the main application window from a GResource.
So I created a resource file, compiled it with glib-compile-resources and also added it to VALAFLAGS as --gresources=$(top_srcdir)/data/gauthenticator.gresource.xml.
The relevant part of the data file looks like this:
<gresource prefix="/eu/polonkai/gergely/gauthenticator">
<file preprocess="xml-stripblanks">gauth-window.ui</file>
</gresource>
and I use it like this:
[GtkTemplate (ui = "/eu/polonkai/gergely/gauthenticator/gauth-window.ui")]
class Window : Gtk.ApplicationWindow {
[GtkChild]
private Gtk.ProgressBar countdown;
}
The relevant part of my Makefile.am:
gresource_file = $(top_srcdir)/data/gauthenticator.gresource.xml
gauthenticator_VALAFLAGS = --pkg gtk+-3.0 --target-glib=2.38 --gresources $(gresource_file)
All is well during compilation, but in runtime I get this error:
(gauthenticator:16501): Gtk-CRITICAL **: Unable to load resource for composite template for type 'GAuthenticatorWindow': The resource at '/eu/polonkai/gergely/gauthenticator/gauth-window.ui' does not exist
(gauthenticator:16501): Gtk-CRITICAL **: gtk_widget_class_bind_template_child_full: assertion 'widget_class->priv->template != NULL' failed
(gauthenticator:16501): Gtk-CRITICAL **: gtk_widget_init_template: assertion 'template != NULL' failed
I copied most resource-related lines from the GNOME Boxes repository, but obviously missed something.

How are you compiling the resources with glib-compile-resources? I would recommend compiling it to a C file:
glib-compile-resources --sourcedir data --generate-source --target my_build_dir/resources/resources.c data/gauthenticator.gresource.xml
Then add my_build_dir/resources/resources.c to your _SOURCES so it gets compiled along with your Vala sources. The --gresources option for valac only does type checking for Vala's GTK+ composite template support.
I've not tried compiling a GResource C file as part of a Vala to C and then C to binary compilation process. At the moment it looks like you are just using valac for the whole compilation process.

Related

R package installation with GitHub

I am trying to install the package "PITE" as it is mentioned in the codes used in the article "Subgroup Identification Clinical Trials via the Predicted Individual Treatment Effect". The codes are taken from "https://github.com/nicoballarini/PLOS-2018-PITE#subgroup-identification-clinical-trials-via-the-predicted-individual-treatment-effect". But I'm unable to load this package, it would be very helpful if anyone can tell me where am I going wrong? The error message that I get:
install_github("nicoballarini/PLOS-2018-PITE")
Downloading GitHub repo nicoballarini/PLOS-2018-PITE#master
✓ checking for file ‘/private/var/folders/ml/wj8v_nld19n52l2g3tvzmltr0000gn/T/RtmpD4r8z6/remotes186f6614c26d/nicoballarini-PLOS-2018-PITE-832e47b/DESCRIPTION’ ...
─ preparing ‘PITE’:
✓ checking DESCRIPTION meta-information ...
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building ‘PITE_0.1.0.tar.gz’
* installing *source* package ‘PITE’ ...
** using staged installation
** R
** byte-compile and prepare package for lazy loading
Error: package or namespace load failed for ‘broom’ in dyn.load(file, DLLpath = DLLpath, ...):
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/libs/Rcpp.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/libs/Rcpp.so, 6): Library not loaded: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libR.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/libs/Rcpp.so
Reason: image not found
Error: package ‘broom’ could not be loaded
Execution halted
ERROR: lazy loading failed for package ‘PITE’
* removing ‘/Library/Frameworks/R.framework/Versions/3.6/Resources/library/PITE’
Error: Failed to install 'PITE' from GitHub:
(converted from warning) installation of package ‘/var/folders/ml/wj8v_nld19n52l2g3tvzmltr0000gn/T//RtmpD4r8z6/file186f5ce8b676/PITE_0.1.0.tar.gz’ had non-zero exit status
Error in dyn.load(file, DLLpath = DLLpath, ...) :
unable to load shared object '/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/libs/Rcpp.so':
dlopen(/Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/libs/Rcpp.so, 6): Library not loaded: /Library/Frameworks/R.framework/Versions/4.0/Resources/lib/libR.dylib
Referenced from: /Library/Frameworks/R.framework/Versions/3.6/Resources/library/Rcpp/libs/Rcpp.so
Reason: image not found

Unity Error: Unable to convert classes into dex format

I have created an Android Unity plugin (.aar file) which provides some custom positioning data to my Unity game. In my Unity script, I use,
var x = customClass.CallStatic<float>("getHeadX");
In order to get some location data. This method is called per frame to get the updated data (polling method) which makes it inefficient. Instead, I decided to call a C# method in my Unity script from my java code (plugin side) when the updated data is ready. To do this, in my java plugin, I wrote,
import com.unity3d.player.UnityPlayer;
...
UnityPlayer.UnitySendMessage("Manager", // gameObject name
"PluginCallback", // this is a callback in C#
"Hello from android plugin"); // msg which is not needed actually
However, the compiler complained that the package com.unity3d.player.UnityPlayer does not exist. So I copied classes.jar file from
C:\Program Files
(x86)\Unity\Editor\Data\PlaybackEngines\AndroidPlayer\Variations\mono\Release\Classes
\classes.jar
into the 'libs' folder of my android plugin's project. I built it successfully and copied the generated .aar file (mylibrary-release.aar) into Assets\Plugins\Android folder of my Unity project.
When I build the Unity project (Using 'Internal' build system), it gives me this error:
IOException: Failed to Move File / Directory from
'Temp/StagingArea\android-libraries\mylibrary-release\classes.jar' to
'Temp/StagingArea\android-libraries\mylibrary-release\libs\classes.jar'.
UnityEditor.Android.PostProcessor.Tasks.ProcessAAR.Execute
...
This error happens because the classes.jar dependency has name conflict with classes.jar (made by unity out of my plugin). So I changed the dependency name to unity_classes.jar and this resolved the issue but now I'm getting a new error when building my unity application:
CommandInvokationFailure: Unable to convert classes into dex format.
C:/Program Files/Java/jdk1.8.0_102\bin\java.exe -Xmx2048M
Dcom.android.sdkmanager.toolsdir="C:/Users/kamran.shamloo/AppData/Local/Android/Sdk\tools"
-Dfile.encoding=UTF8 -jar "C:\Program Files (x86)\Unity\Editor\Data\PlaybackEngines\AndroidPlayer/Tools\sdktools.jar"
stderr[ Uncaught translation error:
java.lang.IllegalArgumentException: already added:
Lbitter/jnibridge/JNIBridge; Uncaught translation error:
java.lang.IllegalArgumentException: already added:
Lbitter/jnibridge/JNIBridge$a; Uncaught translation error:
java.lang.IllegalArgumentException: already added:
Lcom/unity3d/player/NativeLoader; Uncaught translation error:
java.lang.IllegalArgumentException: already added:
Lcom/unity3d/player/ReflectionHelper; Uncaught translation error:
java.lang.IllegalArgumentException: already added:
Lcom/unity3d/player/ReflectionHelper$1; Uncaught translation error:
java.lang.IllegalArgumentException: already added:
Lcom/unity3d/player/ReflectionHelper$a; Uncaught translation error:
java.lang.IllegalArgumentException: already added:
Lcom/unity3d/player/UnityPlayer; Uncaught translation error:
java.lang.IllegalArgumentException: already added:
Lcom/unity3d/player/UnityPlayer$1; Uncaught translation error:
java.lang.IllegalArgumentException: already added:
Lcom/unity3d/player/UnityPlayer$10;
...
The classes.jar (which you later renamed it to 'unity_classes.jar') gets automatically included into the built .apk by Unity, so you shouldn't include it yourself again (in your Android plugin), even under a different name.
In other words, first your android plugin "embeds" this .jar file inside itself. Then, when Unity adds your plugin into the game project, it also adds its own copy of that .jar file (it does that for all android projects). Consequently, Unity essentially ends up having 2 copies of the same .jar file in the project and complains by saying 'unable to convert classes into dex format'.
So although you have to use this library (.jar file) in your project but you should not bundle this library with your project. How to do that? If you're using Android studio, you can achieve this by marking the .jar file as a dependency with the provided scope.
To do this, you can:
1) Go to 'build.gradle' of your module and change this:
compile files('libs/jars/unity_classes.jar')
to this:
provided files('libs/jars/unity_classes.jar')
Or
2) you can right-click on the module (in Android pane) and choose Open Module Settings. Then go to Dependencies tab. Find the Unity module (which I renamed it to unity_classes.jar) and change its scope to Provided.

CMake macro inclusion issue

The aim is to have small and useful libraries included into a main application.
I create a CMakeLists.txt file to create three different library : image, utils_dir and utils_geom. The thing that bother me is the horrible redundancy with the target definition. So I tried to create some macro and I'm confronted to an inclusion issue.
The pattern of my project is presented below.
src/CMakeLists.txt (main CMakeLists including subdirs)
src/cmake/Macro.cmake (containing macro)
src/libs/core/CMakeLists.txt (library def and macro use)
I can't include my Macro.cmake file which contain the macro definition.
With the following code in the top level CMakeLists.txt (in src/) :
include(Macro.cmake)
test_macro()
And in the Macro.cmake :
macro( test_macro )
MESSAGE("Success !")
endmacro
I've got :
CMake Error at libs/core/CMakeLists.txt:8 (include):
include could not find load file:
Macro.cmake
CMake Error at libs/core/CMakeLists.txt:9 (test_macro):
Unknown CMake command "test_macro".
Did someone is using a likely configuration ?

GWT and getClass().getPackage()

I'm getting this error at runtime when I try to use getClass.getPackage().getImplementationVersion(), in my FooterViewImpl class, to show my project's version number (from the pom.xml file) on the web page. I think the error is from the gwt java-to-javascript compiler.
[ERROR] [OnlineGlom] - Line 52: The method getPackage() is undefined for the type Class<capture#1-of ? extends FooterViewImpl>
java.lang.RuntimeException: Deferred binding failed for 'org.glom.web.client.ClientFactory' (did you forget to inherit a required module?)
Should I expect this to work?
No.
getPackage() is not emulated by GWT: https://developers.google.com/web-toolkit/doc/latest/RefJreEmulation. The motto of GWT is to do the maximum at compile-time rather than runtime.

GWT 2.4: "An internal compiler exception occurred" in project that uses Hibernate for Bean Validation

It's been about 5 hrs since I decided to use JSR 303 Bean Validation in my GWT project and I gotta say I can't even express (politely) how deeply unsatisfied I am with lame documentation on the subject on Google's website.
I really hope you guys can help me.
I followed this blog post to add client-side bean validation to my project. Unfortunately it worked only once and threw an exception in runtime saying that I need to add Hibernate Validation sources to class path. I fixed that and decided to remassage my dependencies a little too (biggest mistake of my life) but I couldn't make it work ever again.
I can't play with Validation sample from GWT SDK either because it's uncompilable because it has two implementations of class ServerValidator. Weird.
So to simplify my question I created dummy GWT application using project wizard of IntelliJ IDEA.
I added following elements to module xml:
<inherits name="org.hibernate.validator.HibernateValidator"/>
<replace-with class="com.mySampleApplication.client.ClientValidatorFactory">
<when-type-is class="javax.validation.ValidatorFactory"/>
</replace-with>
Created ClientValidatorFactory:
package com.mySampleApplication.client;
import com.google.gwt.core.client.GWT;
import com.google.gwt.validation.client.AbstractGwtValidatorFactory;
import com.google.gwt.validation.client.GwtValidation;
import com.google.gwt.validation.client.impl.AbstractGwtValidator;
import javax.validation.Validator;
import javax.validation.groups.Default;
public class ClientValidatorFactory extends AbstractGwtValidatorFactory
{
#GwtValidation(value = {Organization.class}, groups = {Default.class, ClientGroup.class})
public interface GwtValidator extends Validator
{
}
#Override
public AbstractGwtValidator createValidator()
{
return GWT.create(GwtValidator.class);
}
}
And in onModuleLoad() method I added this single line which causes compiler to blow up
Validator validator = Validation.buildDefaultValidatorFactory().getValidator();
And finally I used following jars which I copied from Validation sample of GWT SDK.
hibernate-validator-4.1.0.Final-sources.jar
hibernate-validator-4.1.0.Final.jar
log4j-1.2.16.jar
slf4j-api-1.6.1.jar
slf4j-log4j12-1.6.1.jar
validation-api-1.0.0.GA-sources.jar
validation-api-1.0.0.GA.jar
But when I compile my project it gives following meaningless error:
In detailed GWT compiler log I see this:
Loaded 2315 units from persistent store.
Found 2282 cached units. Used 2282 / 2282 units from cache.
Added 0 units to persistent cache.
Validating newly compiled units
Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/org/hibernate/validator/engine/ConstraintViolationImpl_CustomFieldSerializer.java'
Line 33: No source code is available for type org.hibernate.validator.engine.ConstraintViolationImpl<T>; did you forget to inherit a required module?
Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/org/hibernate/validator/engine/ValidationSupport.java'
Line 43: No source code is available for type org.hibernate.validator.engine.ConstraintViolationImpl<T>; did you forget to inherit a required module?
Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/EmailValidator.java'
Line 25: No source code is available for type org.hibernate.validator.constraints.Email; did you forget to inherit a required module?
Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/ScriptAssertValidator.java'
Line 26: No source code is available for type org.hibernate.validator.constraints.Email; did you forget to inherit a required module?
Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/org/hibernate/validator/super/org/hibernate/validator/constraints/impl/URLValidator.java'
Line 26: No source code is available for type org.hibernate.validator.constraints.URL; did you forget to inherit a required module?
Errors in 'jar:file:/C:/work/externals/gwt/gwt-user.jar!/org/hibernate/validator/super/org/hibernate/validator/engine/PathImpl.java'
Line 72: No source code is available for type org.hibernate.validator.engine.NodeImpl; did you forget to inherit a required module?
Why can't it find classses? I have hibernate-validator-4.1.0.Final-sources.jar in my classpath.
Any thoughts ?
I uploaded my project here if you guys want to play with it.
Case closed, guys. Error was caused by lack of hibernate validation sources in classpath because of bug in IntelliJ IDEA. Details are here.