OK, I can't get this to work
As my Android app launches I get this message
The included Syncfusion license is invalid. Please refer to this help topic(https://help.syncfusion.com/es/licensing/invalid/) for more information.
I'm building using VS2017 Community edition 15.9.4 on Win 10
I am using your instructions at https://www.syncfusion.com/kb/9179/syncfusion-license-register-without-hardcoded
- I've put my Syncfusion licence key into a system environment variable.
- I've put the pre and post build events into the project that wants to register the licence. The events point to App.xaml.cs
- I've put the registration code into App.xaml.cs ; this is the line
- I repeat the process for the Android project, with the registration code in OnCreate() in MainActivity.cs
- (I'm not building an iOS project)
If I turn VS2017 build output up to diagnostics (the highest) I can see that SyncfusionLicenseRegister.bat is being called correctly twice (pre- and post-build) but I can't see any output.
If I use DOS, go to the correct directory and run
SyncfusionLicenseRegister.bat PreBuild App.xaml.cs
I can see that the correct licence code has been inserted into App.xaml.cs
If I then run
SyncfusionLicenseRegister.bat PostBuild App.xaml.cs
I can see that the relevant line in App.xaml.cs now again holds the dummy key: "##SyncfusionLicense##"
PS: I suggest also that when creating the post-build event, you select "Run the post-build event - always". The default is " - on successful build"
This ensures that the licence key doesn't remain in the source code if the build fails, from where it might be pushed up to Github or some other public location.
Of course no dev would ever commit broken code, but it's worth checking.
PPS: With the approach above, you are still embedding the licence key in the code. I suspect someone with some intelligence could probably extract it.
I suggest it would be better to tie the licence key to something specific about the app.
Maybe with signed apps you could have a small program that takes the app signature and the licence key and then produces some kind of hash value that can be stored with the app.
This program would be run once by the developer after the app is signed.
At runtime, the Syncfusion license validator would read the hash value and the app signature and only validate the licence if correct.
This way, only the hash value would be embedded in the app and would be useless to any other application / licence combination