Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MainActivity cannot be cast to com.salesforce.androidsdk.phonegap.ui.SalesforceDroidGapActivity #168

Closed
RianHitori opened this issue Feb 17, 2016 · 4 comments

Comments

@RianHitori
Copy link

Hi,

I got an issue with the cordova plugin. I successfully install the sample app "contacts app" of salesforce plugin using Android Studio.
After I run the app I got this error:

getAuthCredentialsError: com.salesforce.contactexplorer.MainActivity cannot be cast to com.salesforce.androidsdk.phonegap.ui.SalesforceDroidGapActivity

Anyone know about this issue?

Thank you.

@wmathurin
Copy link
Contributor

Give us more information.
Did you use forcedroid to create the application?
Was there any error during the application generation?

@RianHitori
Copy link
Author

Hi @wmathurin,

I followed this instruction - https://developer.salesforce.com/docs/atlas.en-us.mobile_sdk.meta/mobile_sdk/dev_hybrid_apps_run.htm

I ran:

git clone https://github.com/forcedotcom/SalesforceMobileSDK-Shared

cordova create contactsApp com.salesforce.contactexplorer contactsApp
cd contactsApp
cordova plugin add https://github.com/forcedotcom/SalesforceMobileSDK-CordovaPlugin
cordova plugin add org.apache.cordova.contacts
cordova plugin add org.apache.cordova.statusbar
cordova platform add android 
cordova platform add ios 
cp -RL <local path to SalesforceMobileSDK-Shared>/samples/contactexplorer/* www/
cordova prepare

After that I open it using AndroidStudio. I added 'multiDexEnabled true' on defaultConfig:

defaultConfig {
        versionCode cdvVersionCode ?: Integer.parseInt("" + privateHelpers.extractIntFromManifest("versionCode") + "0")
        if (cdvMinSdkVersion != null) {
            minSdkVersion cdvMinSdkVersion
        }
        multiDexEnabled true
    }

The build didn't show any error. After I open the app on my android device I see the error above and the salesforce login page is not showing. It works fine on my iOS device.

Thank you.

@wmathurin
Copy link
Contributor

I think if you were to do the cordova platform add before you do the cordova plugin add it would work.

Anyway, we just released Mobile SDK 4.1 a few hours ago.
Among other things, we added a "after-platform-add" hook to the plugin, so it should now work regardless of the order of the cordova platform add and cordova plugin add.

Please re-open if you still have issues.

@RianHitori
Copy link
Author

Thanks @wmathurin. I will test using new version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants