Dart2JS compiler exception when minify is used on google_maps package - google-maps

I have been building a web application with Dart and AngularDart upon Google Maps. I noticed a problem since the begin of the process even though I tested the development Dart sdk, and today the latest dart sdk (version 1.0.0.10_R30798) and still face the problem.
Firstly the packages I am using are shadow_dom, google_maps and AngularDart.
When I build my application WITH --no-minify option it works great, even in all the browsers after fiddling around with shadow_dom for a week (I should add the shadow_dom script BEFORE everything else to work properly).
The problem is that when I build normally (minify) or even directly using Dart2JS compiler with the --minify option the application does not run and I get an exception.
Above you can see the two cases, where in the first the application loads the google maps correctly and in the second picture the google maps are not loaded and I get that exception.
More importantly is that if I use a 3rd party minifier to minify the original main.dart.js file (the unminified) it works perfectly fine.
Thank you

The 2.x version of google_maps package has removed the dependency on dart:mirrors and is only based on dart:js. So the minification problem should come from another part of your code.
Moreover I just tested the map-simple example with --minify and it works.

Usually this can be solved with the #MirrorsUsed annotation if it's 3rd-party code that is affected.
It's easier with your own code where you just have to add #reflectable to the affected functions/methods/fields to ensure they are retained.
It may be hard to find what functions/methods/fields should be included when the names are minified.
Maybe you can gain some knowledge by looking at the stack trace.
Minification usually drops code that is not referenced anywhere.
In Polymer this is because polymer expressions {{ expr }} in HTML are not yet considered.
If you invoke parts of the code only by reflection this is also not recognized.
I have no experience with regard to Angular and minification.
This is just generic advice about problems with minification through pub build.

Related

Google Services Gradle Plugin not generating resources from json

Problem started suddenly and seems to be not related to any change that happened in code around its first occurance.
We have automated CI workflow that prepares RC.
At first every second build worked. Now I had to rebuild RC 7 times to get app that is not crashing.
After investigating it is clear that there are no config values in resources, ergo plugin is not generating values from json config file. Basically rebuilding same code many times makes it work, at some point.
We had recently changed dependency injection in app from dagger components to hilt, it might be the reason of some kind of race or shared resources during build time.
It is also problematic to work around. I've prepared resource files with all values in order to manually add them in build process instead of generating with plugin. Now, because we also use crashlytics, I cannot remove google services plugin as crashlytics is checking for google services tasks in gradle. I cannot remove unused json file as plugin will crash because of lack of config file. Plugin also (based on docs https://developers.google.com/android/guides/google-services-plugin) adds some dependencies to main module, but I wasn't able to find anything in :app:dependencies so maybe docs are outdated.
I am not able to provide any project for reproduction as it only happens in commercial project. I understand it makes the problem hard to resolve in such case but maybe other people has it also.
AGP: 7.2.0-beta02
Google Services plugin: 4.3.10
Hilt: 2.41
EDIT:
I've resolved symptoms by creating gradle module for each build type we have, and each module contains only res/values.xml which I've copied from app/build/generated/res/google-services/*. This way required keys are always available in resources, as we do not often (hardly ever) change json file with config. I am still trying to investigate builds with --scan option but I cannot reproduce it with scan, it only happens without it.

How to enforce module boundaries in Java <= 8

I want to modularize a monolithic application by using Java modules (introduced by Project Jigsaw).
Unfortunately I'm currently stuck to use Java 8. I would like to build those modules (jar files) anyway, but without the feature of using a module-info.java file for declaring the dependencies and the exported API.
Some weeks ago I stumbled upon an API/framework which allows to define nearly the same things that you can do in a module-info.java file. It could be used in JUnit tests in order to enforce module's not to use the internal's of another module and that module's only can access modules they explicitly depend on.
Of course you do not have any assistence from the compiler or the IDE, but you can enforce the access by JUnit. Unfortunately I do not find the project which provides the API any more.
Can anyone help?
Btw. if there is another good approach beside a unit test, please let me know, too!
https://www.archunit.org/ is what I have been looking for.

AIR Build Server Setup

I am at the point where I am running into incredibly long build times for my project and more projects to come. I would like to make a build server but I have not had any experience with them aside from downloading files from them as an end user.
My ideal setup is this: A GitHub where I can place my .fla file, classes and ANEs. The server sees this, compiles it, and allows me to test it remotely or hook into some debugger that lets me see stack traces and active variables at breakpoints and errors like Adobe Animate or Flash Builder.
Now I see there are GitHub plugins for Jenkins. I see there are questions referring to how to set one up with Flex/AIR. I come here with a few issues.
I am too far into my project to switch over from using Animate to something like Flash Develop or anything ADT related. The only thing I have found is how to take existing elements from my library in Animate and have them in a .swc for handling. However, this doesn't let me access existing elements in the Timeline and would rather not try to export/position/handle them in code (which is the only workaround that I see if this is not possible)
I run ANEs that are dependent on Google Play services and other Android specific libraries. Thus, I haven't been able to use the standard mobile debug launcher for AIR. I see Jenkins has some specific abilities for Android. Is it possible to somehow use this to give me a proper window for testing? I am thinking that I would need to run their emulator after compiling everything but I am unsure if there is a more efficient method or if it would even work.
I have never worked with Jenkins before or any other tools capable of automating tasks. Any step by step explanations is appreciated if you have the time.

metadata tag not found with describeType in production

I am using describeType and am able to get all of the variable and accessor metadata tags just fine in local debug, local test suite or local air build. Our web app running this code also sees the metadata just fine in production (running with browser plugin). But, our production air desktop app throws my error "can't find metadata". When I added some logging code (being thoroughly confused LOL) I discovered that the metadata property in the XML from describeType is empty?!?
My only thought is that we use gradle and run a bunch of custom scripts during the actual build process... but HOW could that be either removing or making unreadable class metadata tags?
I've tried standard v/s custom tags, accessors v/s variables, describeType(instance) v/s describeType(class) and all of these give same result... all variations work everywhere every time except in production desktop build.
Anyone with ANY thoughts on this... please chime in. I've been pulling my hair out with this one!
Thanks!!!
so it turns out my "only thought" was the correct answer. after digging deeper I found that the keep-as3-metadata that was on our compiler options was not up to date in our grade build scripts and didn't include the tags we were using for this. Thank god!!! LOL.

Using Java/Python libraries in programming Firefox/Chrome Extensions

I have an idea of studying user behavior on the browser, for which I intend to make a Chrome/Firefox extension to study the behavior dynamically. I have some predefined libraries in Java and Python to analyze the results, which will be impossible to program in plain JavaScript.
Now for my question: is it possible to use third party libraries, especially those of Python or Java like plain function calls?
I have a vague idea about something like Java XPCOM or PyXPCOM for Firefox. However, for a beginner, it all looks so scary. I started making Add-On for Firefox, but got lost somewhere in the huge API.
I found Programming Chrome extensions easier than Firefox, but I couldn't come across something similar to XPCOM in Chrome.
How can I decide which one to go for?
Chrome - seems easy but I am not sure of its power.
Firefox - Seems powerful, but is it really possible to use any Java/Python Library?
Additionally, I came across this link that may be useful: How does someone use thirdparty libraries to be included in Firefox addons/extensions?
But seems like it mostly talks about C++ and XPCOM.
I have a vague idea about something like Java XPCOM or PyXPCOM for Firefox. But for a beginner, it all looks so scary.
I am not a beginner and JavaXPCOM/PyXPCOM are very scary (in addition to being barely maintained). As Firefox goes, it should be much easier to wrap your Java/Python library in an application and run it as an external process: https://developer.mozilla.org/en/XPCOM_Interface_Reference/nsIProcess. Note that you cannot get data back (other than an exit code) so the application should write it to a file that you can then read in your Firefox extension. Not very elegant but it has the advantage of being doable.
As to Chrome, its extensions run in a sandbox and using Java or Python isn't possible. Only option is adding an NPAPI plugin to your extension. It is binary code meaning that it could do anything.
When writing Chrome extensions, you're limited to JavaScript unless you choose to use an NPAPI plugin, which lets you do pretty much anything, but is not recommended.
The other approach you could take is to implement your Java or Python code on the server and make requests from the chrome extension's JavaScript.