Open cs8898 opened 5 years ago
Hi @cs8898 , as you can see in your Log, you can not use the remote operations with no account, so using OwnCloudClientFactory.createOwnCloudClient
is not enough. I would recommend you to use something like:
Account account = new Account("name", "type")
OwnCloudAccount ocAccount = new OwnCloudAccount(account, context);
OwnCloudClientManagerFactory.getDefaultSingleton().getClientFor(ocAccount, context);
By using this, you will obtain an OwnCloudClient with a proper account and it should work.
Thanks I will try that some day, currently i moved to Sardine-Android... They also support direct InputStreams what is pretty great in my case.
@davigonz I have the same problem, and I don't understand your solution. I already have a working owncloud account. So I just updated the values for: server_base_url, username, password - with the exact values I use in the browser. So the sample should work with that, right? I also tried with https://demo.owncloud.com/, demo, demo. Also not working.
In the sample app, the client is set with:
OwnCloudClient createOwnCloudClient(Uri uri, Context context, boolean followRedirects)
How can this work? getSavedAccount()
can only be null, cause it was never set, right? See the constructor:
public OwnCloudAccount(Uri baseUri, OwnCloudCredentials credentials) {
if (baseUri == null) {
throw new IllegalArgumentException("Parameter 'baseUri' cannot be null");
}
mSavedAccount = null;
mSavedAccountName = null;
mBaseUri = baseUri;
mCredentials = credentials != null ?
credentials : OwnCloudCredentialsFactory.getAnonymousCredentials();
String username = mCredentials.getUsername();
if (username != null) {
mSavedAccountName = AccountUtils.buildAccountName(mBaseUri, username);
}
}
mSavedAccountName is set, but mSavedAccount never.
And in your solution, where would the client get my credentials from?
Hello ! I have the same problem with the getSavedAccount(). Any solutions ?
How can this work? getSavedAccount() can only be null, cause it was never set, right? See the constructor:
@DanielKedl the error reported in the first comment is not about getting a null account when calling getSavedAccount() but trying to call getSavedAccount() from a null account, is not the same. Have a look at the logs:
java.lang.NullPointerException: Attempt to invoke virtual method 'android.accounts.Account com.owncloud.android.lib.common.OwnCloudAccount.getSavedAccount()' on a null object reference
at com.owncloud.android.lib.common.OwnCloudClient.getUserFilesWebDavUri(OwnCloudClient.java:263)
And this occurs when you try to perform a network operation with a client without an account, as I explained in https://github.com/owncloud/android/issues/4049
And in your solution, where would the client get my credentials from?
It would get your credentials from the account you use
But for that you might need to use a different constructor and create the credentials yourself.
Hi, same issue here.
This is how I setup ownCloudClient
val ownCloudClient = OwnCloudClientFactory.createOwnCloudClient(Uri.parse(baseUrl), appContext, true)
ownCloudClient.credentials = OwnCloudCredentialsFactory.newBasicCredentials(username, password)
Above code works with this version: oc-android-library-0.9.15
but it doesn't work with 1.0.3
:
2019-11-28 17:45:24.074 23808-23930/ch.arcade.cloudcam.new E/ReadRemoteFolderOperation: Synchronized /: Unexpected exception
java.lang.NullPointerException: Attempt to invoke virtual method 'android.accounts.Account com.owncloud.android.lib.common.OwnCloudAccount.getSavedAccount()' on a null object reference
at com.owncloud.android.lib.common.OwnCloudClient.getUserFilesWebDavUri(OwnCloudClient.java:254)
at com.owncloud.android.lib.resources.files.ReadRemoteFolderOperation.run(ReadRemoteFolderOperation.java:78)
at com.owncloud.android.lib.common.operations.RemoteOperation.runOperation(RemoteOperation.java:251)
at com.owncloud.android.lib.common.operations.RemoteOperation.run(RemoteOperation.java:270)
I thought i just have used the Sample code, but it seems that there are some issues...
Because i'm trying to get some ics files from the server i needed some webdav client but
sardine-android
isn't working... "Only WebDAV Client allowed" ;/So i tried that lib included as
com.github.owncloud:android-library:oc-android-library-0.9.24
The used Code:
Heyo here is my Log: