Please refer to Branch's SDK Documentation for Capacitor for installation. You do not need to add Branch to the MainActivitcy class in Android. Remove it if you added it.
Install
npm install @innomobile/capacitor-branch-deep-links
npx cap sync
Inside your project use
import{BranchDeepLinks,BranchShortUrlAnalytics}from'@innomobile/capacitor-branch-deep-links';
@Injectable({providedIn: 'root',})exportclassBranchService{asyncgenerateShortUrl(analytics,properties){try{constresponse=awaitBranchDeepLinks.generateShortUrl({analytics, properties})returnresponse.url}catch(err){// do something on error}}}