i am getting an error in FirebasePlugin.java, how to solve it? - firebase

when i fire a command ionic build android on terminal.
it show following error.
BUILD FAILED
Total time: 7.557 secs
Error: /Users/mac2/Desktop/myProj/platforms/android/gradlew: Command failed with exit code 1 Error output: /Users/mac2/Desktop/myProj/platforms/android/src/org/apache/cordova/firebase/FirebasePlugin.java:389: error: cannot find symbol
mFirebaseAnalytics.setCurrentScreen(cordova.getActivity(), name, null);
^
symbol: method setCurrentScreen(Activity,String,<null>)
location: variable mFirebaseAnalytics of type FirebaseAnalytics
Note: Some input files use or override a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: Some input files use unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
below is the code in FirebasePlugin.java
private void setScreenName(final CallbackContext callbackContext, final String name) {
// This must be called on the main thread
cordova.getActivity().runOnUiThread(new Runnable() {
public void run() {
try {
mFirebaseAnalytics.setCurrentScreen(cordova.getActivity(), name, null);
callbackContext.success();
} catch (Exception e) {
callbackContext.error(e.getMessage());
}
}
});
}
I dont understand why such error occured in this file.
I try to solve, but i could not.
Can anyone have any idea why this happens?

Related

Issue while updating java project from JDK11 to JDK17

I have a java project using jdk11. I need to migrate the project to java 17 but integration tests have started failing. As soon as I upgraded to JDK17 I started getting below error:
java.lang.reflect.InaccessibleObjectException: Unable to make private sun.reflect.generics.repository.FieldRepository java.lang.reflect.Field.getGenericInfo() accessible: module java.base does not "opens java.lang.reflect" to unnamed module #5702b3b1
I was also getting error for java.util but that is fixed using below command line code.
I have tried adding the command line options as below but the tests are still failing
<argLine>
--illegal-access=permit
--add-opens java.base/java.lang=ALL-UNNAMED
--add-opens java.base/sun.reflect=ALL-UNNAMED
--add-opens java.base/java.util=ALL-UNNAMED
</argLine>
Any help is appreciated.
You can pass your method in to this:
public static <T extends AccessibleObject> T forceAccessible(T o) {
try {
Field unsafeField = Unsafe.class.getDeclaredField("theUnsafe");
unsafeField.setAccessible(true);
Unsafe unsafe = (Unsafe) unsafeField.get(null);
Method m = Class.class.getDeclaredMethod("getDeclaredFields0", boolean.class);
m.setAccessible(true);
Field override = ((Field[]) m.invoke(AccessibleObject.class, false))[0];
if (!o.isAccessible()) {
try {
o.setAccessible(true);
} catch (InaccessibleObjectException e) {
unsafe.putBoolean(o, unsafe.objectFieldOffset(override), true);
}
}
} catch (Exception e) {}
return o;
}

Zxing cannot be started while StartForeground is running

If you are running Start Foreground from an Android.App service
I get an error when I start Zxing (barcode reading).
Error details: Compatible code is not running.
Selective debug execution may or may not be the executable code running in the current thread.
Unhandled Exception:
Java.Lang.NullPointerException: <Timeout exceeded getting exception details>
Is there anyone who can solve this problem?
-- 2020/12/22 add --
Thank you for your reply.
I thought I'd ask a simple question,
It seems that it was not concise but vague Excuse me.
Execute background service to acquire location information continuously (every 15 minutes)
I want to read barcodes as another function,
An error will occur if the barcode is read while the background service is running.
It would be ideal if there was a way to avoid an error in this situation, but I don't know how to deal with it.
Exit background service, read barcode, then
I was wondering if I could handle it by restarting the background service.
I can't solve the problem.
1. Refer to the url below to get the location information in the background.
https://teratail.com/questions/167858
Package installation
ZXing.Net.Mobile (2.4.1)
ZXing.Net.Mobile.Forms (2.4.1)
Run the Clicked event on the Xamarin.Forms Button
The code below calls the Zxing form.
await Navigation.PushAsync (new QRScanPage ()); ← * An error occurs here
using Xamarin.Forms;
using Xamarin.Forms.Xaml;
public partial class QRScanPage: ContentPage
{
public Page00_QRScanPage ()
{
InitializeComponent ();
}
void Handle_OnScanResult (ZXing.Result result)
{
Device.BeginInvokeOnMainThread (async () =>
{
zxing.IsAnalyzing = false;
await Navigation.PopAsync ();
await DisplayAlert ("notification", "Read the following value:" + result.Text, "OK");
zxing.IsAnalyzing = true;
});
}
protected override void OnAppearing ()
{
try
{
base.OnAppearing ();
zxing.IsScanning = true;
}
catch (Exception ex)
{
DisplayAlert ("ExErr",
$ "{ex.Message}", Msg.Button.Ok);
}
}
protected override void OnDisappearing ()
{
zxing.IsScanning = false;
base.OnDisappearing ();
}
}
Service outage
Intent serviceIntent = new Intent (this, typeof (BackgroundService)); * "BackgroundService" is the running Service class
Base.StopService (serviceIntent);
Stop with StopSelf () method
As a result, nothing could be solved.

How to reduce slow start for picocli apps due to reflection

Picocli has to introspect the command tree. Doing so it needs to load the domain object classes for every Command which slows down the jvm startup.
What options are there to avoid this startup lag? One solution I've come up with is described in https://github.com/remkop/picocli/issues/482:
I am using reflection to postpone any class loading until after the command is selected. This way only the command classes themselves are loaded and finally the classes which implement the single command requested by the user:
abstract class BaseCommand implements Runnable {
interface CommandExecutor {
Object doExecute() throws Exception;
}
// find the CommandExecutor declared at the BaseCommand subclass.
protected Object executeReflectively() throws Exception {
Class<?> innerClass = getExecutorInnerClass();
Constructor<?> ctor = innerClass.getDeclaredConstructor(getClass());
CommandExecutor exec = (CommandExecutor) ctor.newInstance(this);
return exec.doExecute();
}
private Class<?> getExecutorInnerClass() throws ClassNotFoundException {
return getClass().getClassLoader().loadClass(getClass().getName() + "$Executor");
}
public void run() {
try {
executeReflectively();
} catch(...){
/// usual stuff
}
}
}
A concrete commend class:
#Command(...)
final class CopyProfile extends BaseCommand {
#Option String source;
#Option String dest;
// class must NOT be static and must be called "Executor"
public class Executor implements CommandExecutor {
#Override
public Object doExecute() throws Exception {
// you can basically wrap your original run() with this boilerplate
// all the CopyProfile's field are in scope!
FileUtils.copy(source, dest);
}
}
}
It seems like https://github.com/remkop/picocli/issues/500 may provide the ultimate solution to this. What are the other options until then?
UPDATE February 2020:
Upgrading to a recent version of picocli should fix this issue.
From the picocli 4.2.0 release notes:
From this release, subcommands are not instantiated until they are matched on the command line. This should improve the startup time for applications with subcommands that do a lot of initialization when they are instantiated.
An alternative that doesn’t require any code changes is to use GraalVM to compile your picocli-based application to a native image.
This article shows how to do this and the resulting startup time is 3 milliseconds.

javafx error even though url is correct

Even though the path given is correct & image is displaying in scene builder, it is throwing error while running the application.
Executing C:\Users\433240\Documents\NetBeansProjects\UI\dist\run547088191\UI.jar using platform C:\Program Files (x86)\Java\jdk1.8.0_40\jre/bin/java
Device "Intel(R) G41 Express Chipset" (\\.\DISPLAY1) initialization failed :
WARNING: bad driver version detected, device disabled. Please update your driver to at least version 8.15.10.2302
null/Images/home.png
Exception in Application start method
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
Caused by: java.lang.IllegalArgumentException: Invalid URL or resource not found
at javafx.scene.image.Image.validateUrl(Image.java:1091)
... 23 more
Exception running application ui.Main
Java Result: 1
I had the same problem
Solution:
go to java controller class and write this code
private Image image;
#FXML
ImageView imageview; // type your imageview fixid
private void setImage(String url) {
try {
image = new Image(url);
imageview.setImage(image);
} catch (Exception e) {
System.out.println(e);
}
}

i got error "Value cannot be null.\r\nParameter name: serviceType"

I was following a tutorial , but after setting the project build path, I run the project and navigate to plugins. Then I got the following error.
An exception of type 'System.ArgumentNullException' occurred in Autofac.dll but was not handled in user code,
"Value cannot be null.\r\nParameter name: serviceType"
and i don't know that which method i should add and in which class?
Please help!
you must register the service you created in the plugin and also the repository for your entity in DependencyRegistrar.cs file so that run time Autofac can found them for example:
public class DependencyRegistrar : IDependencyRegistrar
{
public virtual void Register(ContainerBuilder builder, ITypeFinder typeFinder)
{
//data context
this.RegisterPluginDataContext<MYPLUGINObjectContext>(builder, "nop_object_context_misc_MYPLUGIN");
//override required repository with our custom context
builder.RegisterType<EfRepository<ENTITY>>()
.As<IRepository<ENTITY>>()
.WithParameter(ResolvedParameter.ForNamed<IDbContext>("nop_object_context_misc_MYPLUGIN"))
.InstancePerHttpRequest();
}
public int Order
{
get { return 0; }
}
}

Resources