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

Error loading version from resource "sdk-version.txt": Not found. #140

Closed
saurabhit49 opened this issue Aug 30, 2017 · 25 comments
Closed

Error loading version from resource "sdk-version.txt": Not found. #140

saurabhit49 opened this issue Aug 30, 2017 · 25 comments

Comments

@saurabhit49
Copy link

saurabhit49 commented Aug 30, 2017

I am migrating Dropbox Android V2 API from V1 in my existing project. I have follow this documentation. I have existing project developed with Eclipse. So i have downloaded "dropbox-core-sdk-3.0.3.jar" and "jackson-core-2.9.0.pr3.jar" files and added under lib folder. The V2 dropbox login process works fine and also Auth.getOAuth2Token() method return correct token.

But i am getting issue on calling DropboxClient.getClient(ACCESS_TOKEN) method. I am receiving follwing error...

java.lang.RuntimeException: Error loading version from resource "sdk-version.txt": Not found.

Full Error Stack:

 FATAL EXCEPTION: AsyncTask #1
 Process: com.android.myapp, PID: 23428
 java.lang.RuntimeException: An error occured while executing doInBackground()
 	at android.os.AsyncTask$3.done(AsyncTask.java:304)
 	at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:355)
 	at java.util.concurrent.FutureTask.setException(FutureTask.java:222)
 	at java.util.concurrent.FutureTask.run(FutureTask.java:242)
 	at android.os.AsyncTask$SerialExecutor$1.run(AsyncTask.java:231)
 	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1112)
 	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:587)
 	at java.lang.Thread.run(Thread.java:818)
 Caused by: java.lang.ExceptionInInitializerError
 	at com.dropbox.core.DbxRequestUtil.buildUserAgentHeader(DbxRequestUtil.java:146)
 	at com.dropbox.core.DbxRequestUtil.addUserAgentHeader(DbxRequestUtil.java:131)
 	at com.dropbox.core.DbxRequestUtil.startPostRaw(DbxRequestUtil.java:228)
 	at com.dropbox.core.v2.DbxRawClientV2$1.execute(DbxRawClientV2.java:100)
 	at com.dropbox.core.v2.DbxRawClientV2.executeRetriable(DbxRawClientV2.java:256)
 	at com.dropbox.core.v2.DbxRawClientV2.rpcStyle(DbxRawClientV2.java:97)
 	at com.dropbox.core.v2.users.DbxUserUsersRequests.getCurrentAccount(DbxUserUsersRequests.java:120)
 	at com.android.myapp.UserAccountTask.doInBackground(UserAccountTask.java:32)
 	at com.android.myapp.UserAccountTask.doInBackground(UserAccountTask.java:1)
 	at android.os.AsyncTask$2.call(AsyncTask.java:292)
 	at java.util.concurrent.FutureTask.run(FutureTask.java:237)
 	... 4 more
 Caused by: java.lang.RuntimeException: Error loading version from resource "sdk-version.txt": Not found.
 	at com.dropbox.core.DbxSdkVersion.loadVersion(DbxSdkVersion.java:66)
 	at com.dropbox.core.DbxSdkVersion.<clinit>(DbxSdkVersion.java:17)
 	... 15 more


@greg-db
Copy link
Contributor

greg-db commented Aug 30, 2017

[Cross-linking for reference: https://www.dropboxforum.com/t5/API-support/Error-loading-version-from-resource-quot-sdk-version-txt-quot/m-p/239258#M13288 ]

The Dropbox Java SDK contains a "sdk-version.txt" file with the version number for the SDK in it, e.g., for use in the User-Agent string. The error message you posted seems to indicate that this file wasn't found. I just verified that it is included in jar in the v3.0.3 release though.

Did you get the jars from the official dropbox-core-sdk-3.0.3 release here? If not, where did you download it from? I ask because the release includes "jackson-core-2.7.4.jar", but you mentioned "jackson-core-2.9.0.pr3.jar".

Also, can you make sure you added "dropbox-core-sdk-3.0.3.jar" and not "dropbox-core-sdk-3.0.3-sources.jar"?

@saurabhit49
Copy link
Author

Yes, i have included jar from official dropbox release. Yes you are right previously I had added "jackson-core-2.7.4.jar" from release. But after that i have included latest one by searching from internet version "jackson-core-2.9.0.pr3.jar". BTW, error is also same with 2.7.4 version.

Yes, i am sure that i have added "dropbox-core-sdk-3.0.3.jar" and not "dropbox-core-sdk-3.0.3-sources.jar" version.

@saurabhit49
Copy link
Author

test_dropbox_2.0.zip
I have spend some more time but no clue regarding error. So I have attached my sample project. It will be fine you will take a look with Eclipse IDE and let me know what is wrong with me.

I have replace my original key with "APP-KEY" keyword in Manifest and String.xml file.

@greg-db
Copy link
Contributor

greg-db commented Aug 31, 2017

I'm not set up for Android development in Eclipse unfortunately, as support for that ended some time ago, so I can't run that. Are you able to reproduce this with Android Studio?

(Also, we highly recommend using Gradle or Maven to manage your dependencies anyway. That's generally easier than manually managing the jar files, especial to keep them up to date over time. If you can, please try that instead and let us know if that helps.)

@tdtran
Copy link

tdtran commented Nov 17, 2017

I think there is a bug somewhere in Android Studio 3.0 (+ Android gradle plugin 3.0). The apk built by Android Studio when I hit "Run" does not have Java resource files merged correctly (Java resources, not Android res). I verified it by decompiling the apk. Java resource files, and not only those from Dropbox SDK lib, are not there. The apk file (both debug and release) built by running gradle on the command line is assembled correctly.

I haven't been able to pinpoint what exactly causes this bug in AS but I disabled both Instant Run and gradle daemon and that seems to make the problem go away.

@jacobras
Copy link

I experienced this as well, @tdtran. Build after build was made without any issues and all of a sudden the sdk-version.txt file was missing. Rebuilding and everything was fine again.

@jacobras
Copy link

This still occurs sometimes (once every 15 release builds I'd say), even when using the latest Dropbox SDK dependency from Gradle. The sdk-version.txt file simply isn't included in the APK upon inspection. @greg-db maybe you could look into this?

@greg-db
Copy link
Contributor

greg-db commented Aug 27, 2018

@jacobras Based on what tdtran tried, and the fact that is only occurs sporadically, it sounds like this is an issue in the build system, so I'm not sure if we'd be able to fix this on our side.

I can ask the team to investigate anyway, but we still haven't seen it occur in our testing. Is there any chance you could provide a small test project for Android Studio that does reproduce it? Thanks!

@guidedways
Copy link

This is a serious issue though, since as far as our build system is concerned, we're doing what we've always done in the past - build an apk and deploy. It's only when these reports started coming in from every other user that we realised it's broken. Saving the version in a .txt file is strange though - txt files aren't supposed to be bundled any way (I'd have thought) and if they are, that's pretty clumsy. Can you not embed that into a static variable in the source code instead?

@guidedways
Copy link

I should add I'm not using a jar file, I'm instead using the gradle dependency.

@guidedways
Copy link

guidedways commented Nov 28, 2018

I wonder if this is because of multi-dex support? Note that with multi-dex enabled (which we do) the actual source code may be in a different dex file, so /sdk-version.txt may point to nothing! This is why it's sporadic. You need to either put it into /res (or /META-INF?) or use a static variable instead. This approach is problematic and buggy.

@guidedways
Copy link

For those looking for an immediate fix:

  1. Download the SDK sources
  2. Open DbxSdkVersion.java and change line 35 to:

if (in == null) return "3.0.10"; // throw new LoadException("Not found.");

  1. Open Terminal and install these python libraries:

sudo -H python -m pip install ply six typing

  1. Follow steps on building the Dropbox SDK from sources
  2. Copy the .jar file into your project.

@jiuyangzhao
Copy link
Contributor

@guidedways Thanks a lot! I was thinking about the same thing. Can you submit a pull request?

@guidedways
Copy link

guidedways commented Nov 28, 2018

@jiuyangzhao would love to but I'd consider this a bit of a hack at this point, given you'd need to manually update the string each time you push a release. Could this not be automated to simply generate a string and update the version number in a .java file that gets included as part of the source code? At least then we'd certain be the SDK Version won't ever escape the code itself.

@jiuyangzhao
Copy link
Contributor

I agree but this is strictly better than what we have right now. I don't have any bandwidth developing SDK but I can live with update the code each time.

@guidedways
Copy link

@jiuyangzhao done :)

@chrisonline
Copy link

Any news about this?
I got now also this problem after using multidex.
Without multidex it is working.

@guidedways
Copy link

@chrisonline try my solution above

#140 (comment)

@chrisonline
Copy link

Thanks I have seen this.
But I don't want to compile this myself.
This should be fixed by Dropbox.

So I wonder why Dropbox does ignore this.
They can simple fix this.

@chrisonline
Copy link

chrisonline commented Apr 14, 2019

Seems the last version of Dropbox fixes this problem:
com.dropbox.core:dropbox-core-sdk:3.0.11

This version is not listed at the main page here. There is still 3.0.10

The commit who fixed this problem is:
b3a1e4f#diff-ec2dc95fa99e45aedc35e711a096a87e

@chrisonline
Copy link

@guidedways Your hacky commit is now also merged for the next version. I think this is not needed anymore after the 3.0.11 version.

@greg-db
Copy link
Contributor

greg-db commented Apr 15, 2019

Apologies, the Gradle instructions had an old version number. I just fixed that.

Anyway, yes, we have a workaround for this that will be in the next release.

@cakoose
Copy link
Contributor

cakoose commented Apr 15, 2019

@jiuyangzhao: It might be a good idea to revert the hard-coded version hack (040bc46).

The change that moved "sdk-version.txt" in a subdirectory (b3a1e4f) appears to have fixed the issue for @chrisonline, so there's a good chance it fixed the issue for everyone.

(If someone encounters the issue when using version 3.0.11 or later, then we can give up and use the hard-coded version hack :-)

@chrisonline
Copy link

@cakoose Yes I would remove the hard-coded version hack. I have tried it with 3.0.11 and mutlidex and all is working so far. The updated version with 3.0.11 is since yesterday live and no crashes so far anymore.

@greg-db
Copy link
Contributor

greg-db commented Apr 16, 2019

Thanks for the notes! cc/ @jiuyangzhao

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

9 participants