How do I create a bundle/package ID that works for both iOS and Android?


#1

Hi,

I’m having some issues with running the app on iOS and Android emulators using the same bundle ID and not sure how to create one in order to run on both platforms.

When I generate a new app template, by default it uses nativescript’s bundle id. Eg, in the package.json file, the “nativescript.id” property is set to “com.nativescript.PROJECTNAME”. While this works for basic builds, I wanted to use my own developer id.

For iOS it wasn’t an issue. In Xcode, I selected my dev id and called it a day. In the package.json file I set the “nativescript.id” property to my own iOS dev id. (eg: com.MYCOMPANY.PROJECTNAME).

While this works fine for iOS, I can’t use this for building for Android. Not even for emulator use. Using tns run android, I get the error android.content.pm.PackageManager$NameNotFoundException:

I have never done builds and signings for Android, so I was following the docs here:
https://docs.nativescript.org/publishing/publishing-android-apps

and the Android key signing procedure here:
https://developer.android.com/studio/publish/app-signing.html

I’m not able to get rid of the error. Anyone knows why “com.MYCOMPANY.MYPROJECTNAME” is not valid and where/show should I set this?

When I set it back to “com.nativescript.PROJECTNAME” it works. But obviously that’s not how I want it. And keep changing it back and forth once for iOS build and once for Android, is an obvious pain.

Thanks!


#2

It seems I was able to figure this out after some headaches. Since I’m new to the Android platform, I’m not familiar with the gradle and other manifesto files, and made some errors by adding the right things to the wrong places and the wrong things to the right places :hammer_and_wrench: