0

I am pulling data from a database, returning the values in an instance of a class. In my onCreate method of my Activity, I am setting the content view and then running the following code:

val thisObject:ClassCardJ = myDBAdapter.getAddressBookEntry(cardNum)
//val textFullName:String = (thisObject.getfName().toString() + " " + thisObject.getlName().toString())

val textFirstName:String = thisObject.getfName().toString()
val textLastName:String = thisObject.getlName().toString()
firstLine.setText(textFirstName)
Toast.makeText(AddressBookEntryActivity.this, thisObject.getlName().toString(), Toast.LENGTH_SHORT).show();

Which sets the firstLine text to the textFirstName value and displays a toast with the value that I am using in textLastName.

However, when I attempt to change the setText of the firstLine to textFullName (after uncommenting it), my program force closes. Am I doing something funny wrong??

As request, my logcat stack trace (I tried to include everything relevant and omit everything non-relevant):

I/ActivityManager(   67): Process com.android.email (pid 330) has died.
I/ActivityManager(   67): Starting: Intent { cmp=me.snapcard/.AddressBookActivity } from pid 393
I/ActivityManager(   67): Displayed me.snapcard/.AddressBookActivity: +589ms
I/ActivityManager(   67): Starting: Intent { cmp=me.snapcard/.AddressBookEntryActivity (has extras) } from pid 393
E/dalvikvm(  393): Could not find class 'scala.collection.mutable.StringBuilder', referenced from method me.snapcard.AddressBookEntryActivity.onCreate
W/dalvikvm(  393): VFY: unable to resolve new-instance 1148   (Lscala/collection/mutable/StringBuilder;) in Lme/snapcard/AddressBookEntryActivity;
D/dalvikvm(  393): VFY: replacing opcode 0x22 at 0x0050
D/dalvikvm(  393): VFY: dead code 0x0052-0091 in   Lme/snapcard/AddressBookEntryActivity;.onCreate (Landroid/os/Bundle;)V
D/AndroidRuntime(  393): Shutting down VM
W/dalvikvm(  393): threadid=1: thread exiting with uncaught exception (group=0x40015560)
E/AndroidRuntime(  393): FATAL EXCEPTION: main
E/AndroidRuntime(  393): java.lang.NoClassDefFoundError:   scala.collection.mutable.StringBuilder
E/AndroidRuntime(  393):    at   me.snapcard.AddressBookEntryActivity.onCreate(AddressBookEntryActivity.scala:40)
E/AndroidRuntime(  393):    at  android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1047)
E/AndroidRuntime(  393):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:1611)
E/AndroidRuntime(  393):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:1663)
E/AndroidRuntime(  393):    at android.app.ActivityThread.access$1500(ActivityThread.java:117)
E/AndroidRuntime(  393):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:931)
E/AndroidRuntime(  393):    at android.os.Handler.dispatchMessage(Handler.java:99)
E/AndroidRuntime(  393):    at android.os.Looper.loop(Looper.java:130)
E/AndroidRuntime(  393):    at android.app.ActivityThread.main(ActivityThread.java:3683)
E/AndroidRuntime(  393):    at java.lang.reflect.Method.invokeNative(Native Method)
E/AndroidRuntime(  393):    at java.lang.reflect.Method.invoke(Method.java:507)
E/AndroidRuntime(  393):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:839)
E/AndroidRuntime(  393):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:597)
E/AndroidRuntime(  393):    at dalvik.system.NativeStart.main(Native Method)
W/ActivityManager(   67):   Force finishing activity me.snapcard/.AddressBookEntryActivity
W/ActivityManager(   67):   Force finishing activity me.snapcard/.AddressBookActivity
W/ActivityManager(   67): Activity pause timeout for HistoryRecord{4082ce18 me.snapcard/.AddressBookEntryActivity}
I/dalvikvm(   67): Jit: resizing JitTable from 1024 to 2048
W/ActivityManager(   67): Launch timeout has expired, giving up wake lock!
4
  • 2
    Post your logcat stack trace. Commented Oct 24, 2011 at 6:29
  • But why don't you directly use firstLine.setText(thisObject.getfName().toString() + " " + thisObject.getlName().toString())? if you did,are you still getting error or so? Commented Oct 24, 2011 at 6:56
  • Yes, I am still getting an error when I do that. Looking at the logcat, it appears scala.collection.mutable.StringBuilder is somehow not being found which is probably responsible for building a string like that (and like the one that i have in the FullName variable). I have no clue if this is the reason why, or not. I'm hoping someone can shed some insight into this. Commented Oct 24, 2011 at 7:05
  • I actually worked around the problem by importing java.lang.StringBuilder and using a java based string builder to construct the string. I still don't know why I can't just do it how I have it. If someone does, please let me know!!! Commented Oct 24, 2011 at 7:06

1 Answer 1

1

Like you said, you used a StringBuilder. My suspicion is that your scala.collection.mutable object has encoding that does not allow smooth concatenation of its items. I strongly suggest you wrap the concatenated string (including just textFirstName and textLastName, if you're going to use them individually) in a Scala StringBuilder. If you would like to use the java.lang.StringBuilder, then you can convert a Scala StringBuilder by simply wrapping the Scala StringBuilder with the java.lang.Stringbuilder, which is detailed here. Hope that helped!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.