Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NoClassDefFoundError in com.filestack.internal.Networking #80

Open
jagged91 opened this issue Oct 15, 2018 · 7 comments
Open

NoClassDefFoundError in com.filestack.internal.Networking #80

jagged91 opened this issue Oct 15, 2018 · 7 comments
Assignees

Comments

@jagged91
Copy link

This is in an Android app running in debug (i.e. no proguard/obfuscation). The client is unable to initialize. Here's the stacktrace:

java.lang.IllegalStateException: Fatal Exception thrown on Scheduler.Worker thread. at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:59) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764) Caused by: java.lang.NoClassDefFoundError: com.filestack.internal.Networking at com.filestack.internal.Networking.getCdnService(Networking.java:87) at com.filestack.Client.<init>(Client.java:48) at com.myapp.app.support.DatabaseArchiver$uploadArchive$1.call(DatabaseArchiver.kt:172) at com.myapp.app.support.DatabaseArchiver$uploadArchive$1.call(DatabaseArchiver.kt:47) at rx.internal.operators.OnSubscribeFromCallable.call(OnSubscribeFromCallable.java:48) at rx.internal.operators.OnSubscribeFromCallable.call(OnSubscribeFromCallable.java:33) at rx.Observable.unsafeSubscribe(Observable.java:10150) at rx.internal.operators.OperatorSubscribeOn$1.call(OperatorSubscribeOn.java:94) at rx.internal.schedulers.CachedThreadScheduler$EventLoopWorker$1.call(CachedThreadScheduler.java:228) at rx.internal.schedulers.ScheduledAction.run(ScheduledAction.java:55) at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:457) at java.util.concurrent.FutureTask.run(FutureTask.java:266) at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:301) at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1162) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:636) at java.lang.Thread.run(Thread.java:764) Caused by: java.lang.ExceptionInInitializerError at com.filestack.internal.Networking.getCdnService(Networking.java:87) at com.filestack.Client.<init>(Client.java:48) at com.myapp.api.sync.SyncService$SyncAdapter.onPerformSync(SyncService.java:153) at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:321) Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'java.io.InputStream java.lang.ClassLoader.getResourceAsStream(java.lang.String)' on a null object reference at com.filestack.internal.Util.getVersion(Util.java:30) at com.filestack.internal.HeaderInterceptor.<init>(HeaderInterceptor.java:22) at com.filestack.internal.Networking.buildOkHtttpClient(Networking.java:33) at com.filestack.internal.Networking.<clinit>(Networking.java:29) at com.filestack.internal.Networking.getCdnService(Networking.java:87) at com.filestack.Client.<init>(Client.java:48) at com.myapp.api.sync.SyncService$SyncAdapter.onPerformSync(SyncService.java:153) at android.content.AbstractThreadedSyncAdapter$SyncThread.run(AbstractThreadedSyncAdapter.java:321)

I'm using OKHTTP 3.11.0 currently - could this be why?

@jagged91
Copy link
Author

Just tested with an older version of OKHTTP (3.9.0) and still have the same issue.

@scana scana self-assigned this Oct 15, 2018
@scana
Copy link
Contributor

scana commented Oct 15, 2018

Hey @jgadsby, do you use Filestack SDK inside of a SyncAdapter? Is this 0.9.0 version? Would you mind trying 0.8.2?

Caused by: java.lang.NullPointerException: 
Attempt to invoke virtual method 'java.io.InputStream
java.lang.ClassLoader.getResourceAsStream(java.lang.String)' on a null object reference at
com.filestack.internal.Util.getVersion(Util.java:30) at 

I see that there is some issue with acquiring the SDK version from system resources. This is not really necessary for us to do and it might be the cause of the problem. I don't really think that the OkHttp version has anything to do with it (fortunately :))

@jagged91
Copy link
Author

jagged91 commented Oct 15, 2018

So, I tried 0.8.2 and the exception seems to disappear, but there's still something going wrong - when I place a log statement right after the client is created, the log statement is never called.

Log.d("FileStackHandler", "Creating client...")
    // Create a Filestack client
    val config = Config("<API KEY>")
    val client = Client(config)
    Log.d("FileStackHandler", "Created client")

@jagged91
Copy link
Author

jagged91 commented Oct 15, 2018

Anyway, it doesn't matter right now as I'm unable to get the response via the library (see the other issue - #81). A slightly unrelated question: When I try to upload a file via the FileStack API and OKHTTP directly, I always get 'unexpected end of stream'. Any idea why?

Some more details:

Part of the code for the image + filestack endpoint:

          val fileName = "${image.id}_${System.currentTimeMillis()}"
          val URL = "https://www.filestackapi.com/api/store/S3?key=<key>&mimetype=image/jpeg&filename=$fileName"

          val bitmap = MediaStore.Images.Media.getBitmap(provider.context.contentResolver, image.bitmapUri)

          val contentLength = BitmapCompat.getAllocationByteCount(bitmap).toLong()

@jagged91
Copy link
Author

Never mind - I figured out the OKHTTP upload issue. I needed to provide the following to my OkHttpClient.Builder:

.pingInterval(1, TimeUnit.SECONDS) .writeTimeout(60L, TimeUnit.SECONDS)

@scana
Copy link
Contributor

scana commented Oct 15, 2018

So, I tried 0.8.2 and the exception seems to disappear, but there's still something going wrong - when I place a log statement right after the client is created, the log statement is never called.

Log.d("FileStackHandler", "Creating client...")
    // Create a Filestack client
    val config = Config("<API KEY>")
    val client = Client(config)
    Log.d("FileStackHandler", "Created client")

Does this issue still exists?
Also - do you instantiate and use Client class inside of a SyncAdapter?

@jagged91
Copy link
Author

Also - do you instantiate and use Client class inside of a SyncAdapter?

Yep!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants