I'm using Mono for Android to create a Android application that uses a large number of class libraries already developed. When I add the project as a reference to the android application, I get a warning stating
Warning 1 The project 'ProjectName' cannot be referenced. The referenced project is targeted to a different framework family (.NETFramework)
My project is targeting .NET Framework 4. My android application specifies "Minimum Android to target = Android 4.0".
This is a warning but when I add the using statement to the Activity.cs class in the android app, I get several errors that appear in the referenced library. Then if I remove the using statement and rebuild, the errors go away.
Do I have to change some settings in the Mono for Android project to be able to reference libraries that target .NET framework 4.0?
You can't reference libraries that target the .Net framework.
What you have to do if you want to re-use that code is create a new Android class library project and add the files from the existing .Net library as "linked" files. This is the way to get code re-use across frameworks.
As an example of this, check out the RestSharp project on GitHub. You can see that the projects for MonoDroid, MonoTouch etc have no files, but links to the common source.
Hopefully in your case, all the code in your existing libraries is compatible with the profile of the MonoDroid framework. Otherwise, you'll have to include preprocessor directives - this can also be seen in RestSharp.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With