Has anybody already got the Android app built locally?

Continuing the discussion from Spark Core and Android Application:

And now after having solved this puzzle I’m stuck with the next one.

The Spark app distributed via Google Play uses several typefaces in the Gotham family. If you have a license to these, you can place the following 4 files in SparkCore/assets/fonts.

Otherwise, in order to build a working app, you will need to either modify the app not to look for the fonts or put some other fonts in their place.

As I have not got the license for the gotham fonts I tried to replace them with a standard TTF.
For a quick try I copied the dull Arial.ttf into assets/fonts, altered the font_names.xml and the Typefaces.java accordingly and rebuilt the app - with no errors (just two warnings).
But when I run the app on my phone (Android 4.0.4) it immediately ends and the Eclipse log reports this:

02-12 21:50:12.444: E/ActivityThread(20268): Failed to inflate
02-12 21:50:12.444: E/ActivityThread(20268): android.view.InflateException: Binary XML file line #33: Error inflating class com.danh32.fontify.EditText
02-12 21:50:12.444: E/ActivityThread(20268): 	at android.view.LayoutInflater.createView(LayoutInflater.java:606)
02-12 21:50:12.444: E/ActivityThread(20268): 	at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
02-12 21:50:12.444: E/ActivityThread(20268): 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
02-12 21:50:12.444: E/ActivityThread(20268): 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
02-12 21:50:12.444: E/ActivityThread(20268): 	at android.view.LayoutInflater.rInflate(LayoutInflater.java:742)
02-12 21:50:12.444: E/ActivityThread(20268): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
02-12 21:50:12.444: E/ActivityThread(20268): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
02-12 21:50:12.444: E/ActivityThread(20268): 	at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
02-12 21:50:12.444: E/ActivityThread(20268): 	at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
02-12 21:50:12.444: E/ActivityThread(20268): 	at android.app.Activity.setContentView(Activity.java:1835)
02-12 21:50:12.444: E/ActivityThread(20268): 	at io.spark.core.android.ui.SignUpActivity.onCreate(SignUpActivity.java:84)

And a lot more.

@zachary, have you ever tried/succeeded building the app without the original fonts?
I’m using Eclipse Kepler under Windows 8.1 and can’t seem to get it working.

Once I’d have the standard app build an run on my device, I’d like to take a stab at an additional feature that I suggested in another thread
+ Dedicated RGB-LED-control with a color picker/color wheel (e.g. the cog wheel in the middle of the app)
+ Expose the RX/TX pins as digitalRead/digitalWrites pins, too - if not used as USART (as I think to recall, that they should be usable as digital pins)

I’d also rename the font_names-strings to something more general, if GOTHAM is not available.
BTW, is there a particular reason why Typeface.java does not use the strings out of font_names?
And why does Typeface.java reference italic fonts, where font_names.xml does not? Or italics used at all?

I know, this is not high priority since it’s not a Core problem as such, but any help would be appreciated greatly :wink:

I was able to build without the fonts, but the app would just immediately crash when installed on my phone. Definitely agree with you on all those changes — in particular the font business should be more modular. As you know, we wanted to get the source out there so others could tackle these problems, since working on the apps is nowhere near top priority fo us. As always pull requests are welcome.

If you replace the fonts, they might need to be OTFs.

Thanks @zachary,
the crash you experianced is the same as I have.
Since Fontify mentioned HELVETICA.ttf as example, I thought any TTF would do, but I’ll try to find an .OTF and see if this solves the problem for me.

I have not had any luck with compiling the Android App yet myself.

Using :

  • Android Developer Tools Eclipse Platform, fresh install, under Manjaro (Arch Linux based).
  • Clean checkout from the GitHub site.
  • The CC3000 Wi-Fi library file
  • Gothic Bold, Book, Light, and Medium .OTF font files

I get the following:

Process: io.spark.core.android, PID: 1368
java.lang.RuntimeException: Unable to start activity ComponentInfo{io.spark.core.android/io.spark.core.android.ui.SignUpActivity}: android.view.InflateException: Binary XML file line #33: Error inflating class com.danh32.fontify.EditText
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
at android.app.ActivityThread.access$800(ActivityThread.java:135)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:136)
at android.app.ActivityThread.main(ActivityThread.java:5017)
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:779)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #33: Error inflating class com.danh32.fontify.EditText
at android.view.LayoutInflater.createView(LayoutInflater.java:620)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:696)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:755)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:758)
at android.view.LayoutInflater.inflate(LayoutInflater.java:492)
at android.view.LayoutInflater.inflate(LayoutInflater.java:397)
at android.view.LayoutInflater.inflate(LayoutInflater.java:353)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:290)
at android.app.Activity.setContentView(Activity.java:1929)
at io.spark.core.android.ui.SignUpActivity.onCreate(SignUpActivity.java:84)
at android.app.Activity.performCreate(Activity.java:5231)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:423)
at android.view.LayoutInflater.createView(LayoutInflater.java:594)
... 24 more
Caused by: java.lang.RuntimeException: native typeface cannot be made
at android.graphics.Typeface.(Typeface.java:175)
at android.graphics.Typeface.createFromAsset(Typeface.java:149)
at com.danh32.fontify.FontManager.setFont(FontManager.java:41)
at com.danh32.fontify.FontManager.setFont(FontManager.java:32)
at com.danh32.fontify.EditText.(EditText.java:19)
... 27 more

I’m honestly not sure what’s up, other than what appears to be an issue with Fontify, or how it’s being used.
That and something possibly in the how the LayoutInflator class is being called.

I’d love to hear from anyone who’s had a success story in building this.

Hi @DanielBernard,
have you altered the above mentioned files to reflect the changed font file names?
As I have been cheeky and pulled the GOTHAM files from my running Spark app placed them in the fonts folder, the app actually did run.
So I tried as next step renaming the font files and changed “font_names.xml” and “Typefaces.java” accordingly to see if this made a difference, and the app still worked.
So my next step would be to try another set of free .ott files -> Edit: Other .otf worked find :smile:
And after that I’d try it with .ttf again - to narrow down where the root of my original problem was -> Edit: .ttf does crash the app :cry:

But in your case, just try modifying “font_names.xml” and “Typefaces.java” and alter gotham to gothic - mayby this works for you, too.

Thanks @ScruffR

I typed the filenames out incorrectly in the post, now that I’m looking at it, but truthfully, I forgot to edit the filenames of the .OTF files that I imported, so that’s part of the issue.
The second issue I had, is that I forgot to re-add the .OTF extension on the files after I renamed them through the Eclipse IDE.

Thanks so much for your help, the application launches now, and seems to work!

I got my first “showable” attempt here :wink:

Hi, after i changed the fonts file, when i build the project, it says Warning:(9, 49) java: android.widget android.widget.DigitalClock is outdated; and it says it cannot find smartconfiglib. But actually i have imported it in the libs already. The smarconfiglib.jar is only 12k right?And i did find something weird for this .jar, as other .jar files after click them, have two expanded folders but for smartconfiglib, there is no expansion folder at all. Where am i doing wrongly for import this lib? Thank you so much!

You can forget warnings for the moment, the project should still build and run.

When it says cannot find smartconfiglib, have checked that you have got it stored in the correct location (.\android-app\SparkCore\libs)? And does it show up in your Eclipse project?
For once you should see it under the libs branch of the SparkCore project and you should also have an entry under Android Private Libraries. Under this branch I do have two sub-branches META-INF and com.integrity_project.smartconfiglib.

When you create a copy of the smartconfiglib.jar, rename it into .zip and look into it, what have you got in there?

When i unzip the file and look into it, it does have all the files you mentioned about. I am sure i put the .jar under correct location but somehow it appears in the android studio without branches. And where is the Android Private Libraries you mentioned?

Hi, forgive my dumbness, i am using the android studio so adding a lib needs some additional steps. I’ve solved the problem, thank you so much!

Since you mentioned Eclipse before, I thought you’d still use it and this would be how the project explorer shows me it on my setup

But if you got it working, all’s good :wink:

Edit: Sorry, DanielBernard was using Eclipse - got a bit mixed up there :blush: