Search code examples
androidcordovaandroid-studioionic-frameworksalesforce-ios-sdk

Exception: java.lang.RuntimeException: Unable to instantiate application com.salesforce.androidsdk.phonegap.app.HybridApp


I developed a hybrid mobile app integrating SalesForce Mobile SDK with Ionic using Brett Nelson's set of blog posts -

  1. After following the set of instructions in this post - https://wipdeveloper.com/2017/06/27/saleforce-mobile-sdk-ionic-setup-mobile-sdk/ and setting up the org and running the app in Android Studio -> emulator, the app opened up alright.

  2. After following these set of instructions - https://wipdeveloper.com/author/brettmn/page/6/

wherein I integrated (basically copy pasted) - package.json elements, resources etc. - from the CLI generated Ionic app to the SalesForce SDK project in Step 1, I cannot get to run the project in emulator.

While running, the LogCat emits the following information:

0-4310/com.wipdeveloper.contacts E/AndroidRuntime: FATAL EXCEPTION: main Process: com.wipdeveloper.contacts, PID: 4310 java.lang.RuntimeException: Unable to instantiate application com.salesforce.androidsdk.phonegap.app.HybridApp: java.lang.ClassNotFoundException: Didn't find class "com.salesforce.androidsdk.phonegap.app.HybridApp" on path: DexPathList[[zip file "/data/app/com.wipdeveloper.contacts-gVdyqj5Na6koBXGU6VuxfA==/base.apk", zip file "/data/app/com.wipdeveloper.contacts-gVdyqj5Na6koBXGU6VuxfA==/split_lib_dependencies_apk.apk", zip file "/data/app/com.wipdeveloper.contacts-gVdyqj5Na6koBXGU6VuxfA==/split_lib_slice_0_apk.apk", zip file "/data/app/com.wipdeveloper.contacts-gVdyqj5Na6koBXGU6VuxfA==/split_lib_slice_1_apk.apk", zip file "/data/app/com.wipdeveloper.contacts-gVdyqj5Na6koBXGU6VuxfA==/split_lib_slice_2_apk.apk", zip file "/data/app/com.wipdeveloper.contacts-gVdyqj5Na6koBXGU6VuxfA==/split_lib_slice_3_apk.apk", zip file "/data/app/com.wipdeveloper.contacts-gVdyqj5Na6koBXGU6VuxfA==/split_lib_slice_4_apk.apk", zip file "/data/app/com.wipdeveloper.contacts-gVdyqj5Na6koBXGU6VuxfA==/split_lib_slice_5_apk.apk", zip file "/data/app/com.wipdeveloper.contacts-gVdyqj5Na6koBXGU6VuxfA==/split_lib_slice_6_apk.apk", zip file "/data/app/com.wipdeveloper.contacts-gVdyqj5Na6koBXGU6VuxfA==/split_lib_slice_7_apk.apk", zip file "/data/app/com.wipdeveloper.contacts-gVdyqj5Na6koBXGU6VuxfA==/split_lib_slice_8_apk.apk", zip file "/data/app/com.wipdeveloper.contacts-gVdyqj5Na6koBXGU6VuxfA==/split_lib_slice_9_apk.apk"],nativeLibraryDirectories=[/data/app/com.wipdeveloper.contacts-gVdyqj5Na6koBXGU6VuxfA==/lib/x86, /system/lib, /vendor/lib]] at android.app.LoadedApk.makeApplication(LoadedApk.java:989) at android.app.ActivityThread.handleBindApplication(ActivityThread.java:5715) at android.app.ActivityThread.-wrap1(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1656) at android.os.Handler.dispatchMessage(Handler.java:106)


The manifest file looks like this -> enter image description here

The project structure is as below ->

enter image description here

What is the configuration that is missing? Or incorrect?

Note: This question here seems to have a similar problem, but no resolution: Unable to instantiate application com.salesforce.androidsdk.phonegap.app.HybridApp: java.lang.ClassNotFoundException:


Solution

  • After step 2 in your question, you may have to remove and then re-add the platform you are targeting.

    For iOS

    ionic cordova platform remove ios
    ionic cordova platform add [email protected]
    

    Or for Android

    ionic cordova platform remove android
    ionic cordova platform add [email protected]
    

    If you do that and still have problems try removing and re-adding the salesforce mobile sdk.

    cordova plugin remove com.salesforce
    cordova plugin add https://github.com/forcedotcom/SalesforceMobileSDK-CordovaPlugin --force