Flurry Integration Error: Cannot find symbol method init() - java

In my application class, in OnCreate(), I've added the following bit of code:
new FlurryAgent.Builder()
.withDataSaleOptOut(false) //CCPA - the default value is false
.withCaptureUncaughtExceptions(true)
.withIncludeBackgroundSessionsInMetrics(true)
.withLogLevel(Log.VERBOSE)
.withPerformanceMetrics(FlurryPerformance.ALL)
.build(context, API_KEY);
Also, in the gradle, I've added implementation like,
implementation 'com.flurry.android:analytics:12.11.0'
Now, when I'm trying to add FlurryAgent.init(Context, String) in a method, I'm receiving the error "cannot find symbol method init(Context, String). The same is the case with FlurryAgent.setLogEnabled(True).
This is the first time I'm working with Flurry. Can anyone please guide me?

FlurryAgent.init(Context, String) method was removed from Flurry SDK. You should use FlurryAgent.Builder()...build(Context, String) to initialize Flurry.
Looks like you already use FlurryAgent.Builder.build here. You don't need to use FlurryAgent.init again.

Related

Using enums with LispWorks' Java interface

I'm trying to use the EWS Java library (link) with LispWorks 7.1.2 Win32's Java interface. I am somewhat familiar with basic Java concepts but have no experience with the Java language. This is the code I am trying to mimic:
ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010_SP2);
So I figured I would create an ExchangeVersion object (which is an enum), set it to the value "Exchange2010_SP2", and pass it to another create-java-object expression for the ExchangeService object.
This was my first step:
(create-java-object "microsoft.exchange.webservices.data.core.ExchangeService"
"microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion.Exchange2010_SP2")
However, I get the following error message: constructor of microsoft/exchange/webservices/data/core/ExchangeService first arguments is wrong type, wanted microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion got "microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion.Exchange2010_SP2"
OK, so then I tried this:
(create-java-object "microsoft.exchange.webservices.data.core.ExchangeService"
"microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion")
which gave me the error: constructor of microsoft/exchange/webservices/data/core/ExchangeService first arguments is wrong type, wanted microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion got "microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion". Which doesn't make much sense to me. So finally I tried to create a standalone ExchangeVersion object:
(create-java-object "microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion")
which led to this error message: CREATE-JAVA-OBJECT: : Failed to find constructors for class "microsoft.exchange.webservices.data.core.enumeration.misc.ExchangeVersion".
I wonder if anyone have suggestions on what am I doing wrong?
Many Thanks!

How to use String ressource in Java file in Android without a Layout

I have a Java class that mainly contains strings. It does not have a layout as it is neither a Fragment nor an Activity. It is more used as an auxilliary class. I would like to assign the String values in the class by using the Resource strings as I would like to automatically translate the Strings. Howvever, I can't access the string resources from Java. I use the following code:
static String more = getString(R.string.more);
And in the XML file I have the ressource:
<string name="more">More</string>
I get the error message
Cannot resolve method 'getString'
I also tried static String more = getContext().getString(R.string.more);
but I got the error message:
Cannot resolve method 'getContext'
Would anyone mind helping me on that? I'd appreciate every comment.
Update: I tried to use the answer from "MikaelM"
Resources.getSystem().getString(R.string.more)
However, I get an "exception in initializer error" and when I use the initial String again, I do not get this error. So I still can't get the String from the ressource. DO you have an idea what I can do? I'd appreciate every further comment.
So the error is caused by "Caused by: android.content.res.Resources$NotFoundException: String resource ID #0x7f120038"
The strange thing is that the resource in fact exists (I checked this several times).
getString(R.string...
is not the same as
Resources.getSystem().getString(android.R.string...
Only the second variant you can use in the static context. Alas, you can get this way only system resources.
If you need to get your own resources, no one-line solution exists. Use https://stackoverflow.com/a/4391811/715269 solution of #Cristian. And notice: it is a very good solution, even more, it is the solution meant to be used by the creators of Android.
You should be able to get your string with:
Resources.getSystem().getString(R.string.more)
See more here, getString Outside of a Context or Activity

Azure Custom Vision Parameter this.client.endpoint() is required and cannot be null

I'm trying to get a basic Custom Vision image classifier working by following the tutorial in the Azure documentation found here: https://learn.microsoft.com/en-us/azure/cognitive-services/custom-vision-service/quickstarts/image-classification?pivots=programming-language-java
I have followed this tutorial word for word and have spent a couple days trying to work this out. The issue I am having is when running the code I am getting the following stack trace:
Parameter this.client.endpoint() is required and cannot be null.
java.lang.IllegalArgumentException: Parameter this.client.endpoint() is required and cannot be null.
at com.microsoft.azure.cognitiveservices.vision.customvision.training.implementation.TrainingsImpl.createProjectWithServiceResponseAsync(TrainingsImpl.java:2313)
at com.microsoft.azure.cognitiveservices.vision.customvision.training.implementation.TrainingsImpl$TrainingsCreateProjectParameters.execute(TrainingsImpl.java:2401)
at com.microsoft.azure.cognitiveservices.vision.customvision.samples.CustomVisionSamples.ImageClassification_Sample(CustomVisionSamples.java:67)
at com.microsoft.azure.cognitiveservices.vision.customvision.samples.CustomVisionSamples.runSample(CustomVisionSamples.java:46)
at com.microsoft.azure.cognitiveservices.vision.customvision.samples.CustomVisionSamples.main(CustomVisionSamples.java:374)
The endpoint is defined here and passed as a parameter
final String Endpoint = System.getenv("AZURE_CUSTOMVISION_ENDPOINT");
CustomVisionTrainingClient trainClient = CustomVisionTrainingManager.authenticate("https://{Endpoint}/customvision/v3.0/training/", CustomVisionTrainingClientKey).withEndpoint(Endpoint);
CustomVisionPredictionClient predictClient = CustomVisionPredictionManager.authenticate("https://{Endpoint}/customvision/v3.0/prediction/", predictionApiKey).withEndpoint(Endpoint);
While the tutorial doesn't explicitly state to do so I have tried to set the system environment variable AZURE_CUSTOMVISION_ENDPOINT manually with PowerShell and it doesn't work with or without this set.
Am I missing something? Any help would be greatly appreciated!
Fixed my own issue. The environment variables had not set correctly and were null pointers. I replaced the System.getenv call to the string in plain text and this is working correctly.

How to integrate soundcloud sdk in android application...!

I tried googling that's cause i am found 2 methods code.google.com/p/soundcloudapi-java/
in that step-1 occurred
java.lang.NoClassDefFoundError: oauth.signpost.commonshttp.CommonsHttpOAuthConsumer
i tried to found that solution but not got success anyone can help to sort out these bug......
am i trying to second one
github.com/soundcloud/java-api-wrapper so please suggest how to use it
Thanks in Advance...!!!!
i am including these library file...!!!
I found my mistake and how to integrate the sound-cloud SDK.
// Create a wrapper instance
ApiWrapper wrapper = new ApiWrapper("client_id", "client_secret", null, null, Env.LIVE);
Here, initialization of the ApiWrapper class pass old argument null at position of Env.LIVE* but in the new SDK it passes out Env.LIVE the parameter.

Invoke getMessageWaitingIndicator count of PhoneBase.java

I am trying to retrieve count of voicemail .For this I am trying to call getMessageWaitingIndicator method of PhoneBase.java.
My Code is as given below
Class<?> class2=Class.forName("com.android.internal.telephony.PhoneBase");
Method method=class2.getMethod("getMessageWaitingIndicator");
Boolean returnValue=(Boolean) method.invoke(class2);
But Everytime I am getting an exception as mentioned below :
java.lang.IllegalArgumentException: expected receiver of type com.android.internal.telephony.PhoneBase,
but got java.lang.class<com.android.internal.telephony.PhoneBase>
I don't understand it. How can I fix this issue?
The instruction:
method.invoke (stringValue);
needs the object in which the method will be invoked.
method = class2.getMethod('myFunction',String.class);
method.invoke(someInstanceOfMyActivity, stringValue);
Documentation:
http://docs.oracle.com/javase/6/docs/api/java/lang/reflect/Method.html
Edit.
You can also look at the answer to the very close question here:
Android Reflection Method Error

Categories