Note that there are some explanatory texts on larger screens.

plurals
  1. POIs it possible to use Scala jar library in _Android_ Java project?
    text
    copied!<p>Any "Use Scala on Android" tutorials I find only show to make a simple "Hello World" app. Has anyone actually succeeded in using a Scala library jar in a real life Android app?</p> <p>I tried to use goose library (<a href="https://github.com/GravityLabs/goose/" rel="nofollow">https://github.com/GravityLabs/goose/</a>) in my Android project. I built goose-2.1.22.jar from the sources fine. Inserted it into libs directory of my Android project, and added some code to test what will happen:</p> <pre><code>String url = "http://www.cnn.com/2010/POLITICS/08/13/democrats.social.security/index.html"; Configuration cfg = new Configuration(); Goose goose = new Goose(cfg); com.gravity.goose.Article article = goose.extractContent(url); String s = article.cleanedArticleText().toString(); </code></pre> <p>The project compiled fine, no complains. When I try to run it though, I get an exception:</p> <pre><code>java.lang.NoClassDefFoundError: com.gravity.goose.Configuration </code></pre> <p>A little bit better after adding scala-for-android.jar to libs form "Scala for Android" project, or scala-library.jar from the latest stable Scala - then I get:</p> <pre><code> java.lang.ExceptionInInitializerError at com.gravity.goose.Configuration.&lt;init&gt;(Configuration.scala:77) at com.hyperionics.ScalaTest.TestActivity$1.onClick(TestActivity.java:31) </code></pre> <p>Is there some trick to make it work?</p> <hr> <p><strong>More information:</strong> the crash is in Configuration.scala file of goose, on exactly this line:</p> <pre><code>var contentExtractor: ContentExtractor = StandardContentExtractor </code></pre> <p>I added <em>all</em> the jars from Scala distribution lib directory to my project after a period of testing, but there is no difference, same crash. Also found "Scala for Android" project at <a href="http://code.google.com/p/scalaforandroid/" rel="nofollow">http://code.google.com/p/scalaforandroid/</a> and added it's jars instead of the ones from standard Scala distro, no difference. To compile my project and go around the error "Android Dex: Too meny methods ..." I had to use DexGuard, as with Proguard again I was getting weird errors.</p> <p>Any more tips on how to make this work would be much appreciated!</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload