parse-community / ParseFacebookUtils-Android

A utility library to authenticate ParseUsers with the Facebook SDK
http://docs.parseplatform.org/android/guide/#facebook-users
Other
53 stars 63 forks source link

java.lang.NoClassDefFoundError: com.parse.ParseFacebookUtils$1 #12

Closed nvasilescu closed 8 years ago

nvasilescu commented 8 years ago

Android studio 1.5.

line that throws the error -> ParseFacebookUtils.initialize(getApplicationContext());

dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:design:23.1.1' compile 'com.facebook.android:facebook-android-sdk:4.6.0' compile('com.crashlytics.sdk.android:crashlytics:2.5.5@aar') { transitive = true; } compile 'com.parse:parsefacebookutils-v4-android:1.10.3@aar' }

parse-github-bot commented 8 years ago

Thank you for your feedback. We prioritize issues that have clear and concise repro steps. Please see our Bug Reporting Guidelines about what information should be added to this issue.

Please try the latest SDK. Our release notes have details about what issues were fixed in each release.

In addition, you might find the following resources helpful:

nvasilescu commented 8 years ago

what more info should I provide ? Any new project template from android studio, compiling those gradle libraries and initiation of ParseFacebookUtils in the ApplicationClass in onCreate().

nvasilescu commented 8 years ago

Tested on windows also. Same problem. Switched to .jar instead of aar. Same problem. Please fix. It's a critical issue.

compile files('libs/ParseFacebookUtilsV4-1.10.3.jar')

nvasilescu commented 8 years ago

compile files('libs/ParseFacebookUtilsV4-1.10.3.jar') compile files('libs/Parse-1.11.0.jar')

If you use these 2 jars the error goes away, but the maven library ParseFacebookUtils can't be compiled with Parse android sdk from maven because you will get dex error.

grantland commented 8 years ago

This is a problem with facebook-android-sdk since it's using an outdated version of Bolts (bolts-android before the split to bolts-tasks and bolts-applinks). This will be fixed in their next release which is slated for early next year.

A workaround for now is to exclude bolts-android from facebook-android-sdk and include bolts-tasks and bolts-applinks manually. You can find an example of this here: https://github.com/ParsePlatform/ParseFacebookUtils-Android/blob/master/library/build.gradle#L33

(Note: bolts-tasks is required by parse-android and is not required to be declared)

heliumb commented 8 years ago

@grantland i have this same issue and the solution you provided did not work for me. i still get the same error: "java.lang.NoClassDefFoundError: com.parse.ParseFacebookUtils$1"

Any advice?

grantland commented 8 years ago

@heliumb are you sure that ParseFacebookUtils is in the classpath? Do you get any gradle or compile errors?

heliumb commented 8 years ago

hey @grantland I'm pretty sure but I'm new at this so forgive me if I'm wrong. I just did several things that the parse website told me not to do and it worked...can you please tell me if this is going to be a problematic solution to this. In my dependencies, I included both parse-android and parsefacebookutils, which the parse website says should cause a DexException but I didn't get one. When I include only parsefacebookutils, it does not seem to be able to locate the standard parse library. Then I imported the entire bolts library (rather than just bolts-appslinks) and excluded bolts from the facebook sdk. Somehow these steps made it work....Is this a proper solution to this issue? I honestly have no idea why this works and I'm worried it won't work tomorrow...Thanks!

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile files('libs/joda-time-2.9.jar')

    compile 'com.android.support:appcompat-v7:22.2.0'

    compile 'com.parse:parsefacebookutils-v4-android:1.10.3@aar'
    compile 'com.parse:parse-android:1.+'
    compile 'com.parse.bolts:bolts-android:1.+'

    compile ('com.facebook.android:facebook-android-sdk:4.4.0') {
        exclude module: 'bolts-android'
    }

    compile 'com.edmodo:cropper:1.0.1'

}
grantland commented 8 years ago

At the moment the following should work:

dependencies {
  compile 'com.parse:parsefacebookutils-v4-android:1.10.4@aar'

  // any non-parse/fb related dependencies
}

Notes:

In my dependencies, I included both parse-android and parsefacebookutils, which the parse website says should cause a DexException but I didn't get one.

This shouldn't be a problem, could you point me to the resource that says it would be?

When I include only parsefacebookutils, it does not seem to be able to locate the standard parse library.

This shouldn't be an issue. What are the errors your seeing and where?

Somehow these steps made it work...

Can you confirm whether or not you're having issues still?

heliumb commented 8 years ago

grantland, thanks for all the help! It is working for me, but I do have to include both the parsefacebookutils and parse-android dependencies. When I include only parsefacebookutils, it is unable to import anything from the standard parse library - i just get complier errors on everything to do with Parse in my code.

The parse link that says it should create a DexException to have both parse-android and parsefacebookutils at the same time is https://parse.com/docs/android/guide under Users->Facebook Users->Setup->Step 4 where it says "Add com.parse:parsefacebookutils-v4-android:1.10.3@aar to your Gradle dependencies. This includes the contents of the Parse-*.jar and the com.parse:parse-android:1.10.+ repository, so be sure to remove as needed to prevent duplicate dependencies, otherwise a com.android.dex.DexException will be thrown."

Not sure why I need to include both (regular parse-android and parsefacebookutils) but I guess as long as it works, it's fine with me. I will get rid of the wildcard versioning, thanks for the tip!

grantland commented 8 years ago

strange that you need both, but you shouldn't have a problem with both.

the problem outlined there is that you'll get a DexException when using the Maven dependencies alongside the Parse JAR, but you won't with the Parse Maven dependency.

heliumb commented 8 years ago

got it. thanks again!

heliumb commented 8 years ago

actually can i ask one more question - where would i look up the most current version of parse.bolts and parse.android so i know which ones to include (to get rid of the wildcard thing)?

grantland commented 8 years ago

we try to keep the repository READMEs up-to-date, but looking them up on http://search.maven.org/ is always reliable.

heliumb commented 8 years ago

perfect, thanks!

JulianoEngineer commented 8 years ago

I have the same problem, but i dont know why for me the solutions don't work. @heliumb / @grantland Could you post your full solution for the grandle file?

I'm using this:

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.android.support:appcompat-v7:22.2.0'
    compile project(':facebook')
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.github.chrisbanes.photoview:library:1.2.3'
    compile 'com.google.android.gms:play-services-ads:8.3.0'
    compile 'com.parse:parsefacebookutils-v4-android:1.10.4@aar'
    //compile 'com.parse:parse-android:1.+'
    //compile 'com.parse.bolts:bolts-android:1.+'

    //compile 'com.parse:parsefacebookutils-v4-android:1.10.3@aar'
    //compile 'com.parse.bolts:bolts-android:1.+'
    //compile 'com.parse:parse-android:1.12.0'

    //compile fileTree(dir: 'libs', include: 'Parse-*.jar')
}

Thanks.