【问题标题】:Unable to instantiate activity ComponentInfo (...) java.lang.ClassNotFoundException:()无法实例化活动 ComponentInfo (...) java.lang.ClassNotFoundException:()
【发布时间】:2013-12-03 11:36:08
【问题描述】:

大家好,我正在尝试从 Git 中心编译此代码,但出现错误(我尝试开始时应用程序崩溃)

java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.viewpagerparallax/com.example.viewpagerparallax.MyTestActivity}: java.lang.ClassNotFoundException: Didn't find class "com.example.viewpagerparallax.MyTestActivity" on path: DexPathList[[zip file "/data/app/com.example.viewpagerparallax-1.apk"],nativeLibraryDirectories=[/data/app-lib/com.example.viewpagerparallax-1, /vendor/lib, /system/lib]]

没有堆栈溢出问题/解决方案帮助了我。

此外,当我切换到 main.xml 布局视图时,它会显示

The following classes could not be found:
- com.example.viewpagerparallax (Fix Build Path, Edit XML, Create Class) 

虽然.java文件存在于同一个包中

这是我的清单文件(在我的情况下,我已将包名称更改为 com.example.viewpagerparallax.MyTestActivity ) 这是清单文件

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.viewpagerparallax"
    android:versionCode="1"
    android:versionName="1.0" >

    <uses-sdk
        android:minSdkVersion="8"
        android:targetSdkVersion="18" />

    <application
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:theme="@style/AppTheme" >
        <activity
            android:name="com.example.viewpagerparallax.MyTestActivity"
            android:label="@string/app_name" >
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

这是我关注的链接

https://github.com/MatthieuLJ/ViewPagerParallax 如果您需要这些文件,请告诉我。

请帮忙 在此先感谢

【问题讨论】:

  • 清理您的项目并尝试...
  • 您的代码中是否添加了第三方jar文件?
  • @gopal Rao 试了几次都没有结果。
  • @Siddarth Vyas 我下载了整个代码,没有提到任何内容,但没有添加 jar 文件,代码如何编译仍然是一个新手。我不知道
  • 再次下载项目并再次运行,我下载并运行良好

标签: android android-layout android-intent


【解决方案1】:

试试这个:

转到 Project/Properties/Java Build Path/Order and Export -- 如果您使用它,请确保在 Android Dependencies 和支持库前面有一个检查。标记所有复选框。单击 Apply 并清理项目。

希望这会有所帮助。

【讨论】:

  • 我可以找到android依赖但不支持库你的意思是android私有库,即使它们都被勾选了。
【解决方案2】:

在我的情况下,出现此错误是因为我在资源文件或 Manifest.xml 中有一些由 SVN 客户端(如 smartSVN 或 tortoise)插入的代码行。

    <<<<<<< .mine
        <string name="pathConfiguration">http://jorgesys/app/config_development.xml</string>
    =======    

    >>>>>>> .r124
<<<<<<< .mine

所以删除那些行

<string name="pathConfiguration">http://jorgesys/app/config_development.xml</string>

它将修复异常。

【讨论】:

    【解决方案3】:

    如果您向您的项目添加额外的库,您需要将它们与您的项目一起导出,以防某些类被排除在外。

    我已经回答了这个问题,这将轻松解决问题。 看到here

    【讨论】:

      猜你喜欢
      • 2016-11-17
      • 2015-03-04
      • 2013-09-03
      • 1970-01-01
      • 2016-03-10
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2011-11-19
      相关资源
      最近更新 更多