我正在尝试使用此处找到的cardslib库https://github.com/gabrielemariotti/cardslib。我很难将这个添加到我的项目中,并且我唯一可以弄清楚如何将文件复制并粘贴到我的项目中,并更改所有包名以匹配我的项目。问题是在运行时期间会生成以下错误:
java.lang.RuntimeException: Unable to start activity ComponentInfo{com.nick.simplequiz.paid/com.nick.simplequiz.paid.statistics}: android.view.InflateException: Binary XML file line #39: Error inflating class com.nick.simplequiz.paid.view.CardView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2463)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2520)
at android.app.ActivityThread.access$600(ActivityThread.java:162)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1366)
at android.os.Handler.dispatchMessage(Handler.java:99)
at android.os.Looper.loop(Looper.java:158)
at android.app.ActivityThread.main(ActivityThread.java:5751)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:511)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1083)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:850)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #39: Error inflating class com.nick.simplequiz.paid.view.CardView
at android.view.LayoutInflater.createView(LayoutInflater.java:613)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at android.view.LayoutInflater.inflate(LayoutInflater.java:352)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:342)
at android.app.Activity.setContentView(Activity.java:1929)
at com.nick.simplequiz.paid.statistics.onCreate(statistics.java:41)
at android.app.Activity.performCreate(Activity.java:5165)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1103)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2419)
... 11 more
Caused by: java.lang.reflect.InvocationTargetException
at java.lang.reflect.Constructor.constructNative(Native Method)
at java.lang.reflect.Constructor.newInstance(Constructor.java:417)
at android.view.LayoutInflater.createView(LayoutInflater.java:587)
... 22 more
Caused by: android.view.InflateException: Binary XML file line #57: Error inflating class com.nick.simplequiz.paid.component.CardShadowView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:698)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:746)
at android.view.LayoutInflater.inflate(LayoutInflater.java:489)
at android.view.LayoutInflater.inflate(LayoutInflater.java:396)
at com.nick.simplequiz.paid.view.BaseCardView.initView(BaseCardView.java:153)
at com.nick.simplequiz.paid.view.BaseCardView.init(BaseCardView.java:125)
at com.nick.simplequiz.paid.view.BaseCardView.<init>(BaseCardView.java:101)
at com.nick.simplequiz.paid.view.CardView.<init>(CardView.java:172)
... 25 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.nick.simplequiz.paid.component.CardShadowView" on path: /data/app/com.nick.simplequiz.paid-1.apk
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:65)
at java.lang.ClassLoader.loadClass(ClassLoader.java:501)
at java.lang.ClassLoader.loadClass(ClassLoader.java:461)
at android.view.LayoutInflater.createView(LayoutInflater.java:552)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:687)
这是xml,我相信它有问题:
<com.nick.simplequiz.paid.view.CardView //starting here
android:id="@+id/carddemo"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginLeft="12dp"
android:layout_marginRight="12dp"
android:layout_marginTop="12dp"/>
我不明白导致错误的是什么,我已经验证所有类都被正确复制和重命名,但我不确定还有什么可以尝试。任何建议都表示赞赏。
答案 0 :(得分:0)
错误来自不正确的依赖,我知道你说你检查了它但它仍然无法找到它,我会尝试按照作者的指示并尝试修改maven构建文件或者这可能就是许多错误中的第一个
答案 1 :(得分:0)
开始使用此项目所需的唯一步骤是在build.gradle文件中添加gradle依赖项(目录树中最低)。
dependencies {
compile 'com.github.gabrielemariotti.cards:library:1.7.3'
}