parse-community / ParseUI-Android

ParseUI contains user interface libraries for building apps with the Parse Android SDK.
Other
592 stars 323 forks source link

Using ParseLoginUI 1.10.1 With latest Facebook SDK 4.6.0 #80

Closed StuStirling closed 8 years ago

StuStirling commented 8 years ago

Hi,

Trying to implement the latest Parse SDK with the ParseLoginUI and Facebook SDK V 4.6.0 but can't do it.

This is the furthest I've got. I can get the ParseLoginActivity to display but I'm crashing when I select the "LoginWithFacebook" button.

Here are my different build.gradle files.

ParseUI-Login build.grade I had to increase the minSdkVersion to 15 so there was no longer a conflict between the latest FacebookSDK. I also had to increase the support library version as before it complained about not being able to depend on a .aar file in a library module.

apply plugin: 'android-library'

dependencies {
    compile 'com.android.support:support-v4:23.0.1'
    compile 'com.parse:parse-android:1.10.1'

    provided 'com.facebook.android:facebook-android-sdk:4.6.0'
    provided files("$rootProject.projectDir/ParseUI-Login/libs/ParseFacebookUtilsV4-1.10.1.jar")
    provided files("$rootProject.projectDir/ParseUI-Login/libs/ParseTwitterUtils-1.10.1.jar")
}

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 21
    }
}

My App Module's build.grade So this is the only structure that has worked for me. As soon as I try to include any of the Parse SDK files (following the read me) it breaks the ParseUI-Login. I've only shown the bit of the file that matter.

compile 'com.facebook.android:facebook-android-sdk:4.6.0'

    // PARSE - https://www.parse.com/apps/quickstart#parse_data/mobile/android/native/existing
//    compile 'com.parse.bolts:bolts-android:1.+'
//    compile files('../libs/Parse-1.10.2.jar')
    compile project(':ParseUI-Login')
    compile project(':ParseUI-Widget')
//    compile files('../libs/ParseFacebookUtilsV4-1.10.2.jar')
//    compile files('../libs/ParseTwitterUtils-1.10.1.jar')

I have included the ParseLoginActivity declaration in my manifest file and I open it like this.

ParseLoginBuilder builder = new ParseLoginBuilder(getActivity());
                builder.setFacebookLoginPermissions(Arrays.asList(getResources().getStringArray(R.array.s2tm_facebook_permissions)));
                startActivityForResult(builder.build(), 213);

When the application crashes when I click the "Login with Facebook" button it looks like this.

10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime: FATAL EXCEPTION: main
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime: Process: com.corecoders.ski2themoon, PID: 3627
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime: java.lang.NoClassDefFoundError: Failed resolution of: Lcom/parse/ParseFacebookUtils;
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at com.parse.ui.ParseLoginFragment$5.onClick(ParseLoginFragment.java:306)
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at android.view.View.performClick(View.java:4780)
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at android.view.View$PerformClick.run(View.java:19866)
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at android.os.Handler.handleCallback(Handler.java:739)
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:95)
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:135)
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5254)
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:372)
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:  Caused by: java.lang.ClassNotFoundException: Didn't find class "com.parse.ParseFacebookUtils" on path: DexPathList[[zip file "/system/framework/android.test.runner.jar", zip file "/data/app/com.corecoders.ski2themoon-2/base.apk"],nativeLibraryDirectories=[/vendor/lib, /system/lib]]
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:56)
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at java.lang.ClassLoader.loadClass(ClassLoader.java:511)
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at java.lang.ClassLoader.loadClass(ClassLoader.java:469)
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at com.parse.ui.ParseLoginFragment$5.onClick(ParseLoginFragment.java:306) 
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at android.view.View.performClick(View.java:4780) 
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at android.view.View$PerformClick.run(View.java:19866) 
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at android.os.Handler.handleCallback(Handler.java:739) 
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:95) 
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:135) 
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5254) 
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method) 
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:372) 
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903) 
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698) 
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:   Suppressed: java.lang.ClassNotFoundException: com.parse.ParseFacebookUtils
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at java.lang.Class.classForName(Native Method)
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at java.lang.BootClassLoader.findClass(ClassLoader.java:781)
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at java.lang.BootClassLoader.loadClass(ClassLoader.java:841)
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:     at java.lang.ClassLoader.loadClass(ClassLoader.java:504)
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:           ... 12 more
10-07 20:50:48.182 3627-3627/com.corecoders.ski2themoon E/AndroidRuntime:  Caused by: java.lang.NoClassDefFoundError: Class not found using the boot class loader; no stack available
wangmengyan95 commented 8 years ago

Hi @StuStirling: For the minSdkVersion, aar and support library issues, I will take a look and response you later. For the crash issue, you need

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

in your app's gradle. Since in :ParseUI-Login, we provided not complied the ParseFacebookUtilsV4.

StuStirling commented 8 years ago

Just for completeness, the warning that appears when leaving the support dependency version as 22.0.0 is as follows:

Warning:Project ParseUI-Login: apk dependencies can only be jars. com.android.support:support-v4:aar:22.0.0 is an Android Library.

StuStirling commented 8 years ago

So I have included the compile files('../libs/ParseFacebookUtilsV4-1.10.2.jar) in my app's build.grade file.

Here are my updated build.gradle files.

ParseUI-Login build.gradle

apply plugin: 'android-library'

dependencies {
    compile 'com.android.support:support-v4:23.0.1'
    compile 'com.parse:parse-android:1.10.1'

    provided 'com.facebook.android:facebook-android-sdk:4.6.0'
    provided files("$rootProject.projectDir/libs/ParseFacebookUtilsV4-1.10.2.jar")
    provided files("$rootProject.projectDir/ParseUI-Login/libs/ParseTwitterUtils-1.10.1.jar")
}

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 21
    }
}

app build.gradle

// PARSE - https://www.parse.com/apps/quickstart#parse_data/mobile/android/native/existing
    compile 'com.parse.bolts:bolts-android:1.+'
    compile files('../libs/Parse-1.10.2.jar')
    compile project(':ParseUI-Login')
//    compile project(':ParseUI-Widget')
    compile files('../libs/ParseFacebookUtilsV4-1.10.2.jar')
//    compile files('../libs/ParseTwitterUtils-1.10.1.jar')

Now the error I get on build is about sex issues. Usually because there are duplicate libraries present. Enabling multiDex usually resolves these issues but I don't really want to if I can help it due to performance hits etc. Here is the error



> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/Library/Java/JavaVirtualMachines/jdk1.7.0_75.jdk/Contents/Home/bin/java'' finished with non-zero exit value 2```
StuStirling commented 8 years ago

And if I do enable multiDex I get the following error (might help point to conflicting libraries)

Error:Execution failed for task ':app:packageAllDebugClassesForMultiDex'.
> java.util.zip.ZipException: duplicate entry: com/parse/AbstractQueryController$1.class
wangmengyan95 commented 8 years ago

Check #73, it seems you import Parse twice. We already import Parse from maven in :ParseUI-Login, but you still import your local jar.

StuStirling commented 8 years ago

Ok so removed compile files('../libs/Parse-1.10.2.jar') from my app's build.gradle file and it now builds and runs but is now crashing on startup. It can't find the com.parse.FacebookAuthenticationProvider when calling ParseFacebookUtils.initialize(this);.

10-08 09:06:53.442 13388-13388/? E/AndroidRuntime: java.lang.NoClassDefFoundError: com.parse.FacebookAuthenticationProvider
10-08 09:06:53.442 13388-13388/? E/AndroidRuntime:     at com.parse.ParseFacebookUtils.initialize(ParseFacebookUtils.java:96)
10-08 09:06:53.442 13388-13388/? E/AndroidRuntime:     at com.parse.ParseFacebookUtils.initialize(ParseFacebookUtils.java:81)
10-08 09:06:53.442 13388-13388/? E/AndroidRuntime:     at com.corecoders.ski2themoon.S2TMApplication.onCreate(S2TMApplication.java:48)
10-08 09:06:53.442 13388-13388/? E/AndroidRuntime:     at android.app.Instrumentation.callApplicationOnCreate(Instrumentation.java:1012)
10-08 09:06:53.442 13388-13388/? E/AndroidRuntime:     at android.app.ActivityThread.handleBindApplication(ActivityThread.java:4553)
10-08 09:06:53.442 13388-13388/? E/AndroidRuntime:     at android.app.ActivityThread.access$1500(ActivityThread.java:151)
10-08 09:06:53.442 13388-13388/? E/AndroidRuntime:     at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1364)
10-08 09:06:53.442 13388-13388/? E/AndroidRuntime:     at android.os.Handler.dispatchMessage(Handler.java:102)
10-08 09:06:53.442 13388-13388/? E/AndroidRuntime:     at android.os.Looper.loop(Looper.java:135)
10-08 09:06:53.442 13388-13388/? E/AndroidRuntime:     at android.app.ActivityThread.main(ActivityThread.java:5254)
10-08 09:06:53.442 13388-13388/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Native Method)
10-08 09:06:53.442 13388-13388/? E/AndroidRuntime:     at java.lang.reflect.Method.invoke(Method.java:372)
10-08 09:06:53.442 13388-13388/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:903)
10-08 09:06:53.442 13388-13388/? E/AndroidRuntime:     at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:698)
StuStirling commented 8 years ago

Ok I've got it working. Here are my working files. Note the following.

ParseUI-Login build.grade

/*
 *  Copyright (c) 2014, Parse, LLC. All rights reserved.
 *
 *  You are hereby granted a non-exclusive, worldwide, royalty-free license to use,
 *  copy, modify, and distribute this software in source code or binary form for use
 *  in connection with the web services and APIs provided by Parse.
 *
 *  As with any software that integrates with the Parse platform, your use of
 *  this software is subject to the Parse Terms of Service
 *  [https://www.parse.com/about/terms]. This copyright notice shall be
 *  included in all copies or substantial portions of the software.
 *
 *  THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
 *  IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
 *  FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
 *  COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
 *  IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
 *  CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
 *
 */

apply plugin: 'android-library'

dependencies {
    compile 'com.android.support:support-v4:23.0.1'
    compile 'com.parse:parse-android:1.10.2'

    provided 'com.facebook.android:facebook-android-sdk:4.6.0'
    provided files("$rootProject.projectDir/libs/ParseFacebookUtilsV4-1.10.2.jar")
    provided files("$rootProject.projectDir/ParseUI-Login/libs/ParseTwitterUtils-1.10.1.jar")
}

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.1"

    defaultConfig {
        minSdkVersion 15
        targetSdkVersion 21
    }
}

App Module's build.gradle

compile 'com.facebook.android:facebook-android-sdk:4.6.0'
compile project(':ParseUI-Login')
compile files('../libs/ParseFacebookUtilsV4-1.10.2.jar')

I can now login to my Parse app via Facebook using the ParseUI-Login widget.

wangmengyan95 commented 8 years ago

81