Issue
I am trying to access a library that contains some strings and drawables. In my main project I add the library as a module. The problem is that when I want to reference in a layout to a string or a color resource, I can't. According to the guide of the API syntax, I use @[package.of.the.library]:type/resource_name, but this does not work.
I add an example of the layout that I use for testing:
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:mylibrary="http://schemas.android.com/apk/com.mylibrary.resources"
android:orientation="horizontal" android:layout_width="match_parent"
android:layout_height="wrap_content">
<TextView
android:layout_width="match_parent"
android:layout_height="match_parent"
android:text="@mylibrary:string/testing_text" />
</LinearLayout>
I have tried using xmlns:mylibrary="http://schemas.android.com/apk/res-auto"
instead of xmlns:mylibrary="http://schemas.android.com/apk/com.mylibrary.resources"
but it doesn't work.
Solution
You need to add compile project(":mylibrary")
to your app build.gradle file dependencies.
dependencies {
compile project(":mylibrary")
...rest of dependencies for project
}
Answered By - Joopkins
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.