I created a project for the main Android library in which I created a custom class of the form:
package com.my.android.library.layout;
public class CustomView extends View {
...
I also defined a style for mine CustomView:
<?xml version="1.0" encoding="utf-8"?>
<resources>
<declare-styleable name="CustomView">
<attr name="title_text" format="string" />
</declare-styleable>
</resources>
Since I do not want to share their source code with others who use my library project, so I created a project distributed library , where I added the jar above the main library in the folder libs/of the project distributed library and copied the entire life of the project the main library in the distributed library project .
NEXT, Android, . :
<RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
xmlns:custom="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="match_parent">
<com.my.android.library.layout.CustomView
custom:title_text = "THIS IS TITLE"
/>
<RelativeLayout>
, :
E/AndroidRuntime(30993): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.my.android.app/com.my.android.app.MainActivity}: android.view.InflateException: Binary XML file line
E/AndroidRuntime(30993): at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2071)
E/AndroidRuntime(30993): at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2096)
...
Caused by: java.lang.ClassNotFoundException: com.my.android.library.layout.CustomView
E/AndroidRuntime( 2947): at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
E/AndroidRuntime( 2947): at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
E/AndroidRuntime( 2947): at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
E/AndroidRuntime( 2947): at android.view.LayoutInflater.createView(LayoutInflater.java:552)
E/AndroidRuntime( 2947): at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
, CustomView xml. ? ?
( jar , CustomView. , Android .)