Where do resource files go in a Gradle project that builds a Java 9 module?

Update (25 March 2020): There has been significant progress towards proper JPMS support. A nightly build of Gradle 6.4 now includes options to develop with Java 9 modules natively. See https://github.com/gradle/gradle/issues/890#issuecomment-603289940 . Update (29 September 2020): Since Gradle 6.4 (current release as of this update is 6.6.1) you can now support JPMS modules natively in … Read more

How to Read an embedded resource as array of bytes without writing it to disk?

You are actually already reading the stream to a byte array, why not just stop there? public static byte[] ExtractResource(String filename) { System.Reflection.Assembly a = System.Reflection.Assembly.GetExecutingAssembly(); using (Stream resFilestream = a.GetManifestResourceStream(filename)) { if (resFilestream == null) return null; byte[] ba = new byte[resFilestream.Length]; resFilestream.Read(ba, 0, ba.Length); return ba; } } edit: See comments for a … Read more

How can I force Proguard to keep my .xml resource file?

You shoud add a new file keep.xml under res/raw. <?xml version=”1.0″ encoding=”utf-8″?> <resources xmlns:tools=”http://schemas.android.com/tools” tools:keep=”@layout/l_used*_c,@layout/l_used_a,@layout/l_used_b*” tools:discard=”@layout/unused2″ /> In tools:keep, you list the layouts you want to keep. You can even keep specefic drawables if you use reflection in your code to get your drawable tools:keep=”@drawable/ico_android_home_infosperso” I prefer to add tools:shrinkMode=”strict” so that I make sure … Read more

How to check if image object is the same as one from resource?

if (pictureBox1.Image == Labirint.Properties.Resources.first) There’s a trap here that not enough .NET programmers are aware of. Responsible for a lot of programs that run with bloated memory footprints. Using the Labirint.Properties.Resources.xxxx property creates a new image object, it will never match any other image. You need to use the property only once, store the images … Read more

Can I link a plain file into my executable? [duplicate]

You could do this: objcopy –input binary \ –output elf32-i386 \ –binary-architecture i386 my_file.xml myfile.o This produces an object file that you can link into your executable. This file will contain these symbols that you’ll have to declare in your C code to be able to use them 00000550 D _binary_my_file_xml_end 00000550 A _binary_my_file_xml_size 00000000 … Read more