3

I'm working on integrating WePay Java SDK in Android Studio.

Using following class for WePay initialization:

 import android.content.Context;
 import android.graphics.Bitmap;

import com.wepay.android.SignatureHandler;
import com.wepay.android.SwiperHandler;
import com.wepay.android.TokenizationHandler;
import com.wepay.android.WePay;
import com.wepay.android.models.Config;
import com.wepay.android.models.PaymentInfo;

/**
* Created by zachv on 7/27/15.
* Wecrowd Android
*/
public class PaymentManager {

private static Config config = null;
private static WePay wepay = null;
private static String clientId = "";

public PaymentManager(String clientId) {
    //this.clientId = clientId;
}

public static void tokenizeInfo(Context context, PaymentInfo paymentInfo,
                                final TokenizationHandler handler) {
    initializeMembersFromContext(context);

    wepay.tokenize(paymentInfo, handler);
}

public static void startCardSwipeTokenization(Context context, SwiperHandler swiperHandler,
                                              TokenizationHandler tokenizationHandler)
{
    initializeMembersFromContext(context);

    wepay.startSwiperForTokenizing(swiperHandler, tokenizationHandler);
}

public static void stopCardReader(Context context) {
    initializeMembersFromContext(context);

    wepay.stopSwiper();
}

public static void storeSignatureImage(Context context,
                                       Bitmap image,
                                       String checkoutID,
                                       SignatureHandler signatureHandler)
{
    initializeMembersFromContext(context);

    wepay.storeSignatureImage(image, checkoutID, signatureHandler);
}

private static void initializeMembersFromContext(Context context) {
    if (config == null || wepay == null) {
        config = new Config(context, clientId, Config.ENVIRONMENT_STAGING);
        config.setRestartSwiperAfterSwipeGeneralError(true);
        wepay = new WePay(config);
    } else if (config.getContext() != context) {
        config = new Config(context, clientId, Config.ENVIRONMENT_STAGING);
        config.setRestartSwiperAfterSwipeGeneralError(true);
        wepay = new WePay(config);
    }
}
 }

Now when the function initializeMembersFromContext

is called, it raises following exception:

 java.lang.NoClassDefFoundError: com.wepay.android.internal.Swiper

at this line:

 wepay = new WePay(config);

inside if block of function. I'm passing clientId correctly to this class and all other info too.

I'm a complete noob to WePay in Android. Please suggest.

pratiti-systematix
  • 792
  • 11
  • 28
  • 1
    It seems the `Swiper` class is not present in the APK. How do you declare the dependency to the WePay SDK? Do you have multidex enabled? – fasteque Jan 19 '16 at 12:16
  • I've added wepay.jar to my libs folder – pratiti-systematix Jan 19 '16 at 12:40
  • Can you post your `build.gradle` script? At least to know how you declared your dependencies and if you have `multidex` enabled. Thanks. – fasteque Jan 19 '16 at 12:42
  • dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) testCompile 'junit:junit:4.12' compile('com.twitter.sdk.android:twitter:1.11.0@aar') { transitive = true; } compile project(':volley') compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.facebook.android:facebook-android-sdk:4.7.0' compile 'com.android.support:design:23.1.1' compile files('libs/wepay.jar') } – pratiti-systematix Jan 19 '16 at 12:49

0 Answers0