GlideApp symbol not found in Android Studio 4.1 - android-glide

I have been using Glide 4.11.0 and Realm 6.0.2 for some time now, and recently upgraded Android Studio 4.0.x to 4.1. All has been going fine. Today I ran the lint checker, and started doing some "clean up", nothing out of the ordinary (it would seem). One of the things I did a lot of was to replace switch statements that were testing against R.id. with if-else statements per the lint warning about what's gonna happen in Gradle 5.0.
When I did this, I did use a number of int variables I named 'id' that were to replace the value to compare - i.e. instead of a switch statement that would be:
switch (menuOpt.getId()) {
case R.id.xxx:
...
}
I would do:
int id = menuOpt.getId();
if ( id == R.id.XXX) {
} else if....
per the new guidelines.
Suddenly, on a full build AS complains that it no longer recognizes GlideApp, and I am also getting a very weird message about Realm not being able to process correctly:
C:\BLD\AndroidStudioProjects\InTouch\app\src\main\java\com\reddragon\intouch\ui\MediaPlayerActivity.java:61: error: cannot find symbol
import com.reddragon.intouch.utils.GlideApp;
^
symbol: class GlideApp
location: package com.reddragon.intouch.utils
C:\BLD\AndroidStudioProjects\InTouch\app\src\main\java\com\reddragon\intouch\ui\MediaDialogActivity.java:92: error: cannot find symbol
import com.reddragon.intouch.utils.GlideApp;
^
symbol: class GlideApp
location: package com.reddragon.intouch.utils
C:\BLD\AndroidStudioProjects\InTouch\app\src\main\java\com\reddragon\intouch\ui\MediaListActivity.java:48: error: cannot find symbol
import com.reddragon.intouch.utils.GlideApp;
^
symbol: class GlideApp
location: package com.reddragon.intouch.utils
Note: Version 10.0.0 of Realm is now available: https://static.realm.io/downloads/java/latest
Note: Processing class Album
error: Class "Album" contains illegal final field "id".
Note: [1] Wrote GeneratedAppGlideModule with: []
Class "Album" contains illegal final field "id".
4 errors
I have had the field 'id' in my Album class for about 2 years with no issues!
No manner of rebuild, invalidating cache and restarting, syncing gradle files or "reload all from disk" seems to help.
Actually, if I invalidate and restart, I don't get the red squiggle in the offending classes that are referencing GlideApp, but as soon as I start to run the app and it goes through a build process it errors out.
I Googled a bit and found one post where there seemed to be some conflict between Realm and Glide (RequestOptions), but the strange thing to me is why would this suddenly start occurring?
I have validated that the GlideAppjava class is in fact getting built - I am using the debug build variant, and I can see in the file system GlideApp.java that is in the ap_generated_sources/debug directory in the proper package where I have my class that extends AppGlideModule with the #GlideModule annotation.
So GlideApp is getting generated. It just isn't getting recognized.
One of the other new things is that I've recently created a Dynamic Feature module. This module does depend on a class that is in the base module (where GlideApp is referenced). Not sure if this is relevant (I had many, many successful builds before I started doing lint clean-up).
So frustrating! Any help appreciated.

It turns out that the answer was staring right at me, although somewhat hidden: part of the lint check that I did was accept some suggestions about making variables 'final' - including those that are used in Realm classes to define Realm objects. Realm doesn't like that - above build error output includes as a last line the statement 'Class "Album" contains illegal final field "id".'
"Album" extends RealmObject, and the "auto accept" of the lint's suggestion to make some of the fields final was the culprit.
I think this issue with Realm caused a ripple effect somehow with the other annotation processing - when I went back to all the RealmObject classes and removed the "final" declaration, build now completes smoothly.

Related

An error occurred getting entities in Linkedin's WhereHows

After installing Linkedin's WhereHows following the github docs (https://github.com/linkedin/WhereHows/blob/master/wherehows-docs/getting-started.md#getting-started), logging into the web UI, and navigating to the Datasets tab, it complains
An error occurred getting entities
SyntaxError: JSON.parse: unexpected character at line 3 column 1 of the JSON data
Looking at the developer console in the web browser, can see the error outputs
SyntaxError: JSON.parse: unexpected character at line 3 column 1 of the JSON data[Learn More] vendor-01c52695e9f268de5628f7bec75d6bb1.js:65255:14
tryCatcher http://localhost:9001/assets/assets/vendor-01c52695e9f268de5628f7bec75d6bb1.js:65255:14
invokeCallback http://localhost:9001/assets/assets/vendor-01c52695e9f268de5628f7bec75d6bb1.js:65437:15
publish http://localhost:9001/assets/assets/vendor-01c52695e9f268de5628f7bec75d6bb1.js:65422:9
Queue</Queue.prototype.invoke http://localhost:9001/assets/assets/vendor-01c52695e9f268de5628f7bec75d6bb1.js:27963:17
Queue</Queue.prototype.flush http://localhost:9001/assets/assets/vendor-01c52695e9f268de5628f7bec75d6bb1.js:27848:25
DeferredActionQueues</DeferredActionQueues.prototype.flush http://localhost:9001/assets/assets/vendor-01c52695e9f268de5628f7bec75d6bb1.js:28035:25
Backburner</Backburner.prototype.end http://localhost:9001/assets/assets/vendor-01c52695e9f268de5628f7bec75d6bb1.js:28169:26
Backburner/this._boundAutorunEnd http://localhost:9001/assets/assets/vendor-01c52695e9f268de5628f7bec75d6bb1.js:28131:17
Unhandled promise rejection SyntaxError: JSON.parse: unexpected character at line 3 column 1 of the JSON data
Stack trace:
tryCatcher#http://localhost:9001/assets/assets/vendor-01c52695e9f268de5628f7bec75d6bb1.js:65255:14
invokeCallback#http://localhost:9001/assets/assets/vendor-01c52695e9f268de5628f7bec75d6bb1.js:65437:15
publish#http://localhost:9001/assets/assets/vendor-01c52695e9f268de5628f7bec75d6bb1.js:65422:9
Queue</Queue.prototype.invoke#http://localhost:9001/assets/assets/vendor-01c52695e9f268de5628f7bec75d6bb1.js:27963:17
Queue</Queue.prototype.flush#http://localhost:9001/assets/assets/vendor-01c52695e9f268de5628f7bec75d6bb1.js:27848:25
DeferredActionQueues</DeferredActionQueues.prototype.flush#http://localhost:9001/assets/assets/vendor-01c52695e9f268de5628f7bec75d6bb1.js:28035:25
Backburner</Backburner.prototype.end#http://localhost:9001/assets/assets/vendor-01c52695e9f268de5628f7bec75d6bb1.js:28169:26
Backburner/this._boundAutorunEnd#http://localhost:9001/assets/assets/vendor-01c52695e9f268de5628f7bec75d6bb1.js:28131:17
Does anyone know what this error means and where to look to investigate further (first time working with wherehows and the given output on its own it not very helpful to my uninitiated self)?
** Note my configuration variables for the Play frontend (https://github.com/linkedin/WhereHows/blob/master/wherehows-docs/getting-started.md#frontend-setup) look like
export WHZ_DB_USERNAME="wherehows"
export WHZ_DB_PASSWORD="wherehows"
export WHZ_DB_URL="jdbc:mysql://localhost/wherehows"
export WHZ_ES_DATASET_URL="localhost:9200/wherehows"
export WHZ_ES_METRIC_URL="localhost:9200/_nodes/stats" (honestly don't know if this is correct (don't use elasticsearch much))
export WHZ_ES_FLOW_URL="localhost:9200/wherehows/flows_jobs"
export YOUR_HDFS_BROWSER_LINK="http://node004.myco.local:8888/filebrowser/#"
export WHZ_LDAP_URL="ldap://co.myco.local:389"
export WHZ_LDAP_PRINCIPAL_DOMAIN="#co.local"
export WHZ_LDAP_SEARCH_BASE="ou=mapr access,dc=co,dc=local"
Looking at this github issue seems to dedscribe something similar recent problem (around May 1, 2018) (https://github.com/linkedin/WhereHows/issues/1131#issuecomment-385882867). The response is in chinese, but using google translate it reads:
The latest code has a dao method did not write SQL, throw an exception directly, may be the author has not finished, you can try to use the 1.0.0 this tag, I tried this is no problem
So checking out the commit with tag v1.0.0
git checkout tags/v1.0.0
Adding redoing the parts of the installation that needed redoing (eg. adding the extralibs, setting the frontend configuration variables, starting the front- and backends), I see that error message no longer appears.

How to use PrimeNG with Angular in aspnetcore-spa template

You know, I spend more time just trying to get things set up to work with Angular than I do actually developing with Angular. There must be an easier way... :(
Currently, I am using the aspnetcore-spa template, creating a project with the command "dotnet new angular" - this is version 1.0.3, which adds Angular 4.1.2 to the npm dependencies. This works great to get a project running quickly. But now I want to add PrimeNG to take advantage of their form controls. I have been struggling with this all day, and would love it if anyone could provide some assistance.
Here is what I have done in my current effort (the latest of many, starting fresh each time):
1) Added to the package.json file: "primeng": "4.1.0-rc.2"
2) Added 'primeng/primeng' to the webpack.config.vendor.js file's vendor collection.
3) Added the following to my test module (which is in turn referenced in app.module.shared.ts so I can route to it via my RouterModule):
import { FileUploadModule } from 'primeng/components/fileupload/fileupload';
And in the html for the module, in an attempt to use the file uploader control, I have (from their site - https://www.primefaces.org/primeng/#/fileupload):
<p-fileUpload name="myfile[]" url="./upload.php"></p-fileUpload>
4) ran "webpack --config webpack.config.vendor.js" from a command prompt at the root of the project folder, which completed with no errors.
Then I hit F5 to run the project, and I got this error:
Exception: Call to Node module failed with error: Error: Template parse errors:
'p-fileUpload' is not a known element:
1. If 'p-fileUpload' is an Angular component, then verify that it is part of this module.
2. If 'p-fileUpload' is a Web Component then add 'CUSTOM_ELEMENTS_SCHEMA' to the '#NgModule.schemas' of this component to suppress this message. (" type="button" (click)="onclick()" class="ui-button-info" label="Click Me">Click Me</button>-->
So, in an effort to comply, I added a reference to the ngprime module to the app.module.shared.ts file, like this (I don't really know how I should reference the module...):
import { FileUploadModule } from 'primeng/primeng';
But got the same exact error.
What am I missing???
Any help would be most appreciated.
I finally have this working, using the asp-prerender-module to get server-side rendering, and not having to rely on the asp-ng2-prerender-module (see my last comment). The trick, I found, was to reference the FileUploaderModule in the app.module.shared.ts file like this:
import { FileUploadModule } from 'primeng/components/fileupload/fileupload';
rather than like this:
import { FileUploadModule } from 'primeng/primeng';
The reason this matters is that the latter method of referencing will load all other components as well (see explanation here: https://www.primefaces.org/primeng/#/setup), and SOME of the PrimeNG components can not be rendered on the server due to DOM-related references (things like "window", which do not exist on the server). See the discussion here for more on this: https://github.com/primefaces/primeng/issues/1341
This change, combined with the other steps listed in my answer and, of course, actually referencing the directive in app.module (thank you #pankaj !) made everything work correctly at last. Only took me about 7 hours to figure it out. :(

How can I use reflection with Java 9 on the Java internals?

We use this type of Reflection only in our test framework and not in production. We want add some jar files to the app classloader depending of our test code. Is there any workaround for it? How can we get access to not exported classes?
java.lang.reflect.InaccessibleObjectException: Unable to make member of class jdk.internal.loader.ClassLoaders$AppClassLoader accessible: module java.base does not export jdk.internal.loader to unnamed module #9f73a2
at jdk.internal.reflect.Reflection.throwInaccessibleObjectException(Reflection.java:414)
at java.lang.reflect.AccessibleObject.checkCanSetAccessible(AccessibleObject.java:174)
at java.lang.reflect.Method.checkCanSetAccessible(Method.java:191)
at java.lang.reflect.Method.setAccessible(Method.java:185)
Accessing module-internal classes can not be done from code. This is on purpose. But there is a workaround from the command line - a non-standardized option on java that does what you want:
--add-exports <module>/<package>=<target-module>(,<target-module>)*
updates <module> to export <package> to <target-module>,
regardless of module declaration.
<target-module> can be ALL-UNNAMED to export to all
unnamed modules.
Note
Java 9 is a moving target and the exact syntax has been changed a couple of times - as was this answer. This means (a) some of the comments below may seem outdated and (b) the flag might not work exactly like that. Please leave a comment and it will get fixed.

Error while compiling botan sample example in Qt

I am trying to find out the error for two days but still haven't got this unknown reason figure out.
I have configured and compiled Botan library. Everything goes ok but when try to write this sample code to be run..
S2K* s2k = get_s2k("PBKDF2(SHA-256)");
s2k->set_iterations(4049);
SecureVector<byte> key_and_IV = s2k->derive_key(48, passphrase).bits_of();
SymmetricKey key(key_and_IV, 32);
it says error: 'class Botan::PBKDF' has no member named 'set_iterations'
How can I solve this problem ?
The Botan docs for v1.11.1 report that the function get_s2k() has been deprecated, recommending that you use get_pbkdf() instead.
According to the docs, get_sdk(algospec) just returns the result of a call to get_pbkdf(algo_spec) which will give you a pointer to an instance of the class Botan::PBKDF.
First things first then, your code needs to be something more like:
PBKDF *s2k = getpbkdf("PBKDF2(SHA-256)");
Unfortunately without knowing what you want to do with s2k I can't help any further, as the docs have no reference to a public member function of PBKDF called set_iterations(). You're getting the error you mention because Botan::PBKDF really does have no member named set_iterations. You need to read the docs, work out what the purpose of set_iterations() was in your now deprecated example and hence how to achieve that purpose in the newer version of the library.
Possibly you missed your library header... as your error message says: 'has no member named...'

Specflow error using TestDriven.Net - Couldn't Find Type

I'm trying out Specflow for the first time, and have created a VS2010 project with a reference to TechTalk.SpecFlow, as well as nunit.framework. I've added a sample Feature file:
Feature: Addition
In order to avoid silly mistakes
As a math idiot
I want to be told the sum of two numbers
#mytag
Scenario: Add two numbers
Given I have entered 50 into the calculator
And I have entered 70 into the calculator
When I press add
Then the result should be 120 on the screen
When I execuyte the test (using TestDriven.Net), I get the following error:
Test 'T:SpecFlowFeature1' failed: Couldn't find type with name 'SpecFlowFeature1'
System.Exception: Couldn't find type with name 'SpecFlowFeature1'
at MutantDesign.Xml.Documentation.MemberInfoUtilities.FindMemberInfo(Assembly assembly, String cref)
at TestDriven.TestRunner.AdaptorTestRunner.Run(ITestListener testListener, ITraceListener traceListener, String assemblyPath, String testPath)
at TestDriven.TestRunner.ThreadTestRunner.Runner.Run()
Anyone know what I'm missing?
Actually traced this down to how I was running the test. Right clicking the ".feature" file (or anywhere within that file) and selecting "Run Tests" resulted in the error. Right clicking the underlying ".feature.cs" file and selecting "Run Tests" executed correctly. Looks like TestDriven.Net wasn't able to "understand" the "*.feature" file.
I typically start "Couldn't find type..." errors in my references folder and make sure that the library that I'm referencing is being referenced correctly and that the version that's being referenced isn't outdated.
Also, make sure that your SpecFlowFeature1 class isn't mistakenly declared as private. Visual Studio creates new classes (by default) as private and if you don't specify a class as public, it will remain private and not "visible" to outside projects.

Resources