6

Somehow the the android packager does not (anymore) include the class files from my application in the APK.

I have tried everything that came to my mind from comparing my settings to a sample project to reinstalling Eclipse. However, when I package the app, be it through 'Export (un)signed Application Package' or just by running it on a debug device/emulator, everything is included (jar libraries, android library projects (e.g. ActionBarSherlock)) except my own code. :-(

Here is the minimal configuration which still produces the problem...Thanks for any hints or help!

Android Manifest:

    <?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>

Classpath:

    <?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 project configuration:

    <?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>

Update: My problem was actually that ActionBarSherlock was built against Android 4.2 which somehow screwed it all without a decent error message. Luckily it is mentioned in the FAQs that you have to build it against 4.0 ... Accepting Robert's answer as he was the closest.

Michael.F
  • 110
  • 1
  • 9

2 Answers2

1

How do you Most likely you have a build error, and the process is not being able to complete it's job.

Robert Estivill
  • 12,369
  • 8
  • 43
  • 64
  • I don't have (aka. Eclipse does not show me) any Java errors. The android console does not show any errors either. LogCat only shows the ClassNotFoundException, which is to be expected when the APK does not contain it. Is there any other place where an error could be shown? – Michael.F Nov 21 '12 at 18:44
  • You can get that exception for multiple reasons. Did you actually opened the APK file and check that the classes.dex file is not in there? – Robert Estivill Nov 21 '12 at 18:48
  • The classes.dex is there. However, they are not inside the 'com' folder. And I checked the path of the class that was not found multiple times, which led me to look into the apk in the first place. In addition the apk is quite a bit smaller than before (even though I just added stuff). – Michael.F Nov 21 '12 at 18:58
  • I'm not getting it. There's no 'com' folder inside the APK, all the classes are combined into the classes.dex file. If you have that file in the APK it means the build is working. If you are refering to the 'src/com/' folder in your android project, then, you have not imported your project correctly or you are missing sources classes – Robert Estivill Nov 21 '12 at 19:02
  • Maybe that's a problem, but I do have a 'com/google/...' folder in my apk. – Michael.F Nov 21 '12 at 19:10
  • That's weird, i'm using google maps, and support library and my apk doesn't have anything like that. Please post a screenshot of your eclipse package explorer view expanded – Robert Estivill Nov 21 '12 at 19:32
  • Can I send it to you in the chat? It asks me to move it to a chat but then I can't start it because I don't have enough reputation... – Michael.F Nov 21 '12 at 20:42
  • Anyway, I was wrong and you were right. The classes seem to be there. I added the default 'LoginActivity' and it starts and shows without error. I still don't get my MainActivity running though. The only error I get is the ClassNotFoundException and the path is right for sure (I copied and pasted it again). – Michael.F Nov 21 '12 at 20:47
  • First - here's how i fixed it here: i had AdMob lib referenced as external jar. I have moved it to libs folder of my project and problem has gone! http://stackoverflow.com/questions/9833607/android-eclipse-noclassdeffounderror-for-external-jar-files – WindRider May 03 '13 at 18:11
0
  1. Restart Eclipse
  2. Delete gen folder
  3. Project -> clean
  4. Android Tools -> Fix project properties
  5. Run as -> Android application
intrepidkarthi
  • 3,104
  • 8
  • 42
  • 75
  • Did that 100 times. Plus, as mentioned I reinstalled Eclipse and restarted my computer. (Then created a new android project, copied 'src' and 'res' folders, adjusted the manifest -> same outcome) – Michael.F Nov 21 '12 at 18:41
  • Ensure whether the package name is correct everywhere and also try running Androod tools-> fix project properties – intrepidkarthi Nov 21 '12 at 18:54