title: Android – custom fonts crash app
body: <p>I'm trying to change font of a TextView to a custom one. Have read <a href="https://stackoverflow.com/questions/5694163/custom-font-on-android">this other question</a> and tried instructions <a href="http://mobile.tutsplus.com/tutorials/android/customize-android-fonts/" rel="nofollow">as outlined here</a>. The font in question is Roboto Thin, downloaded straight from <a href="https://developer.android.com/design/style/typography.html" rel="nofollow">Android Design</a> and is in <strong>ttf</strong>.</p>
  
  <p>The code at the <strong>main activity class</strong> is as follows:</p>
  
  <pre><code>TextView txt  = (TextView) findViewById(R.id.hometext);                  
  Typeface font = Typeface.createFromAsset(getAssets(), "Roboto-Thin.ttf");       
  txt.setTypeface(font);
  
  // "hometext" is the TextView I wish to change font of.
  </code></pre>
  
  <p>App does not crash when the above 3 lines are commented, which I hope isolates the problem.</p>
  
  <p>Other etc info:</p>
  
  <ul>
  <li>Android 4.1.2 (API 16)</li>
  <li>testing on Android 4.4</li>
  </ul>
  
  <h3>EDIT:</h3>
  
  <p>Also tried "fonts/Roboto-Thin.ttf" and "assets/fonts/Roboto-Thin.ttf", both don't work.</p>
  
  <pre><code>01-17 22:38:29.086: D/AndroidRuntime(17774): Shutting down VM
  01-17 22:38:29.086: W/dalvikvm(17774): threadid=1: thread exiting with uncaught exception (group=0x415f4ba8)
  01-17 22:38:29.106: E/AndroidRuntime(17774): FATAL EXCEPTION: main
  01-17 22:38:29.106: E/AndroidRuntime(17774): Process: sp.com, PID: 17774
  01-17 22:38:29.106: E/AndroidRuntime(17774): java.lang.RuntimeException: Unable to start activity ComponentInfo{sp.com/sp.com.POSServices}: java.lang.RuntimeException: native typeface cannot be made
  01-17 22:38:29.106: E/AndroidRuntime(17774):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2195)
  01-17 22:38:29.106: E/AndroidRuntime(17774):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2245)
  01-17 22:38:29.106: E/AndroidRuntime(17774):    at android.app.ActivityThread.access$800(ActivityThread.java:135)
  01-17 22:38:29.106: E/AndroidRuntime(17774):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1196)
  01-17 22:38:29.106: E/AndroidRuntime(17774):    at android.os.Handler.dispatchMessage(Handler.java:102)
  01-17 22:38:29.106: E/AndroidRuntime(17774):    at android.os.Looper.loop(Looper.java:136)
  01-17 22:38:29.106: E/AndroidRuntime(17774):    at android.app.ActivityThread.main(ActivityThread.java:5017)
  01-17 22:38:29.106: E/AndroidRuntime(17774):    at java.lang.reflect.Method.invokeNative(Native Method)
  01-17 22:38:29.106: E/AndroidRuntime(17774):    at java.lang.reflect.Method.invoke(Method.java:515)
  01-17 22:38:29.106: E/AndroidRuntime(17774):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:779)
  01-17 22:38:29.106: E/AndroidRuntime(17774):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:595)
  01-17 22:38:29.106: E/AndroidRuntime(17774):    at dalvik.system.NativeStart.main(Native Method)
  01-17 22:38:29.106: E/AndroidRuntime(17774): Caused by: java.lang.RuntimeException: native typeface cannot be made
  01-17 22:38:29.106: E/AndroidRuntime(17774):    at android.graphics.Typeface.&lt;init&gt;(Typeface.java:175)
  01-17 22:38:29.106: E/AndroidRuntime(17774):    at android.graphics.Typeface.createFromAsset(Typeface.java:149)
  01-17 22:38:29.106: E/AndroidRuntime(17774):    at sp.com.POSServices.onCreate(POSServices.java:18)
  01-17 22:38:29.106: E/AndroidRuntime(17774):    at android.app.Activity.performCreate(Activity.java:5231)
  01-17 22:38:29.106: E/AndroidRuntime(17774):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1087)
  01-17 22:38:29.106: E/AndroidRuntime(17774):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2159)
  01-17 22:38:29.106: E/AndroidRuntime(17774):    ... 11 more
  </code></pre>