Liferay Screens Android中的NoClassDefError com.liferay.mobile.screens.base.interactor.JSONObjectCallback

时间:2016-05-08 11:20:06

标签: android gradle dependencies liferay

我在Android移动应用中使用Liferay Screens,以及Liferay Android Mobile SDK。 我已将LoginScreenlet放入我的活动中。它显示正确,但是当我单击“登录”按钮时,我收到此错误:

05-08 10:58:37.681 9296-9296/com.mimacom.lrhc E/AndroidRuntime: FATAL EXCEPTION: main
                                                            java.lang.NoClassDefFoundError: com.liferay.mobile.screens.base.interactor.JSONObjectCallback
                                                                at com.liferay.mobile.screens.auth.login.interactor.LoginBasicInteractor.getUserService(LoginBasicInteractor.java:68)
                                                                at com.liferay.mobile.screens.auth.login.interactor.LoginBasicInteractor.login(LoginBasicInteractor.java:37)
                                                                at com.liferay.mobile.screens.auth.login.LoginScreenlet.onUserAction(LoginScreenlet.java:236)
                                                                at com.liferay.mobile.screens.auth.login.LoginScreenlet.onUserAction(LoginScreenlet.java:44)
                                                                at com.liferay.mobile.screens.base.BaseScreenlet.performUserAction(BaseScreenlet.java:78)
                                                                at com.liferay.mobile.screens.viewsets.defaultviews.auth.login.LoginView.onClick(LoginView.java:136)
                                                                at android.view.View.performClick(View.java:4084)
                                                                at android.view.View$PerformClick.run(View.java:16966)
                                                                at android.os.Handler.handleCallback(Handler.java:615)
                                                                at android.os.Handler.dispatchMessage(Handler.java:92)
                                                                at android.os.Looper.loop(Looper.java:137)
                                                                at android.app.ActivityThread.main(ActivityThread.java:4745)
                                                                at java.lang.reflect.Method.invokeNative(Native Method)
                                                                at java.lang.reflect.Method.invoke(Method.java:511)
                                                                at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:786)
                                                                at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:553)
                                                                at dalvik.system.NativeStart.main(Native Method)

我在Genymotion模拟器,Android 4.1.1(16级)上尝试这个。

我的应用程序的gradle文件:

apply plugin: 'com.android.application'
apply plugin: 'com.neenbedankt.android-apt'
apply plugin: 'com.jakewharton.hugo'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.mimacom.lrhc"
        minSdkVersion 16
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    compileOptions {
        sourceCompatibility "1.7"
        targetCompatibility "1.7"
    }
    packagingOptions {
        exclude 'META-INF/LICENSE'
        exclude 'META-INF/NOTICE'
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    productFlavors {
        mock {}
        prod {}
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    testCompile 'junit:junit:4.12'
    //Support libraries
    compile 'com.android.support:support-v4:23.3.0'
    compile 'com.android.support:appcompat-v7:23.3.0'
    compile 'com.android.support:support-annotations:23.3.0'
    //RxJava
    compile 'io.reactivex:rxandroid:1.1.0'
    compile 'io.reactivex:rxjava:1.1.3'
    //Butterknife view injection
    compile 'com.jakewharton:butterknife:8.0.1'
    apt 'com.jakewharton:butterknife-compiler:8.0.1'
    //Dagger dependency injection
    apt 'com.google.dagger:dagger-compiler:2.2'
    compile 'com.google.dagger:dagger:2.2'
    provided 'javax.annotation:jsr250-api:1.0'
    //Memory leak detector
    debugCompile 'com.squareup.leakcanary:leakcanary-android:1.4-beta2'
    releaseCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
    testCompile 'com.squareup.leakcanary:leakcanary-android-no-op:1.4-beta2'
    //Liferay SDK and Screens
    compile group: 'com.liferay.mobile', name: 'liferay-android-sdk', version: '6.2.0.22'
    compile 'com.liferay.mobile:liferay-screens:1.3.0'
    compile 'com.liferay.mobile:liferay-material-viewset:1.3.0'
}

我找到了一篇关于类似问题的论坛帖子,但是对于旧版Liferay Screens来说也是如此。我猜1.3.0应该已经兼容了。 https://web.liferay.com/community/forums/-/message_boards/message/60438799

这确实是一个依赖性问题还是其他问题?

1 个答案:

答案 0 :(得分:1)

这是一个依赖性问题,6.2.0.22是旧版本,而屏幕1.3.0正在使用较新的版本,并且有更改API。

您不需要依赖移动SDK,您可以使用屏幕中嵌入的内容(更新https://github.com/liferay/liferay-screens/blob/develop/android/Migrate%20to%20Liferay%20Screens%201.2.md中文档中记录的一些代码后