Tried everything but still get "native typeface cannot be made"

196 views Asked by At

In an app I am building, I'd like to use the standard Apple font: Myriad Pro. To do this, I've tried the normal way of using a custom font:

Typeface myriadPro = Typeface.createFromAsset(getAssets(), "fonts/myriad_pro.ttf");

And the workaround for an issue that Android sometimes has with fonts as discussed here:

public class Typefaces {
private static final String TAG = "Typefaces";

private static final Hashtable<String, Typeface> cache = new Hashtable<String, Typeface>();

public static Typeface get(Context c, String assetPath) {
    synchronized (cache) {
        if (!cache.containsKey(assetPath)) {
            try {
                Typeface t = Typeface.createFromAsset(c.getAssets(),
                        assetPath);
                cache.put(assetPath, t);
            } catch (Exception e) {
                Log.e(TAG, "Could not get typeface '" + assetPath
                        + "' because " + e.getMessage());
                return null;
            }
        }
        return cache.get(assetPath);
    }
}
}

I've tried both methods with the OTF and the TTF versions of the font. None of the variations work. In all cases I get the native typeface cannot be made error (i.e. it can't find the typeface), even though the typeface is in the right place with the right name.

Any ideas what's still causing this error to occur?

1

There are 1 answers

2
AudioBubble On

I had the same problem.

Go to the AndroidManifest.xml.

minSdkVersion MUST be 10 or higher.