Jasonette / JASONETTE-Android

📡 Native App over HTTP, on Android
https://www.jasonette.com
Other
1.6k stars 270 forks source link

Add Stetho to allow debugging of network & ui #133

Closed maks closed 7 years ago

maks commented 7 years ago

Stetho allows debugging Android apps using the Chrome Developer tools. Given that Jasonette is heavily based on network and json usage, Chrome Dev tools is helpful for debugging.

gliechtenstein commented 7 years ago

@maks Thanks for the PR! Yes indeed this would be helpful!

But I have one concern, wouldn't including this into the app by default mean it would be packaged even into a release app?

I think that may increase the binary size.

Also while I haven't used stetho so just guessing based on the syntax, it looks like it's acting as a proxy, wouldn't this mean if we ship it to production with stetho included, the performance will suffer?

If this is the case maybe we could add a flag somewhere to turn this on and off? I have a feeling you know much more about stetho so looking forward to your thoughts.

maks commented 7 years ago

@gliechtenstein yes good point, this really should only be in debug builds, I'll fix that up so its not shipped in release APKs. Actually no I don't have much experience at all with Stetho (but a littel with DevTools) so thought it would be a good, easy starting point to help debugging. The main game for me is debugging JS properly within Jasonette but I'm still working on that.

maks commented 7 years ago

@gliechtenstein I've fixed the PR to only include Stetho in debug builds, using the technique provided in the Stetho repo's sample app (swapping out the Application singleton per diff build types using gradle).

gliechtenstein commented 7 years ago

WOW THIS IS CRAZY. https://twitter.com/jasonclient/status/885554141774446593

I feel like a stone age man having done all the debugging using Android studio until now. I don't know why we didn't have this until now.

BTW just to make sure i understand correctly, do i just need to set/reset the debuggable flag to true and false to switch back and forth? I've been trying to build an APK for both modes and looks like they generate the same file size, so wondering if i'm doing something wrong.

maks commented 7 years ago

@gliechtenstein sorry not nearly enough documentation from my end. I've used the same approach as in the stetho sample app, where stetho is only a gradle 'debugCompile' so its only included in the debug buildtype which is the default that Android Studio builds when you do "run app" (or ./gradlew installDebug on command line). To make that work there is a diff Application singleton class (DebugLauncher) in app/src/debug/java When you build a release build type (eg. for a signed apkl for google play) then stetho is not included by gradle in the apk.

We could use a flag liek debuggable to enable/disable running stetho, but then it would be included in release build APKs too - but maybe sounds like that is what you would like?

realitix commented 7 years ago

@maks @gliechtenstein Thanks to this pull request ans Stetho, it would help us to easily write tests for android Jasonette from what I understand.

maks commented 7 years ago

@realitix not so much for writing tests, but Stetho will be very useful I think for interactive debugging of Jasonette apps.

gliechtenstein commented 7 years ago

Ah i see, no I thought we had to manually enable/disable them every time.

I think this automated approach is much better. No need to add flags. Anyway, merged and merged!