2016-06-03 17 views
9

पर rx.plugins.RxJavaPlugins मैं RxJava और Retofit का उपयोग कर एक एंड्रॉइड एप्लिकेशन विकसित कर रहा हूं। जब मैं एपीआई 23 पर अपने कोड का परीक्षण जब मैं एपीआई 15 में परीक्षण लेकिन कोई त्रुटि हो, मेरी RxJava ठीक से त्रुटि के साथ और मेरे ऐप्लिकेशन क्रैश काम करने के लिए दिखाई देते हैं नहीं करता है:RxJava noClassDefFoundError: एपीआई 16

:

FATAL EXCEPTION: main 
java.lang.ExceptionInInitializerError 
at $Proxy1.createToken(Native Method) 
at com.loginsignup.presenter.LoginPresenterImpl.tryToLogin(LoginPresenterImpl.java:39) 
at com.loginsignup.view.LoginActivity.tryToLogin(LoginActivity.java:197) 
at com.loginsignup.view.LoginActivity.onClick(LoginActivity.java:180) 
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) 
Caused by: java.lang.NoClassDefFoundError: rx.plugins.RxJavaPlugins 
at rx.Observable.<clinit>(Observable.java:63) 
at $Proxy1.createToken(Native Method) 
at com.gooroo.gooroo.loginsignup.presenter.LoginPresenterImpl.tryToLogin(LoginPresenterImpl.java:39) 
at com.gooroo.gooroo.loginsignup.view.LoginActivity.tryToLogin(LoginActivity.java:197) 
at com.gooroo.gooroo.loginsignup.view.LoginActivity.onClick(LoginActivity.java:180) 
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) 

यहाँ मेरी Gradle निर्माण है

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion "23.0.2" 

    defaultConfig { 
     applicationId "com.example.ex" 
     minSdkVersion 15 
     targetSdkVersion 23 
     versionCode 1 
     versionName "0.1 alpha" 
     multiDexEnabled true 
    } 

    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 

    dexOptions { 
     javaMaxHeapSize "4g" 
    } 
} 

dependencies { 
    compile fileTree(include: ['*.jar'], dir: 'libs') 
    testCompile 'junit:junit:4.12' 
    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' 
    compile files('libs/sinch-android-rtc-3.9.5.jar') 
    compile 'com.android.support:appcompat-v7:23.4.0' 
    compile 'com.android.support:design:23.4.0' 
    compile 'com.android.support:support-v4:23.4.0' 
    compile 'com.android.support:cardview-v7:23.4.0' 
    compile 'com.google.android.gms:play-services-maps:8.4.0' 
    compile 'com.google.android.gms:play-services-location:8.4.0' 
    compile 'com.google.code.gson:gson:2.6.2' 
    compile 'com.google.android.gms:play-services-analytics:8.4.0' 
    compile 'com.squareup.picasso:picasso:2.5.2' 
    compile 'com.squareup.okhttp3:okhttp-urlconnection:3.2.0' 
    compile 'com.squareup.okhttp3:okhttp:3.2.0' 
    compile 'com.squareup.okhttp3:logging-interceptor:3.2.0' 
    compile 'com.squareup.retrofit2:retrofit:2.0.0' 
    compile 'com.squareup.retrofit2:converter-gson:2.0.0' 
    compile 'com.squareup.retrofit2:adapter-rxjava:2.0.0' 
    compile 'com.github.orhanobut:logger:1.12' 
    compile 'com.viewpagerindicator:library:[email protected]' 
    compile 'io.reactivex:rxandroid:1.2.0' 
    compile 'io.reactivex:rxjava:1.1.5' 
    compile 'com.facebook.android:facebook-android-sdk:4.+' 
    compile 'com.stripe:stripe-android:+' 
    compile 'com.google.android.gms:play-services-gcm:8.4.0' 
    compile 'com.timehop.stickyheadersrecyclerview:library:[email protected]' 
    compile 'com.amazonaws:aws-android-sdk-core:2.+' 
    compile 'com.amazonaws:aws-android-sdk-s3:2.+' 
    compile 'com.google.android.gms:play-services-wallet:8.4.0' 
    compile 'com.android.support:multidex:1.0.0' 
} 

apply plugin: 'com.google.gms.google-services' 

कोई विचार क्यों एपीआई 23 पर कोई समस्या नहीं है, लेकिन जब मैं इसे एपीआई 16 पर चलाता हूं तो यह क्रैश हो जाता है जब मैं लॉगिन करने का प्रयास करता हूं जो आरएक्सजेवा का उपयोग करता है?

+0

से मैं एक ही समस्या है प्राप्त कर सकते हैं, मैं स्टैक ट्रेस के माध्यम से rx.plugins.RxJavaPlugins क्लास करने के लिए नेविगेट करने की कोशिश की है, और मैं उस वर्ग को – Bikash

उत्तर

21

समस्या यहाँ आप आरंभ नहीं किया है किया जा सकता है है MultiDex विकल्प

Android 5.0 के लिए Multidex समर्थन और उच्च

Android 5.0 and higher uses a runtime called ART which natively supports loading multiple dex files from application APK files. ART performs pre-compilation at application install time which scans for classes(..N).dex files and compiles them into a single .oat file for execution by the Android device. For more information on the Android 5.0 runtime, see Introducing ART. This is the reason why your app is working fine on API level 21.

Multidex समर्थन पहले से Android 5,0

Versions of the platform prior to Android 5.0 use the Dalvik runtime for executing app code. By default, Dalvik limits apps to a single classes.dex bytecode file per APK. In order to get around this limitation, you can use the multidex support library, which becomes part of the primary DEX file of your app and then manages access to the additional DEX files and the code they contain.

तो, सबसे पहले यह सुनिश्चित करना कि आपने सही निर्भरता आयात की है, wh ऐसा लगता है कि आपने ऐसा किया था।

dependencies { 
    compile 'com.android.support:multidex:1.0.0' 
} 

अपने प्रकट में आवेदन तत्व को multidex समर्थन पुस्तकालय से MultiDexApplication वर्ग जोड़ें।

<?xml version="1.0" encoding="utf-8"?> 
<manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.android.multidex.myapplication"> 
    <application 
     ... 
     // This will solved the problem 
     android:name="YourAppName"> 
     ... 
    </application> 
</manifest> 

यह मैं कैसे मेरी समस्या हल, यहाँ तक कि वहाँ उसी के बारे में Git मुद्दे को बंद कर दिया जाता है।

संपादित

public class YouAppName extends MultiDexApplication { 
    .. .. 
} 

मुझे आशा है कि यह तुम बाहर में मदद मिलेगी।

+0

परिभाषित किया गया है, हालांकि मेरे पास पहले से ही एक पैकेज नाम है। मैं नाम बदलना नहीं चाहता, मुझे क्या करना चाहिए? –

+0

आवेदन विस्तार करने के बजाय मल्टीडेक्स आवेदन सरल, जाने के लिए आपको अच्छा लगेगा अगर मैं आपकी मदद करता हूं तो – Bikash

+0

सहायता के लिए धन्यवाद। इसके अलावा पूर्ण नाम का विस्तार करना आसान है: android.support.multidex.MultiDexAplication –

0

बिकशा के लिए धन्यवाद, उसका शीर्ष समाधान वास्तव में काम करता है। मेरे कार्यक्रम में, मेरे आवेदन वर्ग ने एक और *** आवेदन बढ़ाया है। अंत में मैं अपने अनुप्रयोग वर्ग में प्रारंभिक मल्टीडेक्स में अटैचबेसबेसटेक्स्ट (संदर्भ आधार) फ़ंक्शन को ओवरराइड करके इसे हल करता हूं। एक शब्द में, मैं इस तरह कार्य करें:

defaultConfig {//first step 
     multiDexEnabled true 
    } 

dependencies {compile 'com.android.support:multidex:1.0.1'}//second 

@Override 
protected void attachBaseContext(Context base) { 
    super.attachBaseContext(base); 
    MultiDex.install(this);//finally 
} 

आप अधिक जानकारी के this page

संबंधित मुद्दे