How to debug "error: cannot find symbol method" in Android code? - java

Why do I get these error's and how do I fix them...noob here please help?
error: cannot find symbol method getServiceUuid()
error: cannot find symbol method toByteArray()
error: cannot find symbol variable UrlBeaconUrlCompressor
Code:
beaconManager.setRangeNotifier(new RangeNotifier() {
#Override
public void didRangeBeaconsInRegion(Collection<Beacon> beacons, Region region) {
// code to get URL below!!!!!
for (Beacon oneBeacon : beacons) {
if (oneBeacon.getServiceUuid() == 0xfeaa && oneBeacon.getBeaconTypeCode() == 0x10) {
// This is a Eddystone-URL frame
String url = UrlBeaconUrlCompressor.uncompress(oneBeacon.getId1().toByteArray());
Log.d("BeaconsEverywhere", "I see a beacon transmitting a url: " + url +
" approximately " + oneBeacon.getDistance() + " meters away.");
}
}
}
}

As per the details you have provided I can see you are getting error of
Cannot find symbol method for following method
toByteArray()
getServiceUuid()
And class : UrlBeaconUrlCompressor
These class and methods belongs to Beacon Library, But in your code you are not able to access these Class and Methods, There could be two possible reasons :
You have not imported related package : Check if you are importing them properly, Example :(If you are using altBeacon's UrlBeaconUrlCompressor )
import org.altbeacon.beacon.utils.UrlBeaconUrlCompressor;
You have not added dependencies properly in your build environment. Example :
dependencies {
compile 'com.google.apis:google-api-services-proximitybeacon:v1beta1-rev38-1.25.0'}
or you might not have added dependencies for altbeacons
However I will recommend you to add proper log stacks and gradle dependencies with your question.

Related

Stripe google pay Android - Unexpected developer error, please try again later

I faced an issue with google pay with stripe. The problem is that I fully
followed the documentation and get an obscure error. I have this onGooglePayResult and i always have Result.Failed with error - " java.lang.RuntimeException: Google Pay failed with error 10 " And error code 2.Feel free to ask i can answer on all your questions.
Main error is java.lang.RuntimeException: Google Pay failed with error 10:. This is coming in GooglePayPaymentMethodLauncher.Result.Failed. I really can't understand why this is producing, I've checked stripe documentation twice, google pay set up and everything, but can't find out.
I mean how to find out what is real error message is, I try to find anything related to this but unfortunatelythere is simply nothing of the kind.
Logcat - error = java.lang.RuntimeException: Google Pay failed with error 10: + error code = 2
private fun onGooglePayResult(
result: GooglePayPaymentMethodLauncher.Result
) {
when (result) {
is GooglePayPaymentMethodLauncher.Result.Completed -> {
// Payment details successfully captured.
// Send the paymentMethodId to your server to finalize payment.
val paymentMethodId = result.paymentMethod.id
presenter.payPlanWithGooglePay(deviceIdentifier, paymentMethodId)
}
GooglePayPaymentMethodLauncher.Result.Canceled -> {
// User cancelled the operation
Timber.d("Cancel")
}
is GooglePayPaymentMethodLauncher.Result.Failed -> {
// Operation failed; inspect `result.error` for the exception
Timber.d("error = ${result.error} + error code = ${result.errorCode}")
}
}
}
I've resolved this issue, was my fault. I forget to add the PUBLISHABLE key from the stripe developer portal.
I use this function to set up Google pay. Just substitute TEST_PUBLISHABLE_KEY with your key in stripe account(Website).
private fun setUpGooglePay(): GooglePayPaymentMethodLauncher {
PaymentConfiguration.init(this, TEST_PUBLISHABLE_KEY)
return GooglePayPaymentMethodLauncher(
activity = this,
config = GooglePayPaymentMethodLauncher.Config(
environment = GooglePayEnvironment.Test,
merchantCountryCode = Constants.GooglePay.Manx.COUNTRY_CODE,
merchantName = UIUtils.getString(R.string.app_name)
),
readyCallback = ::onGooglePayReady,
resultCallback = ::onGooglePayResult
)
}

IntelliJ: Error: Could not find or load main class

I think I trying to solve this problem for any ways such as: CLASSPATH is wrong, Remove cache file , Restart.. etc...
BUT One interesting issues: I got fixed when I trying to add Libraries' New Java(such as spigot-1.17.1.jar) and Edit Modules Dependencies(Scope section) Normal Provided(Maven: org.spigotmc:spigot-api:1.17.1-R0.1-SNAPSHOT) -> Compile
Then this got fixed BUT I DON'T KNOW WHY THIS WORKING TO ME
EXPLAIN:
First of all, When I click(application menu) and press RUN button then I got this msg:
Error: Could not find or load main class me.kennytool.betaplugin.BetaPluginHandler.
Caused by: java.lang.NoClassDefFoundError: org/bukkit/event/Listener
package me.kennytool.betaplugin;
import org.bukkit.ChatColor;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerJoinEvent;
public class BetaPluginHandler implements Listener {
public static void main(String[] args) {
}
#EventHandler
public void onJoin(PlayerJoinEvent e){
Player player = e.getPlayer();
if (player.hasPlayedBefore()){
e.setJoinMessage(ChatColor.AQUA + "[REJOIN]" + ": " + ChatColor.BOLD + player.getDisplayName() + ChatColor.YELLOW + " WELCOME BACK");
// Have experienced logging log
}else{
e.setJoinMessage(ChatColor.YELLOW + "[FIRST]" + ": " + ChatColor.BOLD + player.getDisplayName() + ChatColor.BLUE + " WELCOME FIRST!");
// First logging on!
}
}
}
I don't know why this error shows to me.... Too many solution got it to solve this problems but this not WORK to me
NOTE: I used Java and with Minecraft Development Kit(Spigot)
(This probs doesn't occur in plain Java Project)
From your screenshots, all the dependencies are marked as scope provided, this means that they are expected to be provided externally and not available on the classpath. Please provide the contents of your pom.xml to verify, but I suspect you'll find a line on your dependencies that reads something like <scope>provided</scope> deleting this should resolve the issue. You can read more about maven dependency scopes here: https://maven.apache.org/guides/introduction/introduction-to-dependency-mechanism.html#dependency-scope

Get token string from tokenID using Stanford Parser in GATE

I am trying to use some Java RHS to get the string value of dependent tokens using Stanford dependency parser in GATE, and add them as features of a new annotation.
I am having problems targeting just the 'dependencies' feature of the token, and getting the string value from the tokenID.
Using below specifying only 'depdencies' also throws a java null pointer error:
for(Annotation lookupAnn : tokens.inDocumentOrder())
{
FeatureMap lookupFeatures = lookupAnn.getFeatures();
token = lookupFeatures.get("dependencies").toString();
}
I can use below to get all the features of a token,
gate.Utils.inDocumentOrder
but it returns all features, including the dependent tokenID's; i.e:
dependencies = [nsubj(8390), dobj(8394)]
I would like to get just the dependent token's string value from these tokenID's.
Is there any way to access dependent token string value and add them as a feature to the annotation?
Many thanks for your help
Here is a working JAPE example. It only printns to the GATE's message window (std out), It doesn't create any new annotations with features you asked for. Please finish it yourself...
Stanford_CoreNLP plugin has to be loaded in GATE to make this JAPE file loadable. Otherwise you will get class not found exception for DependencyRelation class.
Imports: {
import gate.stanford.DependencyRelation;
}
Phase: GetTokenDepsPhase
Input: Token
Options: control = all
Rule: GetTokenDepsRule
(
{Token}
): token
-->
:token {
//note that tokenAnnots contains only a single annotation so the loop could be avoided...
for (Annotation token : tokenAnnots) {
Object deps = token.getFeatures().get("dependencies");
//sometimes the dependencies feature is missing - skip it
if (deps == null) continue;
//token.getFeatures().get("string") could be used instead of gate.Utils.stringFor(doc,token)...
System.out.println("Dependencies for token " + gate.Utils.stringFor(doc, token));
//the dependencies feature has to be typed to List<DependencyRelation>
List<DependencyRelation> typedDeps = (List<DependencyRelation>) deps;
for (DependencyRelation r : typedDeps) {
//use DependencyRelation.getTargetId() to get the id of the target token
//use inputAS.get(id) to get the annotation for its id
Annotation targetToken = inputAS.get(r.getTargetId());
//use DependencyRelation.getType() to get the dependency type
System.out.println(" " +r.getType()+ ": " +gate.Utils.stringFor(doc, targetToken));
}
}
}

NoraUI - "Cannot infer Type argument" error using Result.Warning<> in a custom step

I need to raise a warning during one of my scenario but i don't stop to have this error appearing : "Cannot infer type arguments for Result.Warning<>"
I actually tried to raise the Warning the same way i was raising Failure until now :
new Result.Warning<>(targetKey, Messages.format(TaroMessages.WARNING_RESOURCES_VALUE_DIFFERENCE_AFTER_REAFFECTATION, existing_value, new_value), true, oscarAccesClientPage.getCallBack());
The custom step i am using it inside is the following : I'm trying to go over a list of Element and checking that the existing value of them is the same or not as the one saved before.
protected void checkXyResourcesValue(Integer xyIterator, List<WebElement> elements, String keyParameter) throws TechnicalException, FailureException {
try {
Integer resIterator = 1;
for(WebElement element : elements) {
String targetKey = "XY" + xyIterator + "RES" + resIterator + keyParameter;
String new_value = element.getAttribute(VALUE) != null ? element.getAttribute(VALUE) : element.getText();
String existing_value = Context.getValue(targetKey) != null ? Context.getValue(targetKey) : targetKey;
if (new_value != existing_value) {
new Result.Warning<>(targetKey, Messages.format(TaroMessages.WARNING_RESOURCES_VALUE_DIFFERENCE_AFTER_REAFFECTATION, existing_value, new_value), true, oscarAccesClientPage.getCallBack());
}
resIterator++;
}
} catch (Exception e) {
new Result.Failure<>(e.getMessage(), Messages.format(TaroMessages.FAIL_MESSAGE_ACCES_CLIENT_XY_CHECK_RESOURCES_VALUE, keyParameter, xyIterator), true, oscarAccesClientPage.getCallBack());
}
}
For the method to check and saved value I actually inspired myself for the piece of code from NoraUI to save a value on Context or read it from.
I'm using Eclipse Luna 4.4.2 and i try to compile using JDK1.8.0_131.
It may be more related to me not knowing how this work in Java than a real problem so thank you in advance for your help or insights. Don't hesitate to ask if you need more information on the piece of code or the context.
new Result.Warning<>(targetKey, Messages.format(TaroMessages.WARNING_RESOURCES_VALUE_DIFFERENCE_AFTER_REAFFECTATION, existing_value, new_value), true, 0);
use 0 if you do not use any Model (data serialized) or use id of your Object in the serial.

JInput "no jinput-dx8 in java.library.path" Error

Hi I'm trying to make a game in java that gives users the option to a joystick or gamepad to control movement. So I found something called "JInput" that is suppose to make it easy to detect all connected game controllers. The problem is that when I run it in Eclipse I get the following error: "java.lang.UnsatisfiedLinkError: no jinput-dx8 in java.library.path".
My code is the following:
import net.java.games.input.*;
public class ListControllers
{
public static void main(String[] args)
{
System.out.println("JInput version: " + Version.getVersion());
ControllerEnvironment ce =
ControllerEnvironment.getDefaultEnvironment();
Controller[] cs = ce.getControllers();
if (cs.length == 0) {
System.out.println("No controllers found");
System.exit(0);
}
// print the name and type for each controller
for (int i = 0; i < cs.length; i++)
System.out.println(i + ". " +
cs[i].getName() + ", " + cs[i].getType() );
} // end of main()
} // end of ListControllers class
I'm currently developing in Windows 7 environment. Any help would be really appreciated.
You should set java.library.path property to point to the directory containing native dlls of JInput.
You can do it by adding -Djava.library.path=x (where x is your path) to the command line or to the "VM arguments" field of "Run configurations" dialog in Eclipse.

Categories

Resources