ClassNotFoundException when trying to access a View in a Library project

老子叫甜甜 提交于 2019-12-13 18:34:02

问题


I have a library project I'm importing in other project. When I try to compile it, console says this (in red):

[2012-07-11 13:12:53 - Library] Could not find Library.apk!

This library contains some custom Views, and when I try to access one of them, it gives me this a Java.lang.RuntimeException caused by a android.view.InflateException which at the same time is caused by a java.lang.ClassNotFoundException on the View class on the Library.

Does anybody know how to solve this?

Here is the LogCat output just in case.

07-11 13:12:53.899: E/AndroidRuntime(16995): FATAL EXCEPTION: main
07-11 13:12:53.899: E/AndroidRuntime(16995): java.lang.RuntimeException: Unable to start activity ComponentInfo{com.cidaut.fragment.manager/com.cidaut.fragment.manager.MainActivity}: android.view.InflateException: Binary XML file line #7: Error inflating class com.cidaut.viewpagerlibrary.TabPageIndicator
07-11 13:12:53.899: E/AndroidRuntime(16995):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2079)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2104)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at android.app.ActivityThread.access$600(ActivityThread.java:132)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1157)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at android.os.Handler.dispatchMessage(Handler.java:99)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at android.os.Looper.loop(Looper.java:137)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at android.app.ActivityThread.main(ActivityThread.java:4575)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at java.lang.reflect.Method.invokeNative(Native Method)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at java.lang.reflect.Method.invoke(Method.java:511)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:789)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:556)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at dalvik.system.NativeStart.main(Native Method)
07-11 13:12:53.899: E/AndroidRuntime(16995): Caused by: android.view.InflateException: Binary XML file line #7: Error inflating class com.cidaut.viewpagerlibrary.TabPageIndicator
07-11 13:12:53.899: E/AndroidRuntime(16995):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:691)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at android.view.LayoutInflater.rInflate(LayoutInflater.java:739)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:251)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at android.app.Activity.setContentView(Activity.java:1835)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at com.cidaut.fragment.manager.MainActivity.onCreate(MainActivity.java:17)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at android.app.Activity.performCreate(Activity.java:4465)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1049)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2033)
07-11 13:12:53.899: E/AndroidRuntime(16995):    ... 11 more
07-11 13:12:53.899: E/AndroidRuntime(16995): Caused by: java.lang.ClassNotFoundException: com.cidaut.viewpagerlibrary.TabPageIndicator
07-11 13:12:53.899: E/AndroidRuntime(16995):    at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:61)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at android.view.LayoutInflater.createView(LayoutInflater.java:552)
07-11 13:12:53.899: E/AndroidRuntime(16995):    at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:680)
07-11 13:12:53.899: E/AndroidRuntime(16995):    ... 21 more

回答1:


I had same problem ,now it's clear by the given action.

Please try Go to your project build path->order and export .Select you library files and press the buttons up,down. It will clear some confusion to get the library files .



来源:https://stackoverflow.com/questions/11431552/classnotfoundexception-when-trying-to-access-a-view-in-a-library-project

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!