hey guys am trying to execute the below method but am getting an error which says:
Unable to match class for part: 'Lrx/Observable;
my method:
public void SendNote(){
titleStr = etxtTitle.getText().toString();
// saving objects
NotesRealmClass notesRealmClass = new NotesRealmClass();
notesRealmClass.setTitle("try");
// save object asynchronously
Backendless.Persistence.save(notesRealmClass, new AsyncCallback<NotesRealmClass>() {
public void handleResponse(NotesRealmClass note) {
// new Contact instance has been saved
Toast.makeText(getActivity(), "Successfully posted ", Toast.LENGTH_SHORT).show();
}
public void handleFault(BackendlessFault fault) {
Toast.makeText(getActivity(), "" + fault.getMessage(), Toast.LENGTH_SHORT).show();
// an error has occurred, the error code can be retrieved with fault.getCode()
}
}); }
here am trying to save an Object into Backendless Server but am getting this error, any one can explain me what this error is trying to tell ?? i searched around but didnt get anything yet
well it turns out that its a fault in realm , according to this https://www.bountysource.com/issues/29233605-java-lang-noclassdeffounderror-rx-observable-in-0-87-0 , for fixing it we just have to put compile 'io.reactivex:rxjava:1.0.16' in our grade file
Related
EDIT: I just restarted Android Studio after cleaning the project and invalidating cache. Now I get this error -
E/StorageException: { "error": { "code": 403, "message":
"Permission denied. Could not perform this operation" }}
I'm getting the following error that prints infinitely.
2020-09-27 17:00:32.931 11755-11863/com.example.XXXXXX E/StorageUtil: error getting token java.util.concurrent.ExecutionException: com.google.firebase.internal.api.FirebaseNoSignedInUserException: Please sign in before trying to get a token.
In my app I've created the user properly, and FirebaseAuth.getInstance().getCurrentUser(); does NOT return null. But if it does, I handle it by logging them in successfully or creating another user. My app now has 160+ users created, in less than half a day. I don't think I've even run the app that many times for testing. 'Sign in with email', and 'anonymous sign in' options are enabled in auth settings.
The problem starts when I try to access the storage. I get the above mentioned auth token error. The folder and file exist and this is how I'm trying to download the files -
fstore.child("gs://XXXXXX-XXXX.appspot.com/Books/XXXX").listAll().addOnSuccessListener(new OnSuccessListener<ListResult>() {
#Override
public void onSuccess(ListResult listResult) {
for(StorageReference sref : listResult.getItems())
{
tempFilename = sref.getName();
File tmpFile = new File(tempSubDir, tempFilename);
try {
tmpFile.createNewFile();
sref.getFile(tmpFile).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(tabtwoactivity.this, "File download failed!", Toast.LENGTH_LONG).show();
System.out.println("ERROR: "+ e.toString());
}
});
} catch (IOException e) {
e.printStackTrace();
}
//System.out.println("IIIIII: "+sref.getName());
}
}
}).addOnFailureListener(new OnFailureListener() {
#Override
public void onFailure(#NonNull Exception e) {
Toast.makeText(tabtwoactivity.this, "Fetching Directory XXXXX Failed", Toast.LENGTH_LONG).show();
}
});
I've tried using fstore.child("XXXX").listAll() but that gave me an avalanche of different errors, mainly focused around Folder not found. My storage has the folder and files. I've even played around with the storage rules - allow read, write;, allow read, write: if request.auth!=null, allow read, write: if request.auth==null. But nothing worked.
What am I doing wrong?
Paste this in your google.json:
service firebase.storage {
// The {bucket} wildcard indicates we match files in all storage buckets
match /b/{bucket}/o {
// Match filename
match /filename {
allow read: if true;
allow write: if true;
}
}
}
i am trying to send some user data (its registration android page) to my server host but there is an error while trying to get json object from server side, so how can i fix this problem?
update :: i am using byethost services and i understand that there is something with cookies. so how can i solve this problem using volley library?
i have a method called onResponse() in my RegisterActivity class and its where the problem begins. in this method i wrote this line which always throws exception about not converting string to json object which i think there is nothing to do with my java codes, the reason it cant convert string to json i guess is that its not a valid json object. but i dont know why it is not valid.
here is my register.php file
https://www.androidtutorialpoint.com/wp-content/uploads/2016/09/register.txt
https://www.androidtutorialpoint.com/wp-content/uploads/2016/09/update_user_info.txt
https://www.androidtutorialpoint.com/wp-content/uploads/2016/09/android_login_connect.txt
https://www.androidtutorialpoint.com/wp-content/uploads/2016/09/android_login_config.txt
by the way i i just followed a tutorial i do not know so much about php.
here is the method in my RegisterActivity class where the exception triggers.
#Override
public void onResponse(String response) {
Toast.makeText(RegisterActivity.this, response,
Toast.LENGTH_LONG).show();
Log.d(TAG, "Register Response: " + response.toString());
hideDialog();
try {
JSONObject jObj = new JSONObject(response);
boolean error = jObj.getBoolean("error");
if (!error) {
String user =
jObj.getJSONObject("user").getString("name");
Toast.makeText(getApplicationContext(), "Hi " + user +
", You are successfully Added!",
Toast.LENGTH_SHORT).show();
// Launch login activity
Intent intent = new Intent(
RegisterActivity.this,
LoginActivity.class);
startActivity(intent);
finish();
} else {
String errorMsg = jObj.getString("error_msg");
Toast.makeText(getApplicationContext(),
errorMsg, Toast.LENGTH_LONG).show();
}
} catch (JSONException e) {
e.printStackTrace();
}
}
i expect to have a valid json object to pass the user data to my server but what i already have is some invalid json which throws exceptions.
well if anyone have followed the tutorials for register and login page and it does not work here are some reasons.
1) there is a problem with your php file which mostly its this one.
2) if there are problem with converting string to json object, print the string and see if its a valid json.
3)if everything is fine with these stuff, probably you should check the database and see if everything can fit with the php and user data and etc.
my problem was neither of those, as it turns out my server host have something to do with cookies (byethost) and you should add some headers for solving the problem here is a good link
How to set custom header in Volley Request
but i just solved my problem by using another server host (000host) and it works just fine. by the way if you are trying to use wamp and it doesn't work too, just use free 000host. it's been three days i was stuck on this thing. good luck
I'm attempting to convert the code located at How to use signalr in android Service from java to c# and have been making some progress. I'm now stuck at the final method. The java code is:
private void startSignalR() {
Platform.loadPlatformComponent(new AndroidPlatformComponent());
mInstance.setmHubConnection();
mInstance.setHubProxy();
ClientTransport clientTransport = new ServerSentEventsTransport(mInstance.mHubConnection.getLogger());
SignalRFuture<Void> signalRFuture = mInstance.mHubConnection.start(clientTransport);
try {
signalRFuture.get();
} catch (InterruptedException | ExecutionException e) {
Log.e("SimpleSignalR", e.toString());
return;
}
mInstance.sendMessage(MainActivity.unm,"Hello All!");
String CLIENT_METHOD_BROADAST_MESSAGE = "recievedMessage";
mInstance.mHubProxy.on(CLIENT_METHOD_BROADAST_MESSAGE,
new SubscriptionHandler2<String,LoginInfo>() {
#Override
public void run(final String msg,final LoginInfo loginInfo) {
final String finalMsg = loginInfo.FullName + " says " + loginInfo.Password;
Intent intent = new Intent();
intent.setAction(MY_ACTION);
intent.putExtra("DATAPASSED", finalMsg);
sendBroadcast(intent);
}
}
, String.class,LoginInfo.class);
}
Using a java to c# converter, this translated to:
private void startSignalR()
{
Platform.loadPlatformComponent(new AndroidPlatformComponent());
mInstance.setmHubConnection();
mInstance.setHubProxy();
ClientTransport clientTransport = new ServerSentEventsTransport(mInstance.mHubConnection.Logger);
SignalRFuture<Void> signalRFuture = mInstance.mHubConnection.Start(clientTransport);
try
{
signalRFuture.get();
}
catch (Exception e) when (e is InterruptedException || e is ExecutionException)
{
// Log.e("SimpleSignalR", e.ToString());
return;
}
mInstance.sendMessage("", "Hello All!");
string CLIENT_METHOD_BROADAST_MESSAGE = "recievedMessage";
//String CLIENT_METHOD_BROADAST_MESSAGE = "messageReceived";
mInstance.mHubProxy.on(CLIENT_METHOD_BROADAST_MESSAGE, new SubscriptionHandler2AnonymousInnerClass(this)
, typeof(string), typeof(LoginInfo));
}
private class SubscriptionHandler2AnonymousInnerClass : SubscriptionHandler2<string, LoginInfo>
{
private readonly SignalRSrv outerInstance;
public SubscriptionHandler2AnonymousInnerClass(SignalRSrv outerInstance)
{
this.outerInstance = outerInstance;
}
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: #Override public void run(final String msg,final LoginInfo loginInfo)
public override void run(string msg, LoginInfo loginInfo)
{
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final String finalMsg = loginInfo.FullName + " says " + loginInfo.Password;
string finalMsg = loginInfo.FullName + " says " + loginInfo.Password;
Intent intent = new Intent();
intent.Action = MY_ACTION;
intent.PutExtra("DATAPASSED", finalMsg);
sendBroadcast(intent);
}
}
This, of course, generated several errors in Visual Studio 2017.
First, the line Platform.loadPlatformComponent(new AndroidPlatformComponent()); generated the error Platform is inaccessible due to its protection level. Platform in Xamarin for Visual Studio 2017 is indeed protected and is a internal class in System and I cannot change this, so I'm at a loss as how to proceed with it. The same line generates the error The type or namespace name 'AndroidPlatformComponent' could not be found, these errors a numerous and not unexpected I just can't find an equivalent to AndroidPlatformComponent in Visual Studio 2017 so I'm at a loss as how to solve this one.
Next, on this line ClientTransport clientTransport = new ServerSentEventsTransport(mInstance.mHubConnection.Logger); generates the error The type or namespace name 'ClientTransport' could not be found, I was also unable to find an equivalent to this and again I'm at a loss as to proceed. Also on this line, .Logger is not defined for the hub connection, apparently it's .getLogger() in java, I was unable to find an equivalent for this one as well.
Next the line SignalRFuture<Void> signalRFuture = mInstance.mHubConnection.Start(clientTransport);' generates the error 1The type or namespace name 'SignalRFuture<>' could not be found, this seemes to be specific to SignalR, again, I am unable to find an equivalent.
The next one has me totally stumped, the line private class SubscriptionHandler2AnonymousInnerClass : SubscriptionHandler2<string, LoginInfo> generates the error The type or namespace name 'SubscriptionHandler2<,>' could not be found. I've looked everywhere online and read up on AnonymousInnerClass, but it was not help with this.
I'm hoping that the users here are more familiar with SignalR and the differences between c# functionality and java functionality. I'm not at all familiar with java nor am I familiar with SignalR and foreground services.
As it turns out, the last method in the java code I was converting was wiring up an event to pass the message received from the hub to the activity. In c# / Visual Studio (2017), that's done very differently which is why I didn't understand/recognize what was going on. So I created a handler in C# and execute a popup message for the message. This in itself may pose problems, but at least I know what's going on. This is the code I wrote to start SignalR from within the service and WireUp the handler:
private void startSignalR()
{
// Company, Department, and section are private variables
// their values are pulled from the intent bundle
// in the OnBind method, that code is:
// Bundle bundlee = intent.GetBundleExtra("TheBundle");
// MyUser = bundlee.GetParcelable("MyUser") as User;
// This information is put into the bundle when the user is logged in.
// I then pass that information to the SignalR client
// when I set the hub connection and placed on the querystring to the hub.
mInstance.setmHubConnection(username, firstname,lastname,company,department,section);
mInstance.setHubProxy();
try
{
// Connect the client to the hup
mInstance.mHubConnection.Start();
// Set the event handler
mInstance.WireUp();
}
catch (System.Exception e) when (e is InterruptedException || e is ExecutionException)
{
ShowMessage("Error: + e.Message)
}
}
This is the WireUp code, this is a method in the client code:
public void WireUp()
{
// set the event handler
mHubProxy.On("broadcastMessage", (string platform, string message) =>
{
if (OnMessageReceived != null)
OnMessageReceived(this, string.Format("{0}: {1}", platform, message));
});
}
As I had anticipated, the popup message won't appear when the app is in the background, so I'm researching a workaround
I am having issues with the CodeScanner not returning values in my application.
This project I have had unchanged for a year and it was working, but there were some new changes that had to be done and when I was making them I noticed I was using a now deprecated scanner and I was to use the new library. I implemented it into the application and it loads correctly, but after I scan the QR code it never goes into the Completed method.
import com.codename1.ext.codescan.CodeScanner;
import com.codename1.ext.codescan.ScanResult;
...
if (CodeScanner.isSupported()) {
CodeScanner.getInstance().scanQRCode(new ScanResult() {
public void scanCompleted(String contents, String formatName, byte[] rawBytes) {
Dialog.show("Scanning Completed", "Scanning Completed", "OK", null);
}
public void scanCanceled() {
Dialog.show("Scanning Cancelled", "Scanning was cancelled", "OK", null);
}
public void scanError(int errorCode, String message) {
NoScanner(2);
}
});
} else {
NoScanner(2);
}
I am hoping I can get some help as to why it suddenly doesn't want to return the scanned value or even enter the various methods.
This was tested on Android, there is also an iOS build but I don't have a device handy for testing
There was a regression in intent handling that we fixed over the weekend. Please try this again and see if the issue resolved itself.
I am using the following code for adding a new ParseUser:
ParseUser user = new ParseUser();
user.setUsername("Rob");
user.setEmail("rob1989#gmail.com");
user.setPassword("robPass");
user.put("phone", "898989898");
user.saveInBackground();
After running this code nothing is reflected in my parse dashboard. I am not even getting any exception in the Android Studio.
However, when I run the following code, everything works just fine:
ParseObject item = new ParseObject("Item");
item.put("quantity", "dwad");
item.put("description", "dawda");
item.put("name", "fwafa");
item.saveInBackground();
Does anyone know what I am doing wrong here in ParseUser? Is there anyway to check the dashboard from Parse?
As clearly stated in the official guide, for ParseUsers you should use ParseUser.signUpInBackground():
user.signUpInBackground(new SignUpCallback() {
public void done(ParseException e) {
if (e == null) {
// Hooray! Let them use the app now.
} else {
// Sign up didn't succeed. Look at the ParseException
// to figure out what went wrong
}
}
});
Once the user has signed up for the first time, you can use save() and saveInBackground() for any subsequent change in the user attributes. But first you have got to sign him up.