Calligraphy icon indicating copy to clipboard operation
Calligraphy copied to clipboard

fontPath missing in library project

Open sudeeps-r opened this issue 8 years ago • 7 comments

Am developing an android library project with the help of Calligraphy but when I try to use the my aar file the hosting app throws following error .

Error:(4134, 21) No resource found that matches the given name: attr 'fontPath'.

Am using using fontPath in styles as well as in xml.

sudeeps-r avatar Feb 21 '17 13:02 sudeeps-r

Having the same issue. Did you please come up with something?

andrejbroncek avatar Mar 12 '17 15:03 andrejbroncek

You will need to give way more information about how you include your library project - I use Calligraphy in library projects with no problems.

chrisjenx avatar Apr 04 '17 17:04 chrisjenx

Did you include the library?

erickssonxD avatar Oct 13 '17 20:10 erickssonxD

I initially wrote a simple app. I converted that to library using by following the steps here.

I was able to build .aar using Gradle -> Module -> Tasks -> assembleRelease Copied the aar from app -> build -> outputs -> aar -> app-release.aar.

When I add this aar to my new app's lib folder and sync gralde files, I get this error

Error:(29, 5) error: style attribute 'attr/fontPath' not found.

mayuroks avatar Dec 12 '17 17:12 mayuroks

Include the library by maven. Why are you manually including the aar?

On Tue, 12 Dec 2017 at 10:53 Mayur Rokade [email protected] wrote:

I initially wrote a simple app. I converted that to library using by following the steps here https://developer.android.com/studio/projects/android-library.html.

I was able to build .aar using Gradle -> Module -> Tasks -> assembleRelease Copied the aar from app -> build -> outputs -> aar -> app-release.aar.

When I add this aar to my new app's lib folder and sync gralde files, I get this error

Error:(29, 5) error: style attribute 'attr/fontPath' not found.

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/chrisjenx/Calligraphy/issues/370#issuecomment-351131242, or mute the thread https://github.com/notifications/unsubscribe-auth/ABHRsfv-UTGMu71yOsojl4KPYmbH4_W_ks5s_r2hgaJpZM4MHTtN .

chrisjenx avatar Dec 12 '17 17:12 chrisjenx

@chrisjenx The aar library is an internal-use-only library to be used by a handful of people. So we can't distribute it via a public repo.

As of now, we have setup a self hosted Nexus repo manager to distribute the aar. Now even after downloading the aar from nexus, I get the above error.

We have solved it for now by creating a BaseApplication.java for every app that imports the aar.

public class BaseApplication extends Application {
    @Override
    protected void attachBaseContext(Context newBase) {
        super.attachBaseContext(CalligraphyContextWrapper.wrap(newBase));
    }

    @Override
    public void onCreate() {
        super.onCreate();
        CalligraphyConfig.initDefault(new CalligraphyConfig.Builder()
                                .setDefaultFontPath("fonts/Roboto-RobotoRegular.ttf")
                                .setFontAttrId(R.attr.fontPath)
                                .build()
    }
}

This solution is not clean but it's functional.

mayuroks avatar Dec 15 '17 17:12 mayuroks

  1. https://stackoverflow.com/a/34919810/803225
  2. do not attachBaseContext in Application class, you with break your theming and or it wont work.

chrisjenx avatar Dec 15 '17 18:12 chrisjenx