forcedotcom / SalesforceMobileSDK-Android

Android SDK for Salesforce
Other
341 stars 386 forks source link

Facing issues while updating salesforce mobile SDK from 10 to 12 #2572

Closed hemantsumanmetacube closed 1 month ago

hemantsumanmetacube commented 4 months ago

We are trying to update Salesforce Mobile SDK from 10.2 to 12.1, So we created a new project using forcehybrid create command, We identified that the SDK dependencies like SalesforceSDk, SmartStore, SalesforceHybrid etc. are included as a composite gradle module in the new project. ̇We have our custom local changes in Salesforce Mobile SDK files and also we have created a cordova plugin which is directly importing SDK libraries. Now the imports are broken in our custom plugin and changes we are doing inside the root directory/plugins.com.salesforce are not reflecting.

Screenshot 2024-05-23 at 4 08 36 PM

Please provide a solution so we can safely upgrade MobileSDK. Thanks

wmathurin commented 4 months ago

Before 11.1, generated hybrid apps always got MSDK from sources (bundled in the MSDK cordova plugin) at ./plugins/com.salesforce/src/android/

Since 11.1, generated hybrid apps get MSDK from Maven Central in production (tagged version) and from sources in pre-release (dev branch). However when getting them from sources, they are expected from a different location ./platforms/android/mobile_sdk where the MSDK is being checked out at application generation time.

In your case I recommend you check our the MSDK in the ./platforms/android/mobile_sdk location by doing

git clone --tag  v12.0.1 --single-branch --depth 1 https://github.com/forcedotcom/SalesforceMobileSDK-Android  ./platforms/android/mobile_sdk

Then apply your changes

Then the exiting code in settings.gradle will ensure it gets picked up

include ":app"
def salesforceMobileSdkRoot = new File('mobile_sdk/SalesforceMobileSDK-Android');
if (salesforceMobileSdkRoot.exists()) {
  includeBuild(salesforceMobileSdkRoot)
}

On our side, we will clean SalesforceMobileSDK-CordovaPlugin so that it no longer embeds source files from SalesforceMobileSDK-Android since they are never used.

hemantsumanmetacube commented 4 months ago

After making the changes you suggested, drawable resources related to salesforce sdk are not being found. Also getting the error when impoerting the salesforce -

error: package com.salesforce.androidsdk.accounts does not exist import com.salesforce.androidsdk.accounts.UserAccount;

wmathurin commented 3 months ago

So you have a clone of your SalesforceMobileSDK-Android fork in a folder mobile_sdk ? From Android Studio, you can tell it's picking the code from there ? Did you gradle sync and then did a clean rebuild ?

hemantsumanmetacube commented 3 months ago

Yes, I did a gradle sync and clean rebuild, it is still giving this error. Below is the project structure we are getting.

Pasted Graphic
wmathurin commented 3 months ago

You settings.gradle points to your correct folder? The following

def salesforceMobileSdkRoot = new File('mobile_sdk/SalesforceMobileSDK-Android');

expects a SalesforceMobileSDK-Android clone as a sub-directory of the mobile_sdk directory.

brandonpage commented 1 month ago

Closing due to a lack of activity.