This page is no longer maintained — Please continue to the home page at www.scala-lang.org

Potential solution for Scala 2.9.x dexopt failing

4 replies
Nathan Moos
Joined: 2012-01-09,
User offline. Last seen 42 years 45 weeks ago.

There is an article on Android Developers Blog about using multiple
DEX files in a single APK...if there was a way we could integrate the
procedure into SBT then we could completely avoid ProGuard!

Here's the article: http://android-developers.blogspot.com/2011/07/custom-class-loading-in-d...

Johannes Rudolph 2
Joined: 2010-02-12,
User offline. Last seen 42 years 45 weeks ago.
Re: Potential solution for Scala 2.9.x dexopt failing

The article explains how to load another dex file dynamically and
access the library classes through a well-defined interface _by
reflection_. It doesn't explain how to use this technique to develop a
complete app which depends on the library statically all the way down.

I think to make that work properly, you would have to change the way
in which Android loads and accesses classes referenced from the
AndroidManifest.xml or you would need proxies for all classes
mentioned in the manifest to load classes from the correct class
loader. Do you have an idea how to do that? I don't say it isn't
possible but you would have to solve this problem first before
thinking about an SBT solution.

Johannes

On Mon, Jan 9, 2012 at 4:14 PM, Nathan Moos wrote:
> There is an article on Android Developers Blog about using multiple
> DEX files in a single APK...if there was a way we could integrate the
> procedure into SBT then we could completely avoid ProGuard!
>
> Here's the article: http://android-developers.blogspot.com/2011/07/custom-class-loading-in-d...

Nathan Moos
Joined: 2012-01-09,
User offline. Last seen 42 years 45 weeks ago.
Re: Potential solution for Scala 2.9.x dexopt failing

Wouldn't it be possible to have a class that references every class in
the Scala library that we dynamically load with a Class.forName() call
which would force all the Scala classes to be loaded? Then the app's
main code is separated from that code and some sort of proxy is used
to call the main activity.

I think we really need to think about some way to accomplish this to
make Scala programming on Android a possibility because a DEX file
format change would be backwards-incompatible so it would make Scala
apps only compatible with a certain version of Android...

Nathan Moos

On Jan 9, 8:34 am, Johannes Rudolph
wrote:
> The article explains how to load another dex file dynamically and
> access the library classes through a well-defined interface _by
> reflection_. It doesn't explain how to use this technique to develop a
> complete app which depends on the library statically all the way down.
>
> I think to make that work properly, you would have to change the way
> in which Android loads and accesses classes referenced from the
> AndroidManifest.xml or you would need proxies for all classes
> mentioned in the manifest to load classes from the correct class
> loader. Do you have an idea how to do that? I don't say it isn't
> possible but you would have to solve this problem first before
> thinking about an SBT solution.
>
> Johannes
>
> On Mon, Jan 9, 2012 at 4:14 PM, Nathan Moos wrote:
> > There is an article on Android Developers Blog about using multiple
> > DEX files in a single APK...if there was a way we could integrate the
> > procedure into SBT then we could completely avoid ProGuard!
>
> > Here's the article:http://android-developers.blogspot.com/2011/07/custom-class-loading-i...
>
> --
> Johannes
>
> -----------------------------------------------
> Johannes Rudolphhttp://virtual-void.net

Simon Ochsenreither
Joined: 2011-07-17,
User offline. Last seen 42 years 45 weeks ago.
Re: Potential solution for Scala 2.9.x dexopt failing
Imho cutting down on the library size as it is already happening is the best way to go.

It might be possible to reduce the huge amounts of anonymous classes generated when Java 8 is released (probably earlier, as soon as the patches hit HotSpot).

Will be interesting to see what will happen on the Dalvik side, i. e. if people developing for Android are stuck with Java 5/6 forever.
Nathan Moos
Joined: 2012-01-09,
User offline. Last seen 42 years 45 weeks ago.
Re: Re: Potential solution for Scala 2.9.x dexopt failing

This is probably true, but again, in the interest of backwards compatibility, I think we should  develop a solution that works with Dalvik as it is now so we can develop Android apps with Scala 2.9.x. The APKs will be huge but we can solve that later. For now we need to solve the showstopper that makes it so we cannot develop serious Android apps with Scala.

Nathan Moos
Sophomore at Skyline High School, Granite Technical Institute
Salt Lake City, UT

Sent from my Android Gingerbread tablet

On Jan 9, 2012 6:25 PM, "Simon Ochsenreither" <simon [dot] ochsenreither [at] googlemail [dot] com> wrote:
Imho cutting down on the library size as it is already happening is the best way to go.

It might be possible to reduce the huge amounts of anonymous classes generated when Java 8 is released (probably earlier, as soon as the patches hit HotSpot).

Will be interesting to see what will happen on the Dalvik side, i. e. if people developing for Android are stuck with Java 5/6 forever.

Copyright © 2012 École Polytechnique Fédérale de Lausanne (EPFL), Lausanne, Switzerland