These are chat archives for scala-android/sbt-android

23rd
Aug 2016
Perry
@pfn
Aug 23 2016 04:49
@Taig, something along the lines of wrap should be doable..
Rafal Wachol
@charafau
Aug 23 2016 06:27
@pfn viewholders looks great, too bad intellij has problem with it :(
ensime has different problem with it
dont know how to .value for <package>.TypedResource.ResString, create a TypedResValueOp[<package>.TypedResource.ResString] manually at line 15 col 62 where class is:
package com.nullpointerbay.androidtest

import android.app.Activity
import android.os.Bundle
import android.support.v7.app.AppCompatActivity
import android.graphics.drawable.Animatable

class MainActivity extends AppCompatActivity {
  // allows accessing `.value` on TR.resource.constants
  implicit val context = this

  override def onCreate(savedInstanceState: Bundle): Unit = {
    super.onCreate(savedInstanceState)
    val vh = TypedViewHolder.setContentView(this, TR.layout.main)
    vh.text.setText(s"Hello world, from ${TR.string.app_name.value}")
    vh.image.getDrawable match {
      case a: Animatable => a.start()
      case _ => // not animatable
    }
  }
}
Niklas Klein
@Taig
Aug 23 2016 06:37
@jhegedus42 @pfn I have no clue about the underlying mechanisms, and I don't know how incremental multidex came to be. So sorry for the confusion ;)
This might be cool for sbt-android as well if there is an established way to scaffold a new project: sbt/sbt#2705
jhegedus42
@jhegedus42
Aug 23 2016 07:08
ok, thanks
but somehow multidex seems to be pretty fast
faster than no multidex with proguard cache - it seems
Rafal Wachol
@charafau
Aug 23 2016 07:39
@jhegedus42 can you share results ?
jhegedus42
@jhegedus42
Aug 23 2016 07:53
ok
just a sec, just rebooted my mac... doing some network optimization to make transfer faster
Rafal Wachol
@charafau
Aug 23 2016 07:54
not in the hurry
like this
this is the bottleneck now
Rafal Wachol
@charafau
Aug 23 2016 07:57
I'm slowly moving to my linux on macbook ;)
jhegedus42
@jhegedus42
Aug 23 2016 07:58
aham...
u don't experience slow apk transfer?
Rafal Wachol
@charafau
Aug 23 2016 07:58
on OSX ?
yes I do
from what I've learned, osx is not good system
lacks many features
jhegedus42
@jhegedus42
Aug 23 2016 08:00
hmmm
i see
what is your solution for slow apk transfers ?
Rafal Wachol
@charafau
Aug 23 2016 08:01
but since they gave me macbook at work, I'm stuck with it
@jhegedus42 waiting :D
jhegedus42
@jhegedus42
Aug 23 2016 08:01
ohh
android:test
[info] Compiling 1 Scala source to /Users/joco/dev/android/scala/scala-android-playaround/target/android/intermediates/classes...
[warn] there was one deprecation warning; re-run with -deprecation for details
[warn] one warning found
[info] Packaging /Users/joco/dev/android/scala/scala-android-playaround/target/android/intermediates/classes.jar ...
[info] Done packaging.
[info] Generating dex, incremental=false, multidex=true
[info] dex method count: 1060
this took about 10 seconds
top
more like 5
Rafal Wachol
@charafau
Aug 23 2016 08:05
interesting
jhegedus42
@jhegedus42
Aug 23 2016 08:05
i mean, that is impressive
counted again, about 7 seconds
and 30 seconds to transfer the 11MB apk...
Rafal Wachol
@charafau
Aug 23 2016 08:06
:D
need to try on linu
x
jhegedus42
@jhegedus42
Aug 23 2016 08:07
android:test
[info] Compiling 1 Scala source to /Users/joco/dev/android/scala/scala-android-playaround/target/android/intermediates/classes...
[warn] there was one deprecation warning; re-run with -deprecation for details
[warn] one warning found
[info] Packaging /Users/joco/dev/android/scala/scala-android-playaround/target/android/intermediates/classes.jar ...
[info] Done packaging.
[info] Generating dex, incremental=false, multidex=true
[info] dex method count: 1060
[info] Packaged: scala-android-playaround-debug-unaligned.apk (11.08MB)
[info] Debug package does not need signing: scala-android-playaround-debug-unaligned.apk
[info] zipaligned: scala-android-playaround-debug.apk
[info] Installing to Android SDK built for x86_64 (emulator-5554)...
[info] [scala-android-playaround-debug.apk] Install finished: 11.08MB in 28.43s. 399.12KB/s
[info] Testing on Android SDK built for x86_64 (emulator-5554)...
[info] - testOne (com.mypackage.test.Tester)
[info] - testTwo (com.mypackage.test.Tester)
[info] - testDB (mypackage.test.plainSqlTest.PlainSQLTest)
[success] Total time: 39 s, completed Aug 23, 2016 11:06:29 AM
Rafal Wachol
@charafau
Aug 23 2016 08:07
yeah, that transfer
jhegedus42
@jhegedus42
Aug 23 2016 08:07
399.12KB/s
Rafal Wachol
@charafau
Aug 23 2016 08:08
did you check that performance tuning ?
jhegedus42
@jhegedus42
Aug 23 2016 08:08
yea
it helps a little
not much
maybe 10 seconds
or 15
it was 52 second total
or 59
Rafal Wachol
@charafau
Aug 23 2016 08:09
too long
jhegedus42
@jhegedus42
Aug 23 2016 08:09
now its 39
yeah
interesting coz speedtest says 100mbit download on the emulator....
Rafal Wachol
@charafau
Aug 23 2016 08:13
did you try genymotion ?
maybe it's adb problem..
jhegedus42
@jhegedus42
Aug 23 2016 08:13
hmm
ok
Rafal Wachol
@charafau
Aug 23 2016 08:17
[success] Total time: 31 s, completed Aug 23, 2016 5:17:46 PM
jhegedus42
@jhegedus42
Aug 23 2016 08:18
hmmm
slightly faster for you
Rafal Wachol
@charafau
Aug 23 2016 08:18
[success] Total time: 11 s, completed Aug 23, 2016 5:18:20 PM
second run, 8.6 mb
jhegedus42
@jhegedus42
Aug 23 2016 08:18
aham
much faster
Rafal Wachol
@charafau
Aug 23 2016 08:18
Install finished: 8.57MB in 6.46s. 1357.95KB/s
jhegedus42
@jhegedus42
Aug 23 2016 08:19
yeah
much better
is that linux?
Rafal Wachol
@charafau
Aug 23 2016 08:19
(osx, genymotion)
jhegedus42
@jhegedus42
Aug 23 2016 08:19
aham
geny
ok
Rafal Wachol
@charafau
Aug 23 2016 08:20
@pfn [info] dex method count: 798 this is the complete method count in apk ?
jhegedus42
@jhegedus42
Aug 23 2016 08:21
hmm
good question
when i switched to multidex it went down from 22k to 1k
Niklas Klein
@Taig
Aug 23 2016 08:22
Install finished: 16,11MB in 48,78s. 338,17KB/s
OS X to real device via usb
Rafal Wachol
@charafau
Aug 23 2016 08:23
that speed
Niklas Klein
@Taig
Aug 23 2016 08:24
However I think the output is somewhat misleading
jhegedus42
@jhegedus42
Aug 23 2016 08:24
hmmm
Niklas Klein
@Taig
Aug 23 2016 08:25
The install time is the big chunk
jhegedus42
@jhegedus42
Aug 23 2016 08:25
strange
Niklas Klein
@Taig
Aug 23 2016 08:25
Transferring is rather quick
jhegedus42
@jhegedus42
Aug 23 2016 08:25
ahh
i see
Niklas Klein
@Taig
Aug 23 2016 08:25
If you run adb install you'll get a better idea of that
jhegedus42
@jhegedus42
Aug 23 2016 08:25
ok
Niklas Klein
@Taig
Aug 23 2016 08:26
 % time adb install -r  app.apk
[100%] /data/local/tmp/app.apk
    pkg: /data/local/tmp/app.apk
Success
adb install -r app.apk  0,01s user 0,03s system 0% cpu 49,466 total
Transferring took ~2-3 seconds
Rafal Wachol
@charafau
Aug 23 2016 08:27
place for improvement ;)
jhegedus42
@jhegedus42
Aug 23 2016 08:27
hmmm
and install was slow...
maybe its time to give protify a try....
Rafal Wachol
@charafau
Aug 23 2016 08:28
protify is nice
Niklas Klein
@Taig
Aug 23 2016 08:28
I guess multidex drives up the install time, but I'm not even sure what Android is doing during that install phase
jhegedus42
@jhegedus42
Aug 23 2016 08:28
it does not have this install issues right ?
protify ?
Rafal Wachol
@charafau
Aug 23 2016 08:28
no
jhegedus42
@jhegedus42
Aug 23 2016 08:28
and works with multidex ?
Rafal Wachol
@charafau
Aug 23 2016 08:28
it should
jhegedus42
@jhegedus42
Aug 23 2016 08:28
ok
need to try it
jhegedus42
@jhegedus42
Aug 23 2016 08:43
geny is much faster
android:test
[info] Packaged: scala-android-playaround-debug-unaligned.apk (11.08MB)
[info] Debug package does not need signing: scala-android-playaround-debug-unaligned.apk
[info] zipaligned: scala-android-playaround-debug.apk
[info] Installing to Custom Phone - 5.0.0 - API 21 - 768x1280 (192.168.56.101:5555)...
[info] [scala-android-playaround-debug.apk] Install finished: 11.08MB in 11.99s. 946.16KB/s
[info] Testing on Custom Phone - 5.0.0 - API 21 - 768x1280 (192.168.56.101:5555)...
[info] - testOne (com.mypackage.test.Tester)
[info] - testTwo (com.mypackage.test.Tester)
[info] - testDB (mypackage.test.plainSqlTest.PlainSQLTest)
[success] Total time: 21 s, completed Aug 23, 2016 11:42:59 AM
Rafal Wachol
@charafau
Aug 23 2016 08:44
still, it should be faster
i mean... it's local host in virtualbox, c'mon
jhegedus42
@jhegedus42
Aug 23 2016 08:45
ohhh
virtualbox...
yeah
but maybe the install itself is slow
Rafal Wachol
@charafau
Aug 23 2016 08:46
probably, yes
jhegedus42
@jhegedus42
Aug 23 2016 08:46
how does protify work ?
is it some kind of clever hotswap ?
Rafal Wachol
@charafau
Aug 23 2016 08:48
yes
Perry
@pfn
Aug 23 2016 13:39
@charafau, it's supposed to be a total method count, protify messes with it (only shows agent count), multidex should give the correct number, but maybe there's a bug
@charafau, as for the problem with TR value, should work fine
Oh, ensime has a problem with TR value... that's dumb
@charafau, for intellij ascribe the type to the view holder and ignore the squiggly
Rafal Wachol
@charafau
Aug 23 2016 13:42
@pfn what do you mean by ascribe the type ?
val vh: TextView = ... ?
Perry
@pfn
Aug 23 2016 13:43
Oh, I messed up the sample, it should be val vh: TypedViewHolder.main = TypedViewHolder.setContentView...
Rafal Wachol
@charafau
Aug 23 2016 13:45
if I do this:
 val vh: TypedViewHolder.main = TypedViewHolder.setContentView(this, TR.layout.main)
    vh.text.setText(s"Hello world, from ${TR.string.app_name.value}")
    vh.image.getDrawable match {
      case a: Animatable => a.start()
      case _ => // not animatable
    }
Perry
@pfn
Aug 23 2016 13:46
you get an underline under the setContentView but everything otherwise behaves correctly
ah, in minsdk 21 multidex the method. count only includes app dex, it doesn't count library methods
Perry
@pfn
Aug 23 2016 14:01
which is the correct behavior imo
Rafal Wachol
@charafau
Aug 23 2016 14:06
then TypedViewHolder.setContentView(this, TR.layout.main) is underlined with red: expresion of type ev.VH doesnt conform to expected type TypedViewHolder.main
Perry
@pfn
Aug 23 2016 14:10
yeah, you ignore that
and I don't know why ensime doesn't understand the value call on the TR.string
thats a more trivial use of typeclasses
Rafal Wachol
@charafau
Aug 23 2016 14:19
well, but still there's an error
I know it works, I just dont like that there's syntax highlight error
Perry
@pfn
Aug 23 2016 14:28
can't be avoided until they fix the bug I. pointed out. above
Rafal Wachol
@charafau
Aug 23 2016 14:48
sure, i will ask them on gitter ;)
Rafal Wachol
@charafau
Aug 23 2016 18:07
@pfn is it possible to show all dex count in apk ? with libraries
Perry
@pfn
Aug 23 2016 18:58
someTask :=  {
  ((dex.value * "*.dex").get ++ (predex.value._2 * "*.dex" get)).map(Dex.dexMethodCount(_, streams.value.log)).sum
}
something like that should probably work
@charafau
Rafal Wachol
@charafau
Aug 23 2016 19:11
thank you
Perry
@pfn
Aug 23 2016 21:15
@Taig and just like magic it's there: pfn/iota@62ec271
ugh, github filters out markdown from commit messages, particularly ````
oops
I did commit -m "..." stupid shell
pfn/iota@0ca4135
Perry
@pfn
Aug 23 2016 21:47
@Taig
    case class Main(
        container: LinearLayout,
        ... snip ...
        ok: Button,
        cancel: Button
    ) extends ViewTree[LinearLayout] {
        container.setOrientation(LinearLayout.VERTICAL)

        private[this] val buttons = nest[LinearLayout](ok, cancel) {
          ok.lp(WRAP_CONTENT, WRAP_CONTENT, 1.0f)
          cancel.weight(0.5f)
        }.container
updated in the gist as well
with a new screenshot