Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compile error with IntelliJ 14 / Android SDK 21 #12

Open
aguestuser opened this issue Jan 5, 2015 · 4 comments
Open

Compile error with IntelliJ 14 / Android SDK 21 #12

aguestuser opened this issue Jan 5, 2015 · 4 comments

Comments

@aguestuser
Copy link

I get a Progaurd-related dependency warning upon importing and a ridiculously low-level compile error upon trying to compile or run. Two of my coworkers with similar stacks reproduced the error with the same error message and stack trace.

My specific steps were as follows:

  • cloned the project repo to a local folder
  • ran android update project -p . in the project root
  • imported the project into IntelliJ
  • got dependency warning (pasted below)
  • changed before-launch setting as per instructions
  • double checked JDK & project SDK settings
  • tried to compile
  • got compile error (pasted below)

(Incidentally, I can compile successfully and generate a working .adk by running sbt android:package from the project root.)

I am running:

  • OS X 10.0
  • JDK 1.7.0_71
  • Scala 2.11.4
  • SBT 0.13
  • IntelliJ 14.0.2 with:
    • Scala plugin 1.2.1
    • SBT plugin 1.6.1
  • Android SDK at API level 21, with the following installed:
    • Android SDK Tools 24.0.2
    • Android SDK Platform-tools 21
    • Android SDK Build-tools 21.1.2

When I import the project, I get the following warnings:

4:48:18 PM SBT project import
           [warn] There may be incompatibilities among your library dependencies.
           [warn] Here are some of the libraries that were evicted:
           [warn]     * net.sf.proguard:proguard-base:4.11 -> 5.0
           [warn] Run 'evicted' to see detailed eviction warnings

When I try to compile I get the following error message and stack trace:

Information:1/5/15, 4:50 PM - Compilation completed with 2 errors and 0 warnings in 2 sec

Error:scalac: error while loading Object, Missing dependency 'object scala in compiler mirror', required by /Users/aguestuser/Library/Android/sdk/platforms/android-21/android.jar(java/lang/Object.class)

Error:scalac: Error: object scala in compiler mirror not found.
scala.reflect.internal.MissingRequirementError: object scala in compiler mirror not found.
    at scala.reflect.internal.MissingRequirementError$.signal(MissingRequirementError.scala:17)
    at scala.reflect.internal.MissingRequirementError$.notFound(MissingRequirementError.scala:18)
    at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:53)
    at scala.reflect.internal.Mirrors$RootsBase.getModuleOrClass(Mirrors.scala:66)
    at scala.reflect.internal.Mirrors$RootsBase.getPackage(Mirrors.scala:173)
    at scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackage$lzycompute(Definitions.scala:161)
    at scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackage(Definitions.scala:161)
    at scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackageClass$lzycompute(Definitions.scala:162)
    at scala.reflect.internal.Definitions$DefinitionsClass.ScalaPackageClass(Definitions.scala:162)
    at scala.reflect.internal.Definitions$DefinitionsClass.init(Definitions.scala:1388)
    at scala.tools.nsc.Global$Run.<init>(Global.scala:1053)
    at xsbt.CachedCompiler0$$anon$2.<init>(CompilerInterface.scala:116)
    at xsbt.CachedCompiler0.run(CompilerInterface.scala:116)
    at xsbt.CachedCompiler0.run(CompilerInterface.scala:102)
    at xsbt.CompilerInterface.run(CompilerInterface.scala:27)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at sbt.compiler.AnalyzingCompiler.call(AnalyzingCompiler.scala:102)
    at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:48)
    at sbt.compiler.AnalyzingCompiler.compile(AnalyzingCompiler.scala:41)
    at org.jetbrains.jps.incremental.scala.local.IdeaIncrementalCompiler.compile(IdeaIncrementalCompiler.scala:29)
    at org.jetbrains.jps.incremental.scala.local.LocalServer.compile(LocalServer.scala:26)
    at org.jetbrains.jps.incremental.scala.remote.Main$.make(Main.scala:62)
    at org.jetbrains.jps.incremental.scala.remote.Main$.nailMain(Main.scala:20)
    at org.jetbrains.jps.incremental.scala.remote.Main.nailMain(Main.scala)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.martiansoftware.nailgun.NGSession.run(NGSession.java:319)

This is what my build.sbt file looks like:

import android.Keys._

android.Plugin.androidBuild

name := "hello-scaloid-sbt"

scalaVersion := "2.11.4"

proguardCache in Android ++= Seq(
                                 ProguardCache("org.scaloid") % "org.scaloid"
                                              )

proguardOptions in Android ++= Seq("-dontobfuscate", "-dontoptimize", "-keepattributes Signature", "-printseeds target/seeds.txt", "-printusage target/usage.txt"
                                   , "-dontwarn scala.collection.**" // required from Scala 2.11.4
                                     )

libraryDependencies += "org.scaloid" %% "scaloid" % "3.6.1-10" withSources() withJavadoc()

scalacOptions in Compile += "-feature"

run <<= run in Android

install <<= install in Android

This is what my progaurd.sbt.txt file looks like:

# This is a configuration file for ProGuard.
# http://proguard.sourceforge.net/index.html#manual/usage.html

-dontusemixedcaseclassnames
-dontskipnonpubliclibraryclasses
-verbose

# Optimization is turned off by default. Dex does not like code run
# through the ProGuard optimize and preverify steps (and performs some
# of these optimizations on its own).
-dontoptimize
-dontpreverify
# Note that if you want to enable optimization, you cannot just
# include optimization flags in your own project configuration file;
# instead you will need to point to the
# "proguard-android-optimize.txt" file instead of this one from your
# project.properties file.

-keepattributes *Annotation*
-keep public class com.google.vending.licensing.ILicensingService
-keep public class com.android.vending.licensing.ILicensingService

# For native methods, see http://proguard.sourceforge.net/manual/examples.html#native
-keepclasseswithmembernames class * {
    native <methods>;
}

# keep setters in Views so that animations can still work.
# see http://proguard.sourceforge.net/manual/examples.html#beans
-keepclassmembers public class * extends android.view.View {
   void set*(***);
   *** get*();
}

# We want to keep methods in Activity that could be used in the XML attribute onClick
-keepclassmembers class * extends android.app.Activity {
   public void *(android.view.View);
}

# For enumeration classes, see http://proguard.sourceforge.net/manual/examples.html#enumerations
-keepclassmembers enum * {
    public static **[] values();
    public static ** valueOf(java.lang.String);
}

-keep class * implements android.os.Parcelable {
  public static final android.os.Parcelable$Creator *;
}

-keepclassmembers class **.R$* {
    public static <fields>;
}

# The support library contains references to newer platform versions.
# Don't warn about those in case this app is linking against an older
# platform version.  We know about them, and they are safe.
-dontwarn android.support.**
@pocorall
Copy link
Owner

The error message you posted is definitely the compiler cannot find android library.

You posted detailed configuration, but I am not clear that you set the launch configuration properly:

https://github.com/pocorall/hello-scaloid-sbt#import-the-sbt-project

Especially in this part:

Edit the generated run configuration. Remove the 'Before launch: Make' then add a new SBT command android:package-debug then tab out or it will not save, then click OK then OK.

If you succeed to build and launch with sbt ~run command, it is also a good idea to use command-line sbt.

@aguestuser
Copy link
Author

@pocorall very reassuring someone can pin down the cause of the compile error!

sadly, i'm not sure the suggestion about launch configurations gets me anywhere. i followed the instructions to replace Make with the android-package-debug command, and have confirmed a few times that i did so according to the instructions.

are there any other things that could be causing this? any output i could examine or share that would help pinpoint the problem? perhaps something about the new lolipop sdk doesn't play nice with scaloid dependencies?

also, as to using command-line sbt, my workflow (testing, docs, typechecking, etc..) is all tied to intellij, so ditching it is a possible but highly undesirable solution. given that i've got a couple other folks who want to also use scaloid in intellij and are hitting the same issue, it seems like a substantial enough use case to try to drill down on and solve for all of us.

(that anyway is my thinking on why it's worth my personal time trying to pursue the problem despite an intractable impasse. you of course should use your time however you see best fit! :))

/a/

@szymonwartak
Copy link

@pocorall I am having the same error and I checked that the android library is on the bootclasspath in compiler options. @aguestuser , what was your resolution?

@pocorall
Copy link
Owner

pocorall commented Jan 8, 2016

In your first posting,

tried to compile

How did you compile it?

Just Run the project [Shift + F10] is enough, if you setup the sbt task properly in Run/Debug Configurations dialog.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants