MediaBrowser / Emby.ApiClient.Java

ApiClient allows Java apps to easily access the Emby API
http://emby.media
MIT License
20 stars 22 forks source link

Convert project to Gradle build system.Fixes #13 #19

Closed RedshirtMB closed 8 years ago

RedshirtMB commented 8 years ago

Compiled with Idea and verified working.

There are no code changes in this commit, all the files were just moved into their appropriate places in the new project.

With Gradle, the build process should now be as simple as setting up your project framworks one time, then performing a Gradle sync in Android Studio or refresh in the Gradle tool window of Intellij-Idea.

Caveat

The android project is dependent on the apiclient project, every time a Gradle sync is run, the android project forgets that dependency and it needs to be re-added through the dependencies dialog. When the projects are on MavenCentral this won't be an issue as the dependency can be changed to a maven artifact and won't be forgotten on each Gradle sync. There must be a way to stop this from happening with the local dependency I just haven't found it.

LukePulverenti commented 8 years ago

Awesome, thanks. So if this repo is cloned fresh to a new directory will it build out of the box (aside from the caveat you mentioned)?

RedshirtMB commented 8 years ago

You bet. I unintentionally tested again earlier in the week due to replacing an SSD. On a fresh OS install, all I had to do was define the project SDK's, run a gradle sync and re-add the project dependency described in the caveat.

ebr11 commented 8 years ago

Trying to build this and getting an error that:

org.java_websocket.handshake.ServerHandshake does not exist...

RedshirtMB commented 8 years ago

Are you building in Android Studio or Idea? I prefer to use Idea since the apiclient is non-android. Once you download the source, you should just have to click refresh in the gradle projects fly-out on the right of the main window. Then add apiclient as a dependency to the apiclient.android project. Refresh will add all the Gradle dependencies to this window.

dependencies

ebr11 commented 8 years ago

I've only ever used Android Studio...

ebr11 commented 8 years ago

However, I'm no longer confident this is going to matter right now as my app will not run with your (Mark's) version of ApiClient either. Same crash I started getting with the last update that Luke attempted. It appears to be crashing on the first attempt at a network request. Roll back to my previous ApiClient and all is well.

I just got through updating all my framework references and target to 23 as well but it still fails to run. I have no idea why.

02-25 14:47:30.344 8707-8707/tv.emby.embyatv I/System.out: Response received from: http://192.168.1.120:8096/emby/system/info/public?format=json 02-25 14:47:39.753 8707-8716/tv.emby.embyatv I/art: Thread[5,tid=8716,WaitingInMainSignalCatcherLoop,Thread*=0xb8df7f78,peer=0x12c440a0,"Signal Catcher"]: reacting to signal 3 02-25 14:47:39.753 8707-8716/tv.emby.embyatv I/art: Suspending all threads for this process for HandleSigQuit 02-25 14:47:39.923 8707-8716/tv.emby.embyatv I/art: Resuming all threads for this process for HandleSigQuit 02-25 14:47:39.943 8707-8716/tv.emby.embyatv I/art: Wrote stack traces to '/data/anr/traces.txt'

LukePulverenti commented 8 years ago

As a test can you try targeting 22?

ebr11 commented 8 years ago

I can try. I was targeting 21 before and had this same problem.

LukePulverenti commented 8 years ago

Ok, or maybe even try 21 just to try and get as close to what was working as we possibly can, then upgrade from there.

ebr11 commented 8 years ago

I can't go back to 21 now I don't think. I just made a raft of changes due to upgrading framework elements. 21 is what I had before with this same problem though.

RedshirtMB commented 8 years ago

I think the crash your seeing is this.

api_error1

Given the timeframe that the crash started, I firmly believe that it's a result of one of the two connection date changing commits on Jan 14 or Jan 15.

If you uninstall the client and then push a fresh build to the device does it still crash?

RedshirtMB commented 8 years ago

as for the apiclient. I just deleted my local copy, cloned again and built using Android studio and I'm seeing problems with the build process. Android Studio is becoming so Android-only that it seems it's getting harder to build other project types. I'll look into that further and see what can be done.

ebr11 commented 8 years ago

Ahhh... yes, if I uninstall and then push a fresh version it works!

Okay, that doesn't help me much since we obviously cannot do that to deliver a new version but it does narrow the problem down to something within the ApiClient and whatever data it is reading from persistent storage...

RedshirtMB commented 8 years ago

That's why I think it's this commit https://github.com/MediaBrowser/Emby.ApiClient.Java/commit/1ff2907e690370bfd10829ab0c875aac93a12e61 or the one right after it. It's not handling the previously saved values properly.

ebr11 commented 8 years ago

The reverse is true as well. Can't go back to the previous ApiClient once this version has saved data as well. Need to clear it out first.

ebr11 commented 8 years ago

Luke, is this something you have an idea how to fix?

IOW - should I wait to put up a new beta of the app in hopes of getting an ApiClient update as well?

LukePulverenti commented 8 years ago

Yea I am going to have to rename the affected property. I'll have that for you tomorrow.

ebr11 commented 8 years ago

k. thx

LukePulverenti commented 8 years ago

All set, please try again, thanks.

ebr11 commented 8 years ago

Can you check the jar files into the repo please?

LukePulverenti commented 8 years ago

ok done. it's one jar now. that's what it defaulted to (i started fresh). i didn't bother to split them up like before.

ebr11 commented 8 years ago

Just for closure - all is good now with the ApiClient and TV app. I got it updated and put out a beta today.