Xamarin - Project failed to build after adding Google cloud messagin component - xamarin

I've Google Cloud Messaging to my project but after adding it, Project stopped building. It gives build output as
C:\Program Files (x86)\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1135,2): error MSB6006: "aapt.exe" exited with code 1.
I searched through net and got info to turn on the "Log verbosity to Diagnostic". It gives the build out in detailed form and after going through the log I came to know that during build below lines gets added to manifest file:
provider android:authorities="${applicationId}.google_measurement_service" android:exported="false" android:name="com.google.android.gms.measurement.AppMeasurementContentProvider"
Issue here is the "${applicationId}", during build it should get replaced with ApplicationId.
This issue can be fixed on Android Studio by doing changes the Gradle file but I'm using Xamarin.
I'm using GCM version 29.0.0.2.
Please let me know the possible workaround.
Thanks

The current version of GCM is dependent on Google Measurement service and the error is related to Google Measurement Service.
To solve the issue I downgraded the GCM to the version which is not dependent on Google Measurement service.
you can't do it straight away as Nugget downloads the latest version. So in order to downgrade the version of GCM. Remove the updated version and specify the version of GCM to be downloaded in packages.config file.
Xamarin Studio will consider the specified version as missing package and automatically download the mentioned package.
In my case I downloaded the 27.0.0 version of GCM.

Related

How to change version of Mobile App in Xamarin?

I want to change the version of my application but when I am changing the version and version name I am getting an error: "Build Failed: Xamarin.Android does not support running the previous version. Please ensure your solution builds before running or debugging it.". When I change the version name to 1.8.2 the error will occur. How can I fix this?
As mentioned in the comments by Arvindraja, Visual Studio will prompt to deploy the previously built version if there were build errors. In the screenshot you've posted, you're showing no app icon. Perhaps that is causing this issue?
Go through the build output and see what the output says. At some point, there should be a mention of "Build failed", or similar.

Xamarin Forms on TeamCity: Xamarin.Forms tasks do not match targets

I am building a Xamarin Forms solution (containing an iOS library, an Android library and a .NET Standard library) in TeamCity.
I have just upgraded to Xamarin Forms 3.1.0.583944. The project builds without any problem locally, but on my TeamCity build server (Windows Server 2016), I'm consistently getting the following error:
C:\BuildAgent\work\f12265fda07473c1\src\packages\Xamarin.Forms.3.1.0.583944\build\netstandard2.0\Xamarin.Forms.targets(44,
3): error XF002: Xamarin.Forms tasks do not match targets. Please
ensure that all projects reference the same version of Xamarin.Forms,
and if the error persists, please restart the IDE.
I have tried downgrading Xamarin Forms, and rebooting the build agent. Neither of these has succeeded.
UPDATE: There is a new error:
C:\BuildAgent\temp\buildTmp.nuget\packages\xamarin.forms\3.0.0.561731\build\netstandard2.0\Xamarin.Forms.targets(44, 3): error XF002: Xamarin.Forms tasks do not match targets. Please ensure that all projects reference the same version of Xamarin.Forms, and if the error persists, please restart the IDE.
For some reason, the agent is looking for Version 3.0.0.561731. But that is no longer anywhere in the project. I had deleted the entire C:\BuildAgent\temp\buildTmp\.nuget\packages\xamarin.forms\3.0.0.561731 folder, but it has come back.
ADDENDUM: I notice that every time I upgrade Xamarin.Forms to this version via NuGet, it fails to uninstall the old package, and I have to restart Visual Studio to complete the process. This happens without fail. I am fairly sure this is connected to the breaking build, but that is more due to speculation and experience than concrete analysis.
I found out how to fix the problem, but it's not clear to me why it would manifest in the way it has -- locally and even when I RDP onto the build agent, it builds without trouble, but when I run the build agent from the TeamCity console I hit these compilation errors.
One of my dependencies is a NuGet package, which itself has a dependency on Xamarin Forms. Fortunately, I own that NuGet package, and was able to upgrade its Xamarin Forms version to the latest available package. If I didn't own that package I would be completely stuck though -- so this is only a partial solution.
The above answer was quite helpful for me . I would like to add a couple of additional notes though. I was facing this issue when I was using Xamarin Forms 3+ and my local build was being really inconsistent with the same error "Xamarin.Forms tasks do not match targets. Please ensure that all projects reference the same version of Xamarin.Forms, and if the error persists, please restart the IDE.". Then I cleared my local NuGet cache and rebuilt the project and saw that there were other NuGet package versions being pulled for Xamarin Forms when I did a NuGet restore. I then reversed the ordering of the NuGet packages starting with Xamarin Forms and it all worked fine.

Xamarin.android project build error in xamarin forms project

I have tried to resolve fallowing error but not luck, What my issue is while build xamarin.android project shows 'java.lang.IllegalArgumentException: already added :Landroid/support/v4/accessibilityservice/Accessibility
ServiceInfoCompat' error. I have search the cause of this error, many solutions are said that duplicate library files exist in our project i.e "xamarin.android.support.v4 and xamarin.android.support.v7". If I have remove any one of this again I am getting build faileds. If I have remove 'xamarin.android.support.v4' shows "view.pager" not found error and if I have remove 'xamarin.android.support.v7' getting lot of errors. Please suggest any idea to fix this issue. Thanks in advance.
'
Earlier I faced the same issue, I had done these steps to solve it
1) First check the Target Framework i.e Mono Android it should be version more than 7.0 ,if it is not available in the properties. Update your Android SDK manager then you can set to v7.0
2)Uninstall the Xamarin.Forms packages and support files and Reinstall all with latest version

Attempting to add an MQTT library from NuGet into Xamarin project

I saw that Xamarin was now free and decided to try writing a mobile app using it instead of what another technology I was playing with. After some various hiccups, I was able to get the new Xamarin Android project to build, deploy and run on the simulator. I then decided to try out MQTT connectivity from it before I went any further. No matter which MQTT library I to install from NuGet, for example the System.Net.Mqtt one from Xamarin, I get the following error:
"Could not install package 'System.Net.Mqtt 0.3.12-pre'. You are trying to install this package into a project that targets 'MonoAndroid,Version=v6.0', but the package does not contain any assembly references or content files that are compatible with that framework. For more information, contact the package author."
I tried several others with no success. It does the same for the ios and Android projects. I did try changing the Android SDK version to use for compiling, but still had the same result. I also don't understand why it says MonoAndroid since I thought all the Mono references were changed to Xamarin? I'm using Visual Studio 15 with Update 2. I tried the stable Xamarin version and also tried the latest alpha. I'm not sure what else to try, I'd really to give Xamarin a try for this project. I did some searching and couldn't find anything that appeared to help with this issue.
Thanks in advance for any help.
Use the Package Manager Console. Then, either:
Install the latest version of MQTT library.
Or install first its dependency, RX-Main and then MQTT.
If you still get an error, please share with us the Log that is shown in the PM Console.

Can't upgrade to newer versions of Gradle in Android Studio, nor update AS itself

I'm working with Android Studio (Beta) 0.8.14.
I wanted to update the Gradle distribution and the Gradle plugin in my project, so I started manually changing the lines:
classpath 'com.android.tools.build:gradle:0.13.+' (in build.gradle)
distributionUrl=https\://services.gradle.org/distributions/gradle-2.1-all.zip (in gradle-wrapper.properties)
by upgrading to, respectively, 1.0.0 and 2.2.1. Then I tried to use different combinations found here on SO, e.g. 0.14.4 and 2.2, as none of these seemed to work. For each combination I got (after syncing and downloading what needed) some error, like:
AssertionError: null
AssertionError: com.android.tools.idea.gradle.project.AndroidGradleProjectComponent#71c8dfe3
UnsupportedMethodException
Unsupported method: SourceProvider.getJniDirectories().
The version of Gradle you connect to does not support that method.
After some research I thought this might be related to AS itself. Looking for updates in different channels brings me either to AS 0.9.9
This patch will allow you to update from 0.x to 1.x. After updating,
please check for updates again to install 1.x.
or to AS 1.0.2.
When trying to update, I get hundreds of errors related to Android Studio not deleting some files in android_SDK_folder/sources/android-21 , mainly.
This issue has some references here on SO. Known fixes are killing java processes during the update, which was unsuccessful for me, and launching Android Studio as admin, which doesn't look like a great idea to me (and I wouldn't know how to on OS X).
I'm stuck. My questions are:
are the Gradle syncing errors due to my old build of Android Studio?
if so, what can I do to update? I don't think I should uninstall and then get 1.0.2, as the message I reported says I can patch to 0.9.9 and then to 1.x. Is this the only thing to do?
Yes, your Gradle syncing errors are due to a mismatch between the plugin and the version of Android Studio. If you want to use v1.0.0 of the plugin, you need to be running Android Studio 1.0 or later.
As for upgrading, my advice would be to do a clean reinstall of 1.0; it will be easier than trying to spend a lot of time figuring out why the upgrade isn't working. I forget where the SDK is installed in 0.8.14, but we're encouraging/requiring users to have the SDK located outside the application directory itself, so it should help avoid future SDK woes with upgrading/reinstalling Android Studio itself.
If the SDK is currently installed inside Android Studio's directory and you don't want to re-download it, you could move it out to a more sensible place before reinstalling, and point the new installation at it.

Resources