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

Event gravity does not take parameters or application crashs #136

Open
ASchmidt84 opened this issue Aug 27, 2015 · 9 comments
Open

Event gravity does not take parameters or application crashs #136

ASchmidt84 opened this issue Aug 27, 2015 · 9 comments

Comments

@ASchmidt84
Copy link

Hi

I want create a Layout. Using the converter I get this code:

contentView = new SVerticalLayout {
STextView("Large Text").<<.wrap.gravity(Gravity.CENTER_HORIZONTAL).>>.textAppearance(android.R.attr.textAppearanceLarge)
this += new SLinearLayout {}.visibility(View.VISIBLE).orientation(LinearLayout.HORIZONTAL)
SButton("New Button").<<.wrap.gravity(Gravity.CENTER_HORIZONTAL).>>
SButton("New Button").<<.wrap.gravity(Gravity.CENTER_HORIZONTAL).>>
SButton("New Button").<<.wrap.gravity(Gravity.CENTER_HORIZONTAL).>>
}.<<.fill.>>

but with this code I get this error
Int does not take parameters
[error] SButton("New Button").<<.wrap.gravity(Gravity.CENTER_HORIZONTAL).>>

If I change it to this

contentView = new SVerticalLayout { STextView("Large Text") textSize 24.dip this += new SLinearLayout{}.fill }

The app crashs.

What is the problem?

Thank you

@ASchmidt84
Copy link
Author

An error on using this code:

val tmp = new SVerticalLayout {
STextView("Large Text") textSize 24.dip
try{
this += linearLayout.<<(150 dip,MATCH_PARENT).>>.visibility(View.VISIBLE).orientation(LinearLayout.HORIZONTAL)
} catch {
case e => error("KOMISCH",e)
}
}

08-26 09:38:56.520 6836-6836/de.intelligyscience E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: de.intelligyscience, PID: 6836
java.lang.NoSuchMethodError: No virtual method error(Lscala/Function0;Ljava/lang/Throwable;Lorg/scaloid/common/LoggerTag;)V in class Lorg/scaloid/common/package$; or its super classes (declaration of 'org.scaloid.common.package$' appears in /data/app/de.intelligyscience-2/base.apk)
at de.intelligyscience.frontend.QuotationOverview$$anonfun$1$$anon$1.(QuotationOverview.scala:39)
at de.intelligyscience.frontend.QuotationOverview$$anonfun$1.apply(QuotationOverview.scala:34)
at de.intelligyscience.frontend.QuotationOverview$$anonfun$1.apply(QuotationOverview.scala:32)
at org.scaloid.common.SActivity$$anonfun$onCreate$1$$anonfun$apply$mcV$sp$1.apply(app.scala:144)
at org.scaloid.common.SActivity$$anonfun$onCreate$1$$anonfun$apply$mcV$sp$1.apply(app.scala:144)
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
at org.scaloid.common.SActivity$$anonfun$onCreate$1.apply$mcV$sp(app.scala:144)
at org.scaloid.common.SActivity$$anonfun$onCreate$1.apply(app.scala:144)
at org.scaloid.common.SActivity$$anonfun$onCreate$1.apply(app.scala:144)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
at org.scaloid.common.SActivity$class.onCreate(app.scala:143)
at de.intelligyscience.frontend.QuotationOverview.onCreate(QuotationOverview.scala:23)
at android.app.Activity.performCreate(Activity.java:5937)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

@ASchmidt84
Copy link
Author

Sorry this is the correct Exception

08-26 09:41:41.721 6893-6893/de.intelligyscience E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: de.intelligyscience, PID: 6893
java.lang.NoSuchMethodError: No virtual method $less$less(IILscala/Function1;)Lorg/scaloid/common/ViewGroupLayoutParams; in class Lorg/scaloid/common/SLinearLayout; or its super classes (declaration of 'org.scaloid.common.SLinearLayout' appears in /data/app/de.intelligyscience-1/base.apk)
at de.intelligyscience.frontend.QuotationOverview$$anonfun$1$$anon$1.(QuotationOverview.scala:36)
at de.intelligyscience.frontend.QuotationOverview$$anonfun$1.apply(QuotationOverview.scala:34)
at de.intelligyscience.frontend.QuotationOverview$$anonfun$1.apply(QuotationOverview.scala:32)
at org.scaloid.common.SActivity$$anonfun$onCreate$1$$anonfun$apply$mcV$sp$1.apply(app.scala:144)
at org.scaloid.common.SActivity$$anonfun$onCreate$1$$anonfun$apply$mcV$sp$1.apply(app.scala:144)
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
at org.scaloid.common.SActivity$$anonfun$onCreate$1.apply$mcV$sp(app.scala:144)
at org.scaloid.common.SActivity$$anonfun$onCreate$1.apply(app.scala:144)
at org.scaloid.common.SActivity$$anonfun$onCreate$1.apply(app.scala:144)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
at org.scaloid.common.SActivity$class.onCreate(app.scala:143)
at de.intelligyscience.frontend.QuotationOverview.onCreate(QuotationOverview.scala:23)
at android.app.Activity.performCreate(Activity.java:5937)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2251)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2360)
at android.app.ActivityThread.access$800(ActivityThread.java:144)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1278)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:135)
at android.app.ActivityThread.main(ActivityThread.java:5221)
at java.lang.reflect.Method.invoke(Native Method)
at java.lang.reflect.Method.invoke(Method.java:372)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:899)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:694)

@pocorall
Copy link
Owner

NoSuchMethodError frequently caused by misconfiguration of android-sbt-plugin.

Try clean rebuild. If it doesn't help, your build configuration of the plugin have some problem.

@AntoineMorand
Copy link

Hello,
I encountered a similar problem (see stacktrace below). I tried to follow your scaloid example installation instruction for intellij. Do i need to install android-sdk-plugin for sbt in addition? How can i make it work with the sbt plugin of intellij?

Thank you for the very handy framework you are providing!

09-04 09:12:03.258 7173-7173/scaloid.example E/AndroidRuntime﹕ FATAL EXCEPTION: main
Process: scaloid.example, PID: 7173
java.lang.NoSuchMethodError: org.scaloid.common.SButton.
at e_consult.activities.EConsult$$anonfun$1.apply(EConsult.scala:21)
at e_consult.activities.EConsult$$anonfun$1.apply(EConsult.scala:17)
at org.scaloid.common.SActivity$$anonfun$onCreate$1$$anonfun$apply$mcV$sp$1.apply(app.scala:144)
at org.scaloid.common.SActivity$$anonfun$onCreate$1$$anonfun$apply$mcV$sp$1.apply(app.scala:144)
at scala.collection.mutable.ResizableArray$class.foreach(ResizableArray.scala:59)
at scala.collection.mutable.ArrayBuffer.foreach(ArrayBuffer.scala:48)
at org.scaloid.common.SActivity$$anonfun$onCreate$1.apply$mcV$sp(app.scala:144)
at org.scaloid.common.SActivity$$anonfun$onCreate$1.apply(app.scala:144)
at org.scaloid.common.SActivity$$anonfun$onCreate$1.apply(app.scala:144)
at scala.util.DynamicVariable.withValue(DynamicVariable.scala:58)
at org.scaloid.common.SActivity$class.onCreate(app.scala:143)
at e_consult.activities.EConsult.onCreate(EConsult.scala:10)
at android.app.Activity.performCreate(Activity.java:5302)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1090)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2228)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2313)
at android.app.ActivityThread.access$1100(ActivityThread.java:141)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1238)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5336)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:865)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:681)
at dalvik.system.NativeStart.main(Native Method)

@AntoineMorand
Copy link

I don't know if it is related or may help to find a solution, but i also have a plenty of this kind of warnings:

09-04 09:46:40.268 7621-7621/scaloid.example I/dalvikvm﹕ Could not find method org.scaloid.common.TraitContext$class.startService, referenced from method e_consult.activities.EConsult.startService
09-04 09:46:40.268 7621-7621/scaloid.example W/dalvikvm﹕ VFY: unable to resolve static method 906: Lorg/scaloid/common/TraitContext$class;.startService (Lorg/scaloid/common/TraitContext;Lscala/reflect/ClassTag;Landroid/content/Context;)Landroid/content/ComponentName;
09-04 09:46:40.268 7621-7621/scaloid.example D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0006

@AntoineMorand
Copy link

Hello again,
I seem to have found the source of the problem: the number of methods is exceeding the single dex file size in android. My build console says:

[info] dex method count: 89552

Where the maximum is 65536.

In order to solve this problem, multidex file support must be enabled.
I found informations about this option in the official android documentation and android-sdk-plugin for sbt corresponding example.

In short, what you must do is adding the multidex library dependency to your project build.sbt and enable multidex:

libraryDependencies += "com.android.support" % "multidex" % "1.0.0"
dexMulti in Android := true

and add a android:name line to your androidmanifest.xml file:

  <application android:label="@string/app_name"
               android:name="android.support.multidex.MultiDexApplication">
          ...
  </application>

I hope it helps.

@AntoineMorand
Copy link

I encountered problems again on other elements. It seems that proguard cache prevents the proper multidex generation, so i commented the line:

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

and for now it seems to work.

@pocorall
Copy link
Owner

pocorall commented Sep 8, 2015

Great, thanks!

Although android-sdk-plugin is a great project I think, documentation is not so friendly. It often can be a barrier for newcomers. It would be much better if someone contribute a good tutorial. How about you, @AntoineMorand?

@AntoineMorand
Copy link

It is a good idea, even if I am no specialist, i could give it a try when I find time.

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