【问题标题】:Class files of application not packaged in APK应用程序的类文件未打包在 APK 中
【发布时间】:2012-11-21 17:39:31
【问题描述】:

不知何故,android 打包器不再(不再)将我的应用程序中的类文件包含在 APK 中。

我已经尝试了所有想到的方法,从将我的设置与示例项目进行比较,到重新安装 Eclipse。但是,当我打包应用程序时,无论是通过“导出(未)签名的应用程序包”还是仅通过在调试设备/模拟器上运行它,都包含所有内容(jar 库、android 库项目(例如 ActionBarSherlock))除了我自己的代码。 :-(

这是仍然产生问题的最小配置...感谢任何提示或帮助!

Android 清单:

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

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

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

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

类路径:

    <?xml version="1.0" encoding="UTF-8"?>
    <classpath>
        <classpathentry kind="con" path="com.android.ide.eclipse.adt.ANDROID_FRAMEWORK"/>
        <classpathentry kind="con" path="com.android.ide.eclipse.adt.LIBRARIES"/>
        <classpathentry kind="lib" path="libs/json-simple-1.1.1.jar"/>
        <classpathentry kind="lib" path="libs/zbar.jar"/>
        <classpathentry combineaccessrules="false" kind="src" path="/SherlockActionBar"/>
        <classpathentry kind="src" path="src"/>
        <classpathentry kind="src" path="gen"/>
        <classpathentry kind="output" path="bin/classes"/>
    </classpath>

Eclipse项目配置:

    <?xml version="1.0" encoding="UTF-8"?>
    <projectDescription>
        <name>bla-android</name>
        <comment></comment>
        <projects>
        </projects>
        <buildSpec>
            <buildCommand>
                <name>com.android.ide.eclipse.adt.ResourceManagerBuilder</name>
                <arguments>
                </arguments>
            </buildCommand>
            <buildCommand>
                <name>com.android.ide.eclipse.adt.PreCompilerBuilder</name>
                <arguments>
                </arguments>
            </buildCommand>
            <buildCommand>
                <name>org.eclipse.jdt.core.javabuilder</name>
                <arguments>
                </arguments>
            </buildCommand>
            <buildCommand>
                <name>com.android.ide.eclipse.adt.ApkBuilder</name>
                <arguments>
                </arguments>
            </buildCommand>
        </buildSpec>
        <natures>
            <nature>com.android.ide.eclipse.adt.AndroidNature</nature>
            <nature>org.eclipse.jdt.core.javanature</nature>
        </natures>
    </projectDescription>

更新: 我的问题实际上是 ActionBarSherlock 是针对 Android 4.2 构建的,它以某种方式把它搞砸了,没有一个像样的错误消息。幸运的是,在常见问题解答中提到您必须针对 4.0 构建它...接受 Robert 的回答,因为他是最接近的。

【问题讨论】:

    标签: android eclipse actionbarsherlock


    【解决方案1】:

    您怎么办?您最有可能遇到构建错误,并且该过程无法完成它的工作。

    【讨论】:

    • 我没有(又名。Eclipse 没有显示)任何 Java 错误。 android 控制台也没有显示任何错误。 LogCat 仅显示 ClassNotFoundException,当 APK 不包含它时,这是可以预料的。还有其他地方可以显示错误吗?
    • 您可以出于多种原因获得该异常。你真的打开了 APK 文件并检查了 classes.dex 文件不在那里吗?
    • classes.dex 在那里。但是,它们不在“com”文件夹中。我检查了多次没有找到的类的路径,这导致我首先查看了apk。此外,apk 比以前小了很多(尽管我只是添加了一些东西)。
    • 我不明白。 APK 内没有 'com' 文件夹,所有的类都合并到 classes.dex 文件中。如果您在 APK 中有该文件,则表示构建正在运行。如果您在 android 项目中引用 'src/com/' 文件夹,则说明您没有正确导入项目或缺少源类
    • 也许这是个问题,但我的 apk 中有一个 'com/google/...' 文件夹。
    【解决方案2】:
    1. 重启 Eclipse
    2. 删除 gen 文件夹
    3. 项目 -> 清理
    4. Android 工具 -> 修复项目属性
    5. 运行方式 -> Android 应用程序

    【讨论】:

    • 这样做了 100 次。另外,如上所述,我重新安装了 Eclipse 并重新启动了我的计算机。 (然后创建一个新的android项目,复制'src'和'res'文件夹,调整清单->相同的结果)
    • 确保包名是否在所有地方都正确并尝试运行Androod工具->修复项目属性
    猜你喜欢
    • 1970-01-01
    • 2011-05-17
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-02
    • 2023-01-30
    • 2012-05-13
    相关资源
    最近更新 更多