fontPath missing in library project
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.
Having the same issue. Did you please come up with something?
You will need to give way more information about how you include your library project - I use Calligraphy in library projects with no problems.
Did you include the library?
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.
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 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.
- https://stackoverflow.com/a/34919810/803225
- do not attachBaseContext in Application class, you with break your theming and or it wont work.