首先安装应用程序崩溃,但重新安装后它工作

时间:2015-10-30 12:12:35

标签: android

到目前为止,我从未遇到过如此奇怪的问题。 该应用程序编译好。但是在第一次运行时它会在测试设备上崩溃,但如果项目被清理并重新运行,那么应用程序运行正常。 如果我尝试安装apk,结果是一样的:安装应用程序崩溃但重新安装后运行正常。

问题出现在我的所有测试设备上以及Eclipss和Android Studio下。我花了很多时间才找到类似的案例但没有用。 该应用程序的先前版本工作正常,但如果我将文件还原到早期版本,问题仍然存在。

Caused by: java.lang.ClassNotFoundException: Didn't find class "com.plexnor.android.good.ViewfinderView" on path: DexPathList[[zip file "/data/app/com.plexnor.android.good-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.plexnor.android.good-1, /vendor/lib, /system/lib]]

我猜测项目设置出了问题,但找不到罪魁祸首。删除bin文件夹,进行无数次项目清理和重启不会导致任何问题......

完整堆栈跟踪:

java.lang.RuntimeException: Unable to start activity ComponentInfo{com.plexnor.android.good/com.plexnor.android.good.CaptureActivity}: android.view.InflateException: Binary XML file line #17: Error inflating class com.plexnor.android.good.ViewfinderView
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2425)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483)
at android.app.ActivityThread.access$900(ActivityThread.java:171)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1297)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5506)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
Caused by: android.view.InflateException: Binary XML file line #17: Error inflating class com.plexnor.android.good.ViewfinderView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.inflate(LayoutInflater.java:463)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:359)
at android.app.Activity.setContentView(Activity.java:2010)
at com.plexnor.android.good.CaptureActivity.onCreate(SourceFile:317)
at android.app.Activity.performCreate(Activity.java:5426)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2389)
... 11 more
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.plexnor.android.good.ViewfinderView" on path: DexPathList[[zip file "/data/app/com.plexnor.android.good-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.plexnor.android.good-1, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.view.LayoutInflater.createView(LayoutInflater.java:565)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
... 22 more
android.view.InflateException: Binary XML file line #17: Error inflating class com.plexnor.android.good.ViewfinderView
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:713)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.inflate(LayoutInflater.java:463)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:359)
at android.app.Activity.setContentView(Activity.java:2010)
at com.plexnor.android.good.CaptureActivity.onCreate(SourceFile:317)
at android.app.Activity.performCreate(Activity.java:5426)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2389)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483)
at android.app.ActivityThread.access$900(ActivityThread.java:171)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1297)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5506)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.plexnor.android.good.ViewfinderView" on path: DexPathList[[zip file "/data/app/com.plexnor.android.good-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.plexnor.android.good-1, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.view.LayoutInflater.createView(LayoutInflater.java:565)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
... 22 more
java.lang.ClassNotFoundException: Didn't find class "com.plexnor.android.good.ViewfinderView" on path: DexPathList[[zip file "/data/app/com.plexnor.android.good-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.plexnor.android.good-1, /vendor/lib, /system/lib]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:67)
at java.lang.ClassLoader.loadClass(ClassLoader.java:497)
at java.lang.ClassLoader.loadClass(ClassLoader.java:457)
at android.view.LayoutInflater.createView(LayoutInflater.java:565)
at android.view.LayoutInflater.createViewFromTag(LayoutInflater.java:702)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:761)
at android.view.LayoutInflater.rInflate(LayoutInflater.java:769)
at android.view.LayoutInflater.inflate(LayoutInflater.java:463)
at android.view.LayoutInflater.inflate(LayoutInflater.java:398)
at android.view.LayoutInflater.inflate(LayoutInflater.java:354)
at com.android.internal.policy.impl.PhoneWindow.setContentView(PhoneWindow.java:359)
at android.app.Activity.setContentView(Activity.java:2010)
at com.plexnor.android.good.CaptureActivity.onCreate(SourceFile:317)
at android.app.Activity.performCreate(Activity.java:5426)
at android.app.Instrumentation.callActivityOnCreate(Instrumentation.java:1105)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2389)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:2483)
at android.app.ActivityThread.access$900(ActivityThread.java:171)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1297)
at android.os.Handler.dispatchMessage(Handler.java:102)
at android.os.Looper.loop(Looper.java:157)
at android.app.ActivityThread.main(ActivityThread.java:5506)
at java.lang.reflect.Method.invokeNative(Native Method)
at java.lang.reflect.Method.invoke(Method.java:515)
at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:1265)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1081)
at dalvik.system.NativeStart.main(Native Method)

编辑1: 在处理布局时,即使进入主活动,应用程序也会更早崩溃。 布局的开始:

<?xml version="1.0" encoding="UTF-8"?>
<merge xmlns:android="http://schemas.android.com/apk/res/android" >

    <SurfaceView
        android:id="@+id/preview_view"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent" />

    <RelativeLayout
        android:id="@+id/relative_layout_main"
        android:layout_width="fill_parent"
        android:layout_height="fill_parent"
        android:layout_marginBottom="0dp"
        android:layout_marginTop="0dp" >

        <RelativeLayout
            android:id="@+id/learning_swipe_relative_layout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentLeft="true"
            android:layout_alignParentBottom="true"
            android:background="@android:color/transparent" >

            <ImageView
                android:id="@+id/learningSwipe"
                android:layout_width="wrap_content"
                android:layout_height="wrap_content"
                android:layout_alignParentTop="true"
                android:layout_centerHorizontal="true"
                android:padding="30dp"
                android:src="@drawable/swipe" />
        </RelativeLayout>

        <com.plexnor.android.good.ViewfinderView
            android:id="@+id/viewfinder_view"
            android:layout_width="wrap_content"
            android:layout_height="wrap_content" />

        <RelativeLayout
            android:id="@+id/learning_relative_layout"
            android:layout_width="fill_parent"
            android:layout_height="wrap_content"
            android:layout_alignParentRight="true"
            android:layout_alignParentTop="true"
            android:background="@android:color/transparent" >

2 个答案:

答案 0 :(得分:1)

你的logcat抛出什么

  

引起:java.lang.ClassNotFoundException:没有找到类   “com.plexnor.android.good.ViewfinderView”

Java中的

ClassNotFoundException java.lang.Exception 的子类,当Java虚拟机尝试加载特定类并且未在类路径中找到所请求的类时出现。

关于这个Exception的另一个要点是,它是一个经过检查的Exception,你需要在使用 {{ 1}} 子句。

解决方案

  

检查您的类路径是否包含该jar,如果您的类路径           不包含jar然后只在类路径中添加该类。

答案 1 :(得分:0)

因为我无法解决问题,所以我暂停了该项目几个月。在我的另一个项目中使用Eclipse,在将第三方SDK包含到项目中之后出现了同样的问题。 清理项目,改变构建路径中的东西没有帮助。所以,我将项目克隆到一个新的工作区并添加了SDK ......它就是这样工作的。在尝试了旧的废弃项目后,它开箱即用。因此,我认为由开发环境中的错误引起的问题。