Giter VIP home page Giter VIP logo

android-library's Introduction

Nextcloud Android Library v2 Build Status REUSE status Codacy Badge

Introduction

Using Nextcloud Android library it will be the easiest way to communicate with Nextcloud servers. Add this library in your project and integrate your application with Nextcloud seamlessly.

Android Library v2

Starting from 01.10.2019 we will not actively develop our old library (v1), but maintain it until 01.10.2021 with bug fixes. v2 is using OkHTTP and DAV4jvm by BitfireAT. Needed changes for projects using this library are:

  • change build.gradle
    • add to android {…}: compileOptions {
          sourceCompatibility JavaVersion.VERSION_1_8
          targetCompatibility JavaVersion.VERSION_1_8
    
    }
    • add to dependencies {…}:
       implementation "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
    

Use Library

In the repository it is not only the library project but also the example project "sample_client"; thanks to it you will learn how to use the library.

There are different ways of adding this library to your code

Gradle / Maven dependency

At the moment we do not have a publishing mechanism to a maven repository so the easiest way to add the library to your app is via a JitPack Dependency

build via Groovy configuration

repositories {
    ...
    maven { url "https://jitpack.io" }
}
dependencies {
    ...
    implementation("com.github.nextcloud:android-library:$androidLibraryVersion") {
        exclude group: 'org.ogce', module: 'xpp3' // unused in Android and brings wrong Junit version
    }

build via Kotlin configuration

in settings.gradle.kts

dependencyResolutionManagement {
    ...
    repositories {
    ...
        maven(url = "https://jitpack.io")
    }
}

in build.gradle.kts

dependencies {
    ...
    implementation("com.github.nextcloud:android-library:$androidLibraryVersion") {
        exclude(group = "org.ogce", module = "xpp3") // unused in Android and brings wrong Junit version
    }

As a git submodule

Basically get this code and compile it having it integrated via a git submodule:

  1. go into your own apps directory on the command line and add this lib as a submodule: git submodule add https://github.com/nextcloud/android-library nextcloud-android-library
  2. Import/Open your app in Android Studio

Branching strategy

The repository holds one main branch with an infinite lifetime:

  • master

Branch origin/master is considered the main branch where the source code of HEAD always reflects a state with the latest delivered development changes for the next release.

Other branches, some supporting branches are used to aid parallel development between team members, ease tracking of features and to assist in quickly fixing live production problems. Unlike the main branch, these branches always have a limited life time, since they will be removed eventually (feature branching).

Development process

We are all about quality while not sacrificing speed so we use a very pragmatic workflow.

  • create an issue with feature request
    • discuss it with other developers
    • create mockup if necessary
    • must be approved --> label approved
    • after that no conceptual changes!
  • develop code
  • create pull request
  • to assure the quality of the app, any PR gets reviewed, approved and tested by two developers before it will be merged to master

License

Nextcloud Android Library is available under MIT license. See LICENSE.md with the full license text.

Third party libraries

Nextcloud Android Library uses Apache JackRabbit, version 2.12.4. 
Copyright (C) 2004-2010 The Apache Software Foundation. 
Licensed under Apache License, Version 2.0.
Apache JackRabbit depends on Commons HTTPClient version 3.1 and SLF4j version 1.7.5; both included also. 
Copyright (C) 2004-2010 The Apache Software Foundation. 
Licensed under Apache License, Version 2.0.

Compatibility

Nextcloud Android library is valid for Android version 3.0 and up (with android:minSdkVersion="11" and android:targetSdkVersion="24").

Nextcloud Android library supports Nextcloud server from version 9+.

When using newer libraries in your application that integrates with the Nextcloud Android library you could hit a conflict issue with the logging libraries used by our (outdated) HTTPClient. In order to mitigate the issues, please add the following in your build.gradle for the time being:

configurations.all {
    exclude group: "org.slf4j", module: "slf4j-log4j12"
    exclude group: "log4j", module: "log4j"
}

android-library's People

Contributors

aleister09 avatar alperozturk96 avatar alvarobrey avatar andyscherzinger avatar davigonz avatar davivel avatar dependabot-preview[bot] avatar dependabot-support avatar dependabot[bot] avatar elv1zz avatar ezaquarii avatar flole998 avatar github-actions[bot] avatar grote avatar jabarros avatar lukasreschke avatar malkomich avatar mario avatar minfaer avatar mmmarcy avatar nextcloud-bot avatar nickvergessen avatar przybylski avatar renovate[bot] avatar skjnldsv avatar stoyicker avatar szaimen avatar tobiaskaminsky avatar unpublished avatar zetatom avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

android-library's Issues

Cannot compile anymore with gradle 3.6.2

The recent update to gradle 3.6.2 added a new lint check that now blocks using the nextcloud android library because of the commons-httpclient library conflict (see #411).
Error output is:

Error: httpclient defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar. [DuplicatePlatformClasses]
    implementation "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
                            ~~~~~~~~~~

   Explanation for issues of type "DuplicatePlatformClasses":
   There are a number of libraries that duplicate not just functionality of
   the Android platform but using the exact same class names as the ones
   provided in Android -- for example the apache http classes. This can lead
   to unexpected crashes.

   To solve this, you need to either find a newer version of the library which
   no longer has this problem, or to repackage the library (and all of its
   dependencies) using something like the jarjar tool, or finally, rewriting
   the code to use different APIs (for example, for http code, consider using
   HttpUrlConnection or a library like okhttp).

2 errors, 0 warnings

Only workarounds so far is to stay with the old gradle 3.6.1 or switch off the lint errors. Both are no long-term solutions for production code.

com.nextcloud.android.beta craches in IPV6PreferringDNS.lookup in constant restart loop (as long as wifi connected)

I have been running the beta android client the last couple of years basically with only one serious problem before, this it number two.

03-12 16:56:41.174 16254 16375 E AndroidRuntime: FATAL EXCEPTION: Thread-5
03-12 16:56:41.174 16254 16375 E AndroidRuntime: Process: com.nextcloud.android.beta, PID: 16254
03-12 16:56:41.174 16254 16375 E AndroidRuntime: java.lang.UnsupportedOperationException
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at java.util.AbstractList.set(AbstractList.java:132)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at java.util.AbstractList$ListItr.set(AbstractList.java:426)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at java.util.Collections.sort(Collections.java:247)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at com.nextcloud.common.IPV6PreferringDNS.lookup(IPV6PreferringDNS.java:30)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at okhttp3.internal.connection.RouteSelector.resetNextInetSocketAddress(RouteSelector.kt:164)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at okhttp3.internal.connection.RouteSelector.nextProxy(RouteSelector.kt:129)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at okhttp3.internal.connection.RouteSelector.next(RouteSelector.kt:71)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at okhttp3.internal.connection.ExchangeFinder.findConnection(ExchangeFinder.kt:205)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at okhttp3.internal.connection.ExchangeFinder.findHealthyConnection(ExchangeFinder.kt:106)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at okhttp3.internal.connection.ExchangeFinder.find(ExchangeFinder.kt:74)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at okhttp3.internal.connection.RealCall.initExchange$okhttp(RealCall.kt:255)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at okhttp3.internal.connection.ConnectInterceptor.intercept(ConnectInterceptor.kt:32)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at okhttp3.internal.cache.CacheInterceptor.intercept(CacheInterceptor.kt:95)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at okhttp3.internal.http.BridgeInterceptor.intercept(BridgeInterceptor.kt:83)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept(RetryAndFollowUpInterceptor.kt:76)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at okhttp3.internal.http.RealInterceptorChain.proceed(RealInterceptorChain.kt:109)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at okhttp3.internal.connection.RealCall.getResponseWithInterceptorChain$okhttp(RealCall.kt:201)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at okhttp3.internal.connection.RealCall.execute(RealCall.kt:154)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at com.nextcloud.common.OkHttpMethodBase.execute(OkHttpMethodBase.kt:171)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at com.nextcloud.client.network.ConnectivityServiceImpl.isInternetWalled(ConnectivityServiceImpl.java:75)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at com.owncloud.android.utils.FilesSyncHelper.lambda$restartJobsIfNeeded$0(FilesSyncHelper.java:207)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at com.owncloud.android.utils.-$$Lambda$FilesSyncHelper$78U1WN_nzr5HiGIrRZMThSEamz8.run(lambda)
03-12 16:56:41.174 16254 16375 E AndroidRuntime:        at java.lang.Thread.run(Thread.java:761)
03-12 16:56:41.241   562 16383 I chatty  : uid=1000 system_server expire 1 line
03-12 16:56:41.268   562  6111 I ActivityManager: Process com.nextcloud.android.beta (pid 16254) has died
03-12 16:56:41.269   562  6111 D ActivityManager: cleanUpApplicationRecord -- 16254
03-12 16:56:41.269   562  6111 W ActivityManager: Scheduling restart of crashed service com.nextcloud.android.beta/androidx.work.impl.background.systemjob.SystemJobService in 1000ms
03-12 16:56:41.269   562  6111 W ActivityManager: Scheduling restart of crashed service com.nextcloud.android.beta/com.owncloud.android.services.AccountManagerService in 11000ms
03-12 16:56:41.269   562  6111 I ActivityManager: Killing 16260:com.nextcloud.android.beta:crash/u0a184 (adj 0): depends on provider com.nextcloud.android.beta/com.owncloud.android.providers.FileContentProvider in dying proc com.nextcloud.android.beta (adj 0)
03-12 16:56:41.315   562  2187 I WindowManager: WIN DEATH: Window{bf2c98c u0 com.nextcloud.android.beta/com.nextcloud.client.errorhandling.ShowErrorActivity}
03-12 16:56:41.325   562  8038 I ActivityManager: Start proc 16384:com.nextcloud.android.beta/u0a184 for service com.nextcloud.android.beta/com.owncloud.android.services.AccountManagerService
03-12 16:56:41.326   562  8294 D ActivityManager: cleanUpApplicationRecord -- 16260
03-12 16:56:41.327   562  8294 W ActivityManager: Force removing ActivityRecord{ef0a427 u0 com.nextcloud.android.beta/com.nextcloud.client.errorhandling.ShowErrorActivity t3751}: app died, no saved state
03-12 16:56:41.386   562   583 W WindowManager: Failed looking up window

Looking at the code, the function is quite simple

        public List<InetAddress> lookup(String hostname) throws UnknownHostException {
            List<InetAddress> addresses = cache.get(hostname.toLowerCase(Locale.ROOT));

            if (addresses != null) {
                return addresses;
            }

            addresses = Dns.SYSTEM.lookup(hostname);
            Collections.sort(addresses, (address1, address2) -> {
                if(address1 instanceof Inet4Address) {
                    return 1;
                } else {
                    return -1;
                }
            });
            cache.put(hostname, addresses);

            return addresses;
        }

I am not sure what types Dns.SYSTEM.lookup returns, but looking into why sort can fail, it seems to be cause by missing set support on the elements.

https://stackoverflow.com/questions/53065894/collections-sort-throws-unsupportedoperationexception-while-sorting-a-list-after
https://stackoverflow.com/questions/21854353/why-does-collections-sort-throw-unsupported-operation-exception-while-sorting-by
https://stackoverflow.com/questions/55802573/abstractlist-unsupportedoperationexception-when-calling-sort-on-a-list

Probably you need to wrap the result in an ArrayList before attempting to sort?

Update THIRD_PARTY.txt

There are a number of things that are not up-to-date in THIRD_PARTY.txt.

  • Apache JackRabbit is outdated
  • Jakarta Commons Httpclient & Simple Logging Facade for Java are only used indirectly through jackrabbit.
  • As we do pull all dependencies through gradle now there is no need to mention any jars and no need for projects that use this library to explicitly include any of these dependencies.
  • org.parceler & com.google.code.gson are missing from that file

Java API for NextCloud?

Hello,

I am planning to integrate NextCloud with my Java application. I was wondering if there is a Java API for NextCloud similar to this. I assume this android library can be tweaked to implement something like that. Has anyone tried it? Are there any implementations?

I could find one such implementation here https://github.com/a-schild/nextcloud-java-api, but it has no method to download a file.

Please let me know.

Library crashes at authorization using Android 9

After I updated my project to Android 9 (API 28) the library no longer works as it crashes
due to a class not being to load NTLMScheme

I have included the legacy library in the project

useLibrary 'org.apache.http.legacy'

other clouds (Google Drive api, Dropbox api etc) depending on this library work OK, it's just the authorization that does not work.

I checked the contents of the legacy .jar and see the class is inside that .jar, but seems at a different path. Any ide how to fix this?

     Caused by: java.lang.NoClassDefFoundError: org.apache.commons.httpclient.auth.NTLMScheme
        at org.apache.commons.httpclient.auth.AuthPolicy.class$(AuthPolicy.java:100)
        at org.apache.commons.httpclient.auth.AuthPolicy.<clinit>(AuthPolicy.java:100)
        at org.apache.commons.httpclient.auth.AuthPolicy.getAuthScheme(Unknown Source:0)
        at org.apache.commons.httpclient.auth.AuthState.setPreemptive(AuthState.java:122)
        at org.apache.commons.httpclient.HttpMethodDirector.executeMethod(HttpMethodDirector.java:162)
        at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:397)
        at org.apache.commons.httpclient.HttpClient.executeMethod(HttpClient.java:323)
        at com.owncloud.android.lib.common.OwnCloudClient.executeMethod(OwnCloudClient.java:222)
        at com.owncloud.android.lib.common.OwnCloudClient.executeMethod(OwnCloudClient.java:192)
        at com.owncloud.android.lib.resources.files.ExistenceCheckRemoteOperation.run(ExistenceCheckRemoteOperation.java:91)
        at com.owncloud.android.lib.common.operations.RemoteOperation.execute(RemoteOperation.java:136)

Crash at app startup due to jacoco trying to write to root directory

I sometimes get a crash at app startup coming from the nextcloud android-library, debug build.
I use the revision 847558b from 04.Mar.2020 (v2.0.1).
Seems to be related to this problem: jacoco/jacoco#968

03-08 01:57:38.690 20787 20852 W System.err: java.io.FileNotFoundException: /jacoco.exec (Read-only file system)
03-08 01:57:38.690 20787 20852 W System.err:    at java.io.FileOutputStream.open0(Native Method)
03-08 01:57:38.691 20787 20852 W System.err:    at java.io.FileOutputStream.open(FileOutputStream.java:308)
03-08 01:57:38.691 20787 20852 W System.err:    at java.io.FileOutputStream.<init>(FileOutputStream.java:238)
03-08 01:57:38.691 20787 20852 W System.err:    at org.jacoco.agent.rt.internal_8ff85ea.output.FileOutput.openFile(FileOutput.java:67)
03-08 01:57:38.691 20787 20852 W System.err:    at org.jacoco.agent.rt.internal_8ff85ea.output.FileOutput.startup(FileOutput.java:49)
03-08 01:57:38.691 20787 20852 W System.err:    at org.jacoco.agent.rt.internal_8ff85ea.Agent.startup(Agent.java:122)
03-08 01:57:38.691 20787 20852 W System.err:    at org.jacoco.agent.rt.internal_8ff85ea.Agent.getInstance(Agent.java:50)
03-08 01:57:38.691 20787 20852 W System.err:    at org.jacoco.agent.rt.internal_8ff85ea.Offline.<clinit>(Offline.java:31)
03-08 01:57:38.691 20787 20852 W System.err:    at org.jacoco.agent.rt.internal_8ff85ea.Offline.getProbes(Offline.java:51)
03-08 01:57:38.691 20787 20852 W System.err:    at com.owncloud.android.lib.common.OwnCloudClientManagerFactory.$jacocoInit(Unknown Source:13)
03-08 01:57:38.691 20787 20852 W System.err:    at com.owncloud.android.lib.common.OwnCloudClientManagerFactory.<clinit>(Unknown Source:0)
03-08 01:57:38.691 20787 20852 W System.err:    at com.owncloud.android.lib.common.OwnCloudClientManagerFactory.setUserAgent(Unknown Source:0)

Replace used http client library

At the moment the Nextcloud library uses a very old Apache http client library commons-httpclient-3.1. Thus I propose to move on to the latest stable release which is described here: https://hc.apache.org/httpcomponents-client-4.5.x/android-port.html - httpclient-android-4.3.5.1 targeting Android 22 or lower or httpclient-android-4.4.1.1 respectively targeting Android 23 of higher or use libraries like OkHttp, Volley or others.

cc @tobiasKaminsky for discussion on this topic

Asked for compatibility here: smarek/httpclient-android#12

Timeout when assembling large file uploads

As reported to the android-app repository in nextcloud/android#5609, uploading large files fails at 100% by timeout if the server takes too long assembling them. This results in an endless loop of retries and conflicts.

This can be fixed by increasing the read-timeout of the move-method that does the assembly in the chunk-upload. I tested setting the timeout to a flat 15 minutes similarly to what was done to version 1 of the library in #19. However, maybe that timeout should scale with the filesize only for files larger than some limit (like 100mb) and be left alone otherwise?

If desired, I can submit a pr for either solution.

What is undocumented UploadRemoteFileOperation param fileLastModifTimestamp

Hi,

The documentation
https://docs.nextcloud.com/server/13/developer_manual/android_library/examples.html
does not mention the 4th param in the constructor
UploadRemoteFileOperation(String localPath, String remotePath, String mimeType, String fileLastModifTimestamp);
What should this be ? How should a long File.lastModified be formatted to math this?

When I simply pass "" or null, I get a 500 internal server error reply - which is converted to INSTANCE_NOT _CONFIGURED, but all other calls (download, list directory , remoteFileInformation etc all work as designed)

Cannot use ReadRemoteFolderOperation

I'm not sure why, maybe you are using an old version of the ownCloud library, but when I try to use ReadRemoteFolderOperation as in:

ReadRemoteFolderOperation refreshOperation = new ReadRemoteFolderOperation(FileUtils.PATH_SEPARATOR);

I get the error

cannot resolve symbol 'ReadRemoteFolderOperation'

Support mutual TLS auth

Hi,

I have a deployment of next cloud behind a reverse proxy which secures the connection via mutual TLS with client certs. Supporting this would require extending com.owncloud.android.lib.common.OwnCloudClient to support mutual TLS authentication and loading a keystore containing the cert to use.

`CreationException` is marked as `@Deprecated`.

CreationException is marked as @Deprecated.

I think it's rather kludgy to fail with exceptions in general. Many developers don't even know how to handle exceptions or care about handling them, using try-catch block to suppress them (sic!):

try {
    veryImportantThng = makeStuff();
} catch(VeryNastyException ex) {
   log(ex);
}
continue and probably crash later

Maybe we can return a client that fast-fails the operation? This way we can remove a lot of checks in the client code and make it safer:

  1. no edge cases
  2. no null handling

Originally posted by @ezaquarii in nextcloud/android#4900

Fix login route

at the moment the login uses index.php as a rout not the /ocs path as discussed with @MorrisJobke
This is a high prio issue since this will break login for Nc11 instances but the to be used route works backward for all Nc versions and also oC8.x versions.

cc: @tobiasKaminsky - labeling it prio high to have this in beta releases soon for testing and ship it with the next feature release of the app.

Branch has been created: https://github.com/nextcloud/android-library/tree/userInfoRouteUpdate (no changes yet)

NPE: RemoteOperationResult - StatusLine.getStatusCode()

When making heavy use of Nextcloud's DocumentsProvider via Seedvault, I sometimes get crashes like these:

This is with Nextcloud 3.12.1 which seems to be using 4b90880 of this library.

    java.lang.NullPointerException: Attempt to invoke virtual method 'int org.apache.commons.httpclient.StatusLine.getStatusCode()' on a null object reference
        at org.apache.commons.httpclient.HttpMethodBase.getStatusCode(HttpMethodBase.java:570)
        at com.owncloud.android.lib.common.operations.RemoteOperationResult.<init>(RemoteOperationResult.java:328)
        at com.owncloud.android.lib.resources.files.DownloadFileRemoteOperation.run(DownloadFileRemoteOperation.java:85)
        at com.owncloud.android.lib.common.operations.RemoteOperation.execute(RemoteOperation.java:181)
        at com.owncloud.android.operations.DownloadFileOperation.run(DownloadFileOperation.java:160)
        at com.owncloud.android.lib.common.operations.RemoteOperation.execute(RemoteOperation.java:181)
        at com.owncloud.android.files.services.FileDownloader.downloadFile(FileDownloader.java:471)
        at com.owncloud.android.files.services.FileDownloader.access$500(FileDownloader.java:81)
        at com.owncloud.android.files.services.FileDownloader$ServiceHandler.handleMessage(FileDownloader.java:422)

It seems like DownloadFileRemoteOperation#run() is calling DownloadFileRemoteOperation#downloadFile() which swallows all exceptions (not sure if logging works, I didn't see any messages). Then run() is working on the potentially bogus result and in this case crashes. I've often seen a status of -1 returned in the log without crashes, but that probably also means that there was a problem with the HTTP request.

This crash is especially bad, because the DocumentsProvider consumer is hanging waiting for a response from Nextcloud which never comes.

So if DownloadFileRemoteOperation#downloadFile() is only ever called by run() which catches all exceptions already, then I suggest to remove the catching from downloadFile(), so that they appear in run() and this doesn't try to proceed with an undefined result, but errors out properly.

Parser crash for activities with null values

The android client crashes while parsing deck activities which send null values for the rich subject parts, e.g. when trying to parse this:

{
"activity_id":7655,"app":"deck","type":"deck","user":"andy","subject":"You have created a new stack Done on Personal",
"subject_rich":
[
"You have created a new stack {stack} on {board}",
{
"board":{"type":"highlight","id":6,"name":"Personal","link":"/index.php/apps/deck/#!/board/6/"},
"card":null,
"user":{"type":"user","id":"andy","name":"Andy"},
"stack":{"type":"highlight","id":7,"name":"Done"}
}],
"message":null,"message_rich":["",[]],"object_type":"deck_board","object_id":6,"object_name":"Personal","objects":{"6":"Personal"},"link":"","icon":"/apps/files/img/add-color.svg","datetime":"2018-11-14T13:53:42+00:00"
}

we get an Exception:

Expected BEGIN_OBJECT but was NULL at path $[11].subject_rich[1].card

@nickvergessen can you shed some light on this if

  • deck needs to remove the card element completely
  • Android client needs to be able to handle such null values (would have to check how to do thi in GSON)

cc @juliushaertl for deck and @tobiasKaminsky for Android lib.

At the moment the client app will show an error toast and no activity stream.

Unable to use with Nextcloud SSO

Hi I try to use the Nextcloud Android SSO in my android app but get the following error when doing a UploadFileRemoteOpreation:

E/HttpMethodDirector: Credentials cannot be used for basic authentication: com.owncloud.android.lib.common.network.BearerCredentials
    org.apache.commons.httpclient.auth.InvalidCredentialsException: Credentials cannot be used for basic authentication: com.owncloud.android.lib.common.network.BearerCredentials

Is the token from the Nextcloud Android SSO not a Bearer Token or am I doing something wrong? I am kind of confused

SocketTimeoutException on library v2

java.net.SocketTimeoutException: 
 
  at libcore.io.IoBridge.connectErrno (IoBridge.java:191)
 
  at libcore.io.IoBridge.connect (IoBridge.java:135)
 
  at java.net.PlainSocketImpl.socketConnect (PlainSocketImpl.java:142)
 
  at java.net.AbstractPlainSocketImpl.doConnect (AbstractPlainSocketImpl.java:390)
 
  at java.net.AbstractPlainSocketImpl.connectToAddress (AbstractPlainSocketImpl.java:230)
 
  at java.net.AbstractPlainSocketImpl.connect (AbstractPlainSocketImpl.java:212)
 
  at java.net.SocksSocketImpl.connect (SocksSocketImpl.java:436)
 
  at java.net.Socket.connect (Socket.java:621)
 
  at okhttp3.internal.platform.AndroidPlatform.connectSocket (AndroidPlatform.java:73)
 
  at okhttp3.internal.connection.RealConnection.connectSocket (RealConnection.java:247)
 
  at okhttp3.internal.connection.RealConnection.connect (RealConnection.java:167)
 
  at okhttp3.internal.connection.StreamAllocation.findConnection (StreamAllocation.java:258)
 
  at okhttp3.internal.connection.StreamAllocation.findHealthyConnection (StreamAllocation.java:135)
 
  at okhttp3.internal.connection.StreamAllocation.newStream (StreamAllocation.java:114)
 
  at okhttp3.internal.connection.ConnectInterceptor.intercept (ConnectInterceptor.java:42)
 
  at okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:147)
 
  at okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:121)
 
  at okhttp3.internal.cache.CacheInterceptor.intercept (CacheInterceptor.java:93)
 
  at okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:147)
 
  at okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:121)
 
  at okhttp3.internal.http.BridgeInterceptor.intercept (BridgeInterceptor.java:93)
 
  at okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:147)
 
  at okhttp3.internal.http.RetryAndFollowUpInterceptor.intercept (RetryAndFollowUpInterceptor.java:127)
 
  at okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:147)
 
  at okhttp3.internal.http.RealInterceptorChain.proceed (RealInterceptorChain.java:121)
 
  at okhttp3.RealCall.getResponseWithInterceptorChain (RealCall.java:257)
 
  at okhttp3.RealCall.execute (RealCall.java:93)
 
  at com.nextcloud.common.OkHttpMethodBase.execute (OkHttpMethodBase.kt:126)
 
  at com.nextcloud.common.NextcloudClient.execute (NextcloudClient.kt:84)
 
  at com.owncloud.android.lib.resources.activities.GetActivitiesRemoteOperation.run (GetActivitiesRemoteOperation.java:131)

@ezaquarii @AndyScherzinger have you experienced that on your devices?
This is a high crash rate on google dev console, so we should try to fix it.

It seems we have default of 10s set, but on old library we only use 5s for connect.
So I hesitate to "stupidly" increase the timeout, but wonder why it takes more than double the time to get a connection.

GPlay: java.lang.NullPointerException - com.owncloud.android.lib.resources.status.OwnCloudVersion.<init>

java.lang.NullPointerException
com.owncloud.android.lib.resources.status.OwnCloudVersion.

java.lang.NullPointerException: 
  at com.owncloud.android.lib.resources.status.OwnCloudVersion.<init> (OwnCloudVersion.java:84)
  at com.owncloud.android.lib.common.accounts.AccountUtils.getCredentialsForAccount (AccountUtils.java:210)
  at com.owncloud.android.lib.common.OwnCloudAccount.loadCredentials (OwnCloudAccount.java:126)
  at com.owncloud.android.lib.common.SimpleFactoryManager.getClientFor (SimpleFactoryManager.java:62)
  at com.owncloud.android.lib.common.DynamicSessionManager.getClientFor (DynamicSessionManager.java:42)
  at com.owncloud.android.lib.common.operations.RemoteOperation.run (RemoteOperation.java:282)
  at java.lang.Thread.run (Thread.java:764)

Hasn't been recorded before 2.0.0-rc2 but I guess this is due to a misconfigured server. Nevertheless I'd say we should handle it and gracefully fallback to the oldest server version we support. What do you think @mario @tobiasKaminsky? For whatever reason it seams the server version is null?!

More generic target file in DownloadRemoteFileOperation constructor

Hi,
The DownloadRemoteFileOperation currently takes (String remotePath, String localFolderPath) as parameters. These are then concatenated in getTmpPath().
As a result the temp file directory structure matches the path in remotePath.
This is not very convenient if you want to download to a different directory structure (as I do).
If there were a new constructor (String remotePath, File tempFile) that would simply take the temp file as defined by the using client, it would be much more generic. The existing constructor can be expressed in this by using DownloadRemoteFileOperation(remotePath, new File(localFolderPath, remotePath));
I thik this would make the interface much more generic to use and would save me from copying the class for just this modification.

Thanks in advance,

Bump Jackrabbit to the latest 2.14 release

At the moment we are using 2.12.x which is still using http client 3.1 while the new release 2.14 bumped the version to 4.1, see http://jackrabbit.510166.n4.nabble.com/ANNOUNCE-Apache-Jackrabbit-2-14-0-released-td4666058.html

The main changes in this release are:

  • Switch WebDAV client components to HttpClient 4.5.x (summary in JCR-2406)
  • Introduction of Commons-VFS Datastore implementation (JCR-3975)
  • Allow use of JDK7 features (JCR-4030)

cc @mario @tobiasKaminsky

Immediate crash in release builds

The library gives me the following crash on the first call. I tried to trace down the exact location where the crash happens, but ultimately, it seems to be in some static class initialization code somewhere in HttpConnectionManager or that area.

This only happens when building with proguard enabled, but I think I kept all apache related classes (see my config file below). It is also interesting that this crashes only on my Samsung S8 (Android 9), but not on the Nexus 5 (Android 6). Hence, I don't believe it is simply a missing class, but rather some code error.

I also tried old versions down to 1.3.0, but get the same error, which is strange because I was building this without this problem in April 2019. Hence, the issue might only occur with current versions of Android studio (v3.6.1).

Spent a whole day and night on this and am completely stuck.
Will have to remove Nextcloud support from my software until this is resolved.

Crash:

03-08 03:09:28.773 25982 26053 E AndroidRuntime: java.lang.ExceptionInInitializerError
03-08 03:09:28.773 25982 26053 E AndroidRuntime:        at com.owncloud.android.lib.common.OwnCloudClientFactory.createOwnCloudClient(SourceFile:18)
...
03-08 03:09:28.773 25982 26053 E AndroidRuntime:        at java.lang.Thread.run(Thread.java:764)
03-08 03:09:28.773 25982 26053 E AndroidRuntime: Caused by: org.apache.commons.logging.LogConfigurationException: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.trim()' on a null object reference (Caused by java.lang.NullPointerException: Attempt to invoke virtual\
 method 'java.lang.String java.lang.String.trim()' on a null object reference)
03-08 03:09:28.773 25982 26053 E AndroidRuntime:        at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(SourceFile:7)
03-08 03:09:28.773 25982 26053 E AndroidRuntime:        at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(SourceFile:3)
03-08 03:09:28.773 25982 26053 E AndroidRuntime:        at org.apache.commons.logging.impl.LogFactoryImpl.getInstance(SourceFile:1)
03-08 03:09:28.773 25982 26053 E AndroidRuntime:        at org.apache.commons.logging.LogFactory.getLog(SourceFile:1)
03-08 03:09:28.773 25982 26053 E AndroidRuntime:        at org.apache.commons.httpclient.HttpClient.<clinit>(SourceFile:1)
03-08 03:09:28.773 25982 26053 E AndroidRuntime:        ... 5 more
03-08 03:09:28.773 25982 26053 E AndroidRuntime: Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.lang.String java.lang.String.trim()' on a null object reference
03-08 03:09:28.773 25982 26053 E AndroidRuntime:        at org.apache.commons.logging.impl.LogFactoryImpl.createLogFromClass(SourceFile:27)
03-08 03:09:28.773 25982 26053 E AndroidRuntime:        at org.apache.commons.logging.impl.LogFactoryImpl.discoverLogImplementation(SourceFile:19)
03-08 03:09:28.773 25982 26053 E AndroidRuntime:        at org.apache.commons.logging.impl.LogFactoryImpl.newInstance(SourceFile:2)
03-08 03:09:28.773 25982 26053 E AndroidRuntime:        ... 9 more

proguard config (it's an enhanced version of a config previously posted here):

# Nextcloud
-keep,allowshrinking class com.owncloud.android.** { *; }
-keep,allowshrinking class org.parceler.** { *; }
-keep,allowshrinking class org.slf4j.** { *; }
-keep class org.apache.** { *; }

# --- these have no effect
#-keep class org.** { *; }
#-keep class javax.** { *; }
#-keep class com.squareup.**
#-keep class org.jetbrains.**
#-keep class twitter4j.** { *; }

# --- these options also have no effect
#-dontshrink
#-dontoptimize
#-dontpreverify
#-verbose


-dontwarn com.owncloud.android.lib.**
-dontwarn org.apache.jackrabbit.webdav.**
-dontwarn org.slf4j.**

-dontskipnonpubliclibraryclasses

-keepclasseswithmembernames class * {
    native <methods>;
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet);
}

-keepclasseswithmembers class * {
    public <init>(android.content.Context, android.util.AttributeSet, int);
}

-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

-keepattributes InnerClasses
#end nextcloud

gradle:

configurations.all {
    exclude group: "log4j", module: "log4j"
    exclude group: 'org.slf4j', module: 'jcl-over-slf4j'

    exclude group: 'com.google.guava', module: 'listenablefuture'
}

...
    implementation project(":libs:nextcloud-android-library")
    implementation "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2
...
    implementation('com.google.api-client:google-api-client-android:1.26.0') {
        exclude group: 'org.apache.httpcomponents'
    }
    implementation('com.google.apis:google-api-services-drive:v3-rev136-1.25.0') {
        exclude group: 'org.apache.httpcomponents'
    }
...

User information leaking through debug log prints.

adb logcat reveals several debug log entries marked with "GetRemoteUserInfoOperation". Here is one example.

02-09 23:12:33.410 28516 3060 D GetRemoteUserInfoOperation: Successful response: {"ocs":{"meta":{"status":"ok","statuscode":100,"message":"OK","totalitems":"","itemsperpage":""},"data":{"enabled":"true","id":"xxx","quota":{"free":110406975803,"used":50654297797,"total":161061273600,"relative":31.45,"quota":161061273600},"email":"[email protected]","phone":"","address":"","website":"https:\/\/redacted.com","twitter":"@redacted","groups":["admin"],"language":"en","display-name":"Redacted"}}}

It makes sense to print these as a debugging measure, but it doesnt belong in a production ready deployment. My recommendation would either be to use a wrapper class to filter the log prints away from RELEASE builds or use Proguard to filter out the debug code completely.

How to get qouta

How do i get quota for a user, or how do i get a NextCloudClient, so that i can run a GetUserInfoRemoteOperation?

fail to createfolder using bearer access token

Help please,

i try access token from Talk-Android and i use that token for startFolderCreation, but the result process is fail.

D/EGL_emulation: eglMakeCurrent: 0xe2c054e0: ver 3 1 (tinfo 0xe2c03710)
D/OwnCloudClient #0: REQUEST MKCOL /remote.php/odav/myfolder
D/OwnCloudClient #0: Location to redirect: https://domaintesting.com/remote.php/odav/myfolder
D/AdvancedSslSocketFactory: Creating SSL Socket with remote domaintesting.com:443, local null:0, params: org.apache.commons.httpclient.params.HttpConnectionParams@fc9745b
... with connection timeout 5000 and socket timeout 30000
I/ServerNameIndicator: SSLSocket implementation: com.android.org.conscrypt.Java8FileDescriptorSocket
I/ServerNameIndicator: SNI done, hostname: domaintesting.com
D/RemoteOperationResult: RemoteOperationResult has processed UNHANDLED_HTTP_CODE: 200 OK
D/CreateFolderRemoteOperation: Create directory myfolder: Operation finished with HTTP status code 200 (fail)

Thanks.

Still OwnCloud references

The accompanied text holds still references for OwnCloud and NOT NextCloud, yet

regards, hitam4450

Failed to resolve error

Hi,

I am using Android Studio and I want to use the library. I updated my root gradle file with:
maven { url "https://jitpack.io" }

And added this in my app gradle file:
implementation 'com.github.nextcloud:android-library:1.1.0'

I also tried -SNAPSHOT or master but this does not work:
Failed to resolve: com.github.nextcloud:android-library:1.1.0

How to get the library then?

403 forbidden

Hi,

I keep having 403 forbidden exception when using this code on some servers (perhaps the ones with reverse proxies)

but the nextcloud app works when using old authentication method. Any ideas why ?
Thanks !


OwnCloudClient client = OwnCloudClientFactory.createOwnCloudClient(
                    Uri.parse("https://server"),
                    getContext(),
                    true);
            client.setCredentials(
                    OwnCloudCredentialsFactory.newBasicCredentials("username", "password")
            );

            ExistenceCheckRemoteOperation operation = new ExistenceCheckRemoteOperation("/", false);
            RemoteOperationResult result = operation.execute(client);

            if (operation.wasRedirected()) {
                RedirectionPath redirectionPath = operation.getRedirectionPath();
                String permanentLocation = redirectionPath.getLastPermanentLocation();
                result.setLastPermanentLocation(permanentLocation);
            }

            Log.d("connectdebug",result.getLogMessage());
            Log.d("connectdebug ",""+(result.isServerFail() || result.isException()));
            return result.isSuccess();

Dav-URLs containing spaces causing problems

When a username or path contains a space, the nextcloud android app is throwing exceptions making e.g. logins for those users impossible while it works in other apps and using the web GUI.

OwnCloudClient.getFilesDavUri(String path) should encode spaces within path AND OwnCloudClient.userId.
In detail this.getUserId() should be used in favor of this.userId.

2021-11-15 21:11:12.933 9444-9966/com.nextcloud.client W/System.err: java.lang.IllegalArgumentException: Invalid uri 'https://nextcloud.instance.com/remote.php/dav/files/Mister Mysterious//': escaped absolute path not valid
2021-11-15 21:11:12.933 9444-9966/com.nextcloud.client W/System.err:     at org.apache.commons.httpclient.HttpMethodBase.<init>(HttpMethodBase.java:222)
2021-11-15 21:11:12.934 9444-9966/com.nextcloud.client W/System.err:     at org.apache.commons.httpclient.methods.HeadMethod.<init>(HeadMethod.java:94)
2021-11-15 21:11:12.934 9444-9966/com.nextcloud.client W/System.err:     at com.owncloud.android.authentication.AuthenticatorAsyncTask.mausekuchen(AuthenticatorAsyncTask.java:128)
2021-11-15 21:11:12.934 9444-9966/com.nextcloud.client W/System.err:     at com.owncloud.android.authentication.AuthenticatorAsyncTask.doInBackground(AuthenticatorAsyncTask.java:99)
2021-11-15 21:11:12.934 9444-9966/com.nextcloud.client W/System.err:     at com.owncloud.android.authentication.AuthenticatorAsyncTask.doInBackground(AuthenticatorAsyncTask.java:51)
2021-11-15 21:11:12.935 9444-9966/com.nextcloud.client W/System.err:     at android.os.AsyncTask$3.call(AsyncTask.java:378)
2021-11-15 21:11:12.935 9444-9966/com.nextcloud.client W/System.err:     at java.util.concurrent.FutureTask.run(FutureTask.java:266)
2021-11-15 21:11:12.935 9444-9966/com.nextcloud.client W/System.err:     at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:289)
2021-11-15 21:11:12.935 9444-9966/com.nextcloud.client W/System.err:     at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
2021-11-15 21:11:12.935 9444-9966/com.nextcloud.client W/System.err:     at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
2021-11-15 21:11:12.935 9444-9966/com.nextcloud.client W/System.err:     at java.lang.Thread.run(Thread.java:929)

ReadFileVersionsRemoteOperation always ends up with file not found

Steps to reproduce
Request versions with ReadFileVersionsRemoteOperation
Execute request
Result is always not success with file not found
Expected behaviour
result should be success and deliver list of versions of the given file
Actual behaviour
Always no success because of File not found
Can you reproduce this problem on https://try.nextcloud.com?
Yes

Environment data
Android version: 10

Device model: Huawei Honor View 10

Client creation:
mClient = OwnCloudClientFactory.createOwnCloudClient(serverUri, ctx, true);
mClient.setCredentials(
OwnCloudCredentialsFactory.newBasicCredentials(
XXXXXX,
YYYYYY
)
);

Request:

ReadFileVersionsRemoteOperation rop = new ReadFileVersionsRemoteOperation(mHelpFileId) // mHelpFileId="121427";
rop.execute(mClient, this, mHandler);

Perhaps this helps:
In Browser the response for this request has a first not found response. the second response is server code 200 and has data. Seems that library just sees the not found of the first response.

<d:multistatus
xmlns:d="DAV:"
xmlns:s="http://sabredav.org/ns"
xmlns:oc="http://owncloud.org/ns"
xmlns:nc="http://nextcloud.org/ns">
<d:response>
<d:href>/remote.php/dav/versions/XXXXX/versions/121427/</d:href>
<d:propstat>
<d:prop>
<d:getcontentlength/>
<d:getcontenttype/>
<d:getlastmodified/>
</d:prop>
<d:status>HTTP/1.1 404 Not Found</d:status>
</d:propstat>
</d:response>
<d:response>
<d:href>/remote.php/dav/versions/XXXXX/versions/121427/1611152051</d:href>
<d:propstat>
<d:prop>
<d:getcontentlength>11617184</d:getcontentlength>
<d:getcontenttype>application/pdf</d:getcontenttype>
<d:getlastmodified>Wed, 20 Jan 2021 14:14:11 GMT</d:getlastmodified>
</d:prop>
<d:status>HTTP/1.1 200 OK</d:status>
</d:propstat>
</d:response>
</d:multistatus>

Library v2: what changed & why

I started a while a go to slowly to use OkHTTP and DAV4jvm by BitfireAT.

This introduces some changes, that any project using this lib should be aware of

  • change build.gradle
    • add to android {…}: compileOptions {
      sourceCompatibility JavaVersion.VERSION_1_8
      targetCompatibility JavaVersion.VERSION_1_8
      }

    • add to dependencies {…}:
      implementation "commons-httpclient:commons-httpclient:3.1@jar" // remove after entire switch to lib v2

    • add to AndroidManifest.xml:

             android:name="org.apache.http.legacy"
             android:required="false"/>```
      
      
  • NextcloudClient is used instead of OwnCloudClient for rewritten remote operations

If you need any help or if there questions, just reply here.

null pointer crash in CreateRemoteFolderOperation

There is a null-pointer crash when using CreateRemoteFolderOperation in this situation:

When the operation is run, the following happens:

  • CreateRemoteFolder.run() calls createFolder() which fails.
  • Because it fails, it will call createParentFolder(), which will try to create "/" and fails again.
  • As it fails again, it will try to create the parent folder of "/".
  • It calls String parentPath = new File(remotePath).getParent() on remotePath="/", which results in `parentPath=null' (FileUtils.java:37)
  • It crashes in the following line.

Crash when trying to execute ReadFolderRemoteOperation

I have followed the instructions from the sample application, for calling ReadFolderRemoteOperation but i get this error.

java.lang.ExceptionInInitializerError
        at org.apache.jackrabbit.webdav.Status.<init>(Status.java:41)
        at org.apache.jackrabbit.webdav.MultiStatusResponse.getStatus(MultiStatusResponse.java:262)
        at com.owncloud.android.lib.common.network.WebdavEntry.<init>(WebdavEntry.java:119)
        at com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation.readData(ReadFolderRemoteOperation.java:144)
        at com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation.run(ReadFolderRemoteOperation.java:88)
        at com.owncloud.android.lib.common.operations.RemoteOperation.run(RemoteOperation.java:363)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'int java.io.Reader.read(char[])' on a null object reference
        at java.util.Properties$LineReader.readLine(Properties.java:432)
        at java.util.Properties.load0(Properties.java:348)
        at java.util.Properties.load(Properties.java:336)
        at org.apache.jackrabbit.webdav.DavException.<clinit>(DavException.java:41)
        at org.apache.jackrabbit.webdav.DavException.getStatusPhrase(DavException.java:131)
        at org.apache.jackrabbit.webdav.Status.<init>(Status.java:41) 
        at org.apache.jackrabbit.webdav.MultiStatusResponse.getStatus(MultiStatusResponse.java:262) 
        at com.owncloud.android.lib.common.network.WebdavEntry.<init>(WebdavEntry.java:119) 
        at com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation.readData(ReadFolderRemoteOperation.java:144) 
        at com.owncloud.android.lib.resources.files.ReadFolderRemoteOperation.run(ReadFolderRemoteOperation.java:88) 
        at com.owncloud.android.lib.common.operations.RemoteOperation.run(RemoteOperation.java:363) 
        at java.lang.Thread.run(Thread.java:764)

Add me to the repository

Actual behavior

I am not a member of the repository, can't commit, push or review.

Expected behavior

I should be a member of the repository, should be able to commit, push and review.

Steps to reproduce

  1. Buy a cookie
  2. Check the list of repository users
  3. See that I'm missing

Serverbase URL wrong? Error: HOST_NOT_AVAILABLE

I am trying to upload a file but there seems to be an error with the Url?
Log says:

<D/OwnCloudClient #0: Creating OwnCloudClient D/OwnCloudClient #0: REQUEST PUT /remote.php/webdav/Testhtml.html D/AdvancedSslSocketFactory: Creating SSL Socket with remote xxx-xxx.de:443, local null:0, params: org.apache.commons.httpclient.params.HttpConnectionParams@b4ef2da D/AdvancedSslSocketFactory: ... with connection timeout 60000 and socket timeout 60000 I/Upload result:: HOST_NOT_AVAILABLE

The Nextcloud server is available under https://xxx-xxx.de/nextcloud. I tried the url with and without /nextcloud at the end.

I can login there and everything works fine. Is the base Url wrong here?

My code:

public NextCloudManager(Context context) {
    Uri serverUri = Uri.parse("https://xxx-xxx.de");
    mClient = OwnCloudClientFactory.createOwnCloudClient(serverUri, context, true);
    mClient.setCredentials(
            OwnCloudCredentialsFactory.newBasicCredentials("xxxx", "xxxx")
    );

}

And the method to upload a file:

public void startUpload(File fileToUpload, String mimeType) {

    String remotePath = FileUtils.PATH_SEPARATOR + fileToUpload.getName();
    // Get the last modification date of the file from the file system
    Long timeStampLong = fileToUpload.lastModified() / 1000;
    String timeStamp = timeStampLong.toString();

    UploadFileRemoteOperation uploadFileRemoteOperation =
            new UploadFileRemoteOperation(fileToUpload.getAbsolutePath(), remotePath, mimeType, timeStamp);
    //uploadFileRemoteOperation.addDatatransferProgressListener(this);
    RemoteOperationResult result = uploadFileRemoteOperation.execute(mClient);
    Log.i("Upload result: ", result.getCode().toString());

}

when I use other RemoteOperation , it happens "FILE_NOT_FOUND'

DownloadFileRemoteOperation,GetUserInfoRemoteOperation,ReadFolderRemoteOperation were OK.
when I use other RemoteOperation , such as "ReadTrashbinFolderRemoteOperation", or "SearchRemoteOperation" , it happens "FILE_NOT_FOUND'

ReadTrashbinFolderRemoteOperation: Synchronized /: Local file does not exist
result: RemoteOperationResult(mSuccess=false, mHttpCode=404, mHttpPhrase=Not Found, mException=null, mCode=FILE_NOT_FOUND, getLogMessage=Local file does not exist)

what's the problem?

UploadFileRemoteOperation cannot be solved

I added the library via gradle with this:
implementation 'com.github.nextcloud:android-library:1.2.0'

I try to build the functionality of the sample client into my app but Android Studio does not resolve the correct classes. The names of some classes have changed some days ago and leads to problems. I try to import this (like in the SampleClient):
UploadFileRemoteOperation

But Android Studio/the compiler only knows this:
import com.owncloud.android.lib.resources.files.UploadRemoteFileOperation;

I already rebuild the project/reopened Android Studio but the problem remains..

How to configure Proguard for Android Client library

Hi,
I’m using the Nextcloud Android library to add Nextcloud support to an android app using Android Studio. I’m having trouble configuring Proguard. When I run with minifyEnabled false all is fine, but with minifyEnabled true I get lots of Proguard related warnings and error. For example:

com.owncloud.android.lib.common.ExternalLink$$Parcelable: can’t find superclass or interface org.parceler.ParcelWrapper

library class org.apache.commons.codec.binary.BinaryCodec extends or implements program class org.apache.commons.codec.BinaryDecoder

org.apache.jackrabbit.webdav.server.AbstractWebdavServlet: can’t find referenced method ‘int getContentLength()’ in program class org.apache.jackrabbit.webdav.WebdavRequest

I can run with disabling the warings , for example
-dontwarn com.owncloud.android.lib.**
etc.
But then the app crashes as soon as a client completes.

I have tried copying the Proguard.cfg settings from the Nextcloud client app on Github, but that does not make a difference.

Any idea how to configure Proguard to make this work?

Thanks in advance,

Gerrit Beuze

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.