I am new to protocol buffer from google so I tried the Java tutorial and everything goes well until I am trying to make an instance of the protocol class. So I tried to make my own proto file but I had the same problem. The problem lies in this piece of code:
AddressBook.Builder address = new AddressBook.newBuilder();
On the newBuilder() part I am getting a cannot find symbol error. In the comments in the file generated by protoc it says to use the newBuilder() to make an instance of the class and I can't find the problem. Does anyone know the problem and is there a solution?
This is the problem:
new AddressBook.newBuilder();
That syntax is half way between a method call and a constructor call. newBuilder() is just a static method. You just need:
AddressBook.Builder builder = AddressBook.newBuilder();
Related
I am trying to use the library Porcupine on Android. I have now downloaded a Rhino context file (.rhn) but can't find a way how to implement that file into my code.
The documentation says that I should use setContextPath() but this gives me the error:
Cannot resolve method 'setContextPath' in 'Builder'
That's how I tried it:
try {
porcupineManager = new PorcupineManager.Builder()
.setModelPath("porcupine_params_de.pv")
.setAccessKey(ACCESS_KEY)
.setKeywordPath("my_file_de_android_v2_0_0.ppn")
.setContextPath("my_file_de_android_v2_0_0.rhn");
.setSensitivity(0.7f).build(
getApplicationContext(),
porcupineManagerCallback);
porcupineManager.start();
}
...
I don't know what this method is good for since I can't even find it in its class.
So how can I use my .rhn file?
In the sample code from the link you provide, this method is called on different class:
PicovoiceManager picovoiceManager = new PicovoiceManager.Builder()
.setAccessKey("${ACCESS_KEY}")
.setKeywordPath("${KEYWORD_FILE_PATH}")
.setWakeWordCallback(wakeWordCallback)
.setContextPath("${CONTEXT_FILE_PATH}")
.setInferenceCallback(inferenceCallback)
.build(context);
you use PorcupineManager while sample code uses PicovoiceManager.
I have been trying to utilize the Android SDK from Maffen:
https://github.com/mrmaffen/vlc-android-sdk/ in order to stream RTSP.
So I found the following stack overflow thread:
vlc-android-sdk - cannot view RTSP live video
Which has a number of answers of how to do this.
However, the problem I am having is that when I try to set the options for LibVLC it will not allow me to do so.
For example:
ArrayList<String> options = new ArrayList<String>();
options.add("--no-drop-late-frames");
options.add("--no-skip-frames");
options.add("--rtsp-tcp");
options.add("-vvv");
videoVlc = new LibVLC(options)
When I try to run this I get the following error message in Android Studio:
"error: incompatible types: ArrayList cannot be converted to Context"
Also if I hover over the "LibVLC(options)" section of the code it comes up with the following message:
"LibVLC (android.content.Context) in LibVLC cannot be applied to (java.util.ArrayList)
I'm no Java expert, so perhaps this is an easy fix but I have been trying different sample codes from around the internet all day and every single one sets those options and I can't do it.
Any help would be much appreciated. Thank you!
EDIT:
This problem was solved using the following:
videoVlc = new LibVLC(this, options);
I had simply forgot about including the context part of the LibVLC.
I forgot to go back and edit this once I had arrived at a solution.
maffen vlc android sdk. the constructor LibVLC takes two params. context and options. option can be null. and options should be the second one. the older version may only takes one param option
I have been trying to use the TwilioRestClient.Builder class in order to send out an sms using my Twilio number.
I have been using this piece of code within a MessageCreator class:
messageCreator = new TwilioMessageCreator(
newTwilioRestClient.Builder(credentials.getAccountSid(),credentials.getAuthToken())
.build()
);
However, when I use this piece of code in another class, I receive this exception:
java.lang.NoClassDefFoundError: org/apache/http/ProtocolVersion com.twilio.http.TwilioRestClient$Builder.<init>(TwilioRestClient.java:66)
This seems to indicate some problem with the TwilioRestClient.Builder() method, but I am unable to identify the issue.
I hope I can get an answer to this!
It is possible you are using version 6.x at the moment, the example of TwilioRestClient.Builder you are looking at is for version 7.x of the java library.
You can check here how you send messages with version 6.x: https://www.twilio.com/docs/api/rest/sending-messages
Please let me know if this helps.
I have recently acquired a beacon from Kontakt.io
I followed the "Monitoring code example" from here: http://docs.kontakt.io/android-sdk/quickstart/#monitoring-code-sample
The Kontakt library is included (since other methods from the library is working), but the following line is giving me an error:
beaconManager.startMonitoring(Region.EVERYWHERE);
Error:
startMonitoring (java.util.Set<com.kontakt.sdk.android.device.Region>) in BeaconManager
cannot be applied to (com.kontakt.sdk.android.device.Region)
I have also tried creating a new region with the proximity uuid from the beacon:
static UUID uid = UUID.fromString("1DEFF9522D014664BB6088F065302B83");
private static final Region beacon = new Region(uid, 49668, 35726, null);
but this throws the same error.
I'm quite new to java and this might be a fairly simple question, but how do i resolve this?
If you check the changelog on their website you will see that there is new version of API. Clearly example is not updated. If you want to monitor Region.EVERYWHERE you can simply call beaconManager.startMonitoring() according to docs it should work.
I can't find what is the problem with my project. I'm trying to create a header for a word document I'm making but when I try these lines of code:
XWPFHeader header = document.getHeaderFooterPolicy().getFirstPageHeader();
XWPFRun headRun = header.getParagraphArray(1).createRun();
headRun.setText("SOME TEXT");
I get the following errors:
Error(55,20): XmlString not found in interface org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr in class org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy in class ****.***.*****.MyDocument
Error(55,20): StringEnumAbstractBase not found in class org.openxmlformats.schemas.wordprocessingml.x2006.main.STHdrFtr.Enum in class org.apache.poi.xwpf.model.XWPFHeaderFooterPolicy in class ****.***.*****.MyDocument
I have tried to search for the error message but I find nothing, can someone please give me some help? I would appreciate specially if someone can tell me an effective way to address these problems, googling the error message has always worked for me, but not this time. I don't know how to find a jar (as it seems to be what is missing) by what classes are in it.
Thanks.
PS. This is the first time I try to create a document, so the code may just be completely wrong.
Take a look at Apache POI components and this FAQ. You are definitely missing something.