0

Skip to my EDIT section below - new project setup and new question there. I left the original stuff here for context...

I'm getting a NoClassDefFoundError in my Android project - in this case it's complaining that it can't find the the UserVoice plugin I just added:

stack trace

Triggered by this code:

package com.mycompany.myapp;
...
import com.uservoice.uservoicesdk.Config;
import com.uservoice.uservoicesdk.UserVoice;
...
public class MyActivity extends Activity {
    ...
    public void onCreate(Bundle savedInstanceState) {
        ...
        super.onCreate(savedInstanceState);
        ...
        _configureFeedbackWidget();
    }

    private void _configureFeedbackWidget() {
        // It gets past this code, which contains stuff in the same 
        // "uservoicesdk" package as the problem class. 
        Config config = new Config("myapp.uservoice.com");
        UserVoice.init(config, this);
    }

    public void showFeedbackWindow(View v) {
        // Triggered by a button on the page
        UserVoice.launchUserVoice(this);  // Error is triggered by this line
    }
    ...
}

However, I cracked open the .apk (using dex2jar) that was installed and manually verified that the PortalActivity class, that it's complaining about, IS there:

apk contents

What could cause Android to not find the class?



EDIT:
I've changed around my project dependences & Java Build Path settings, and this is what I have now:

Build Path - Projects Build Path - Libraries! Build Path - Order and Export

I cleaned/re-built - no errors, and now I'm seeing the following:

  1. MyApp.apk no longer has the com.uservoice.uservoicesdk package in it. That package is now in PortalActivity.apk, which I can see, from the console, is installed separately from my .apk.

    Console output:

Uploading MyApp.apk onto device 'LG-MS770-275bcf0'
Installing MyApp.apk...
Success!
Project dependency found, installing: PortalActivity
Uploading PortalActivity.apk onto device 'LG-MS770-275bcf0'
Installing PortalActivity.apk...
Success!
Starting activity com.mycompany.myapp.MyActivity on device LG-MS770-275bcf0

  1. Now my app dies during the _configureFeedbackWidget() method, above, with the error java.lang.NoClassDefFoundError: com.service.uservoicesdk.Config.

So, what is the correct way to reference the PortalActivity project from my project such that my project can find PortalActivity's classes at runtime, and not just at build time?

Troy
  • 21,172
  • 20
  • 74
  • 103
  • Post the code that gives this error – user3282276 Nov 21 '14 at 19:19
  • Im not familiar with Android dev or the apk files, but if they are anything like a traditional JAR file, simply having the dependency in there isnt enough, it must also be specified in the classpath in the jars manifest. I would expect an APK to have something similar. – Mark W Nov 21 '14 at 19:24
  • This is usually caused by a linker error when building. Usually because a library wasn't added properly. Sometimes simply rebuilding fixes it. http://stackoverflow.com/questions/2247998/noclassdeffounderror-eclipse-and-android – DeeV Nov 21 '14 at 19:34
  • @DeeV I've tried cleaning/re-building and closing/re-opening Eclipse, I've also made sure that the relevant jar is checked off in the "Order and Export" tab (as suggested by your link), with no luck... – Troy Nov 21 '14 at 19:42
  • did you added the activity in the manifest? – Sarthak Mittal Nov 21 '14 at 19:56
  • The "MyClass" Activity is in the manifest (assuming you mean AndroidManifest.xml). Does the uservoice lib need to be specified in the manifest somehow also? – Troy Nov 21 '14 at 20:44
  • I just tried adding `` to AndroidManifest.xml, but it still dies with the same error. – Troy Nov 21 '14 at 20:50

0 Answers0