Forum Xamarin.Android
We are excited to announce that the Xamarin Forums are moving to the new Microsoft Q&A experience. Q&A is the home for technical questions and answers at across all products at Microsoft now including Xamarin!

We encourage you to head over to Microsoft Q&A for .NET for posting new questions and get involved today.

Adding Firebase Ads to android project in visual studio

shaiifrachshaiifrach ILMember ✭✭

Hello,
I setup new Monogame android project via VS2017 community edition, select android 7 as my target
then i add via xamarin components firebase ads which adds a bunch of references of google and etc.
then i try to build the project and i see the following warning:
MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(1673,3): warning : Name cannot begin with the '$' character, hexadecimal value 0x24.

Can anyone help with that?
my VS 2017 & xamarin are both up-to-date using xamarin android 7.2

Tagged:

Posts

  • shaiifrachshaiifrach ILMember ✭✭

    bump...
    I really need help with this... i think this is the reason i cant see the ad on the ui

  • shaiifrachshaiifrach ILMember ✭✭

    bump....
    Please can someone help?
    I cant seem to get the FCM ads working on my project and i'v done what the description of the component exactly.

  • cwphillicwphilli USMember ✭✭✭

    @shaiifrach said:
    Hi @cwphilli I don't mean to hijack this thread but can you please see if you can help me with my issue
    https://forums.xamarin.com/discussion/94901/adding-firebase-ads-to-android-project-in-visual-studio#latest
    Ever since i added the firebase ads component my project is messed up
    I can't build in release mode i get the following error
    1>C:\Program Files\Microsoft Visual Studio\2017\Community\MSBuild\Xamarin\Android\Xamarin.Android.Common.targets(2025,3): error MSB6006: "java.exe" exited with code 1.

    when i open the manifest xml i get red lines under all the attributes as if their not recognized

    I can still build in debug mode and run it but with the warning i mentioned in the above linked thread and not seeing ads of course

    Change your output verbosity for more information.
    Tools -> Options -> Projects and Solutions -> Build and Run -> MSBuild project build output verbosity -> Detailed

    Look (search via CTRL+F) for any errors. Post the output in a zip file if you are unable to identify and resolve on your own.

  • shaiifrachshaiifrach ILMember ✭✭

    Hi @cwphilli Thanks for your reply,
    I did what you said but i didn't see any additional info that would help me solve this issue
    I'm attacking the build output here as requested
    you can search for the line "Name cannot begin with the '$' character, hexadecimal value 0x24" to see this issue
    When i add the FCM Ads should i have in the apk the java code binding of them as well? if so i cant see it...
    I'm using windows 32bit can it compile it?

  • cwphillicwphilli USMember ✭✭✭

    In one of your layout files, do you by chance have <? xml instead of <?xml (extra space)?

  • cwphillicwphilli USMember ✭✭✭

    Can you also provide the logcat output while running the app on your device?
    View -> Other Windows -> Device Log
    For me, when I was first implementing ads, the error in my logcat indicated that there was an invalid overlay on the ad view. It provided dimensions of the adview for me to troubleshoot directly in logcat.
    In order to figure it out, I had to go to developer options on the device itself and enable Show Layout Bounds.

    Then once that was resolved I received an error because it said my layout containing the ad was not visible.
    In fact, this was true, I was using the visibility flag to load it and when it was loaded then expand it to show the ad, however this is not allowed.
    Instead I had to set the height and width to 0dp and change it when the ad was loaded.

  • shaiifrachshaiifrach ILMember ✭✭

    Hi @cwphilli thanks for your continued help.
    I have just one layout file and there is no space between "<?" part and "xml" part
    I'm attaching the logcat of the running of the game

    What i think is relevant is the following lines
    05-11 23:06:51.963 LGE Nexus 5 Error 31660 GooglePlayServicesUtil The Google Play services resources were not found. Check your project configuration to ensure that the resources are included.
    05-11 23:06:51.963 LGE Nexus 5 Warning 31660 ResourceType For resource 0x7f06002f, entry index(47) is beyond type entryCount(11)
    05-11 23:06:51.963 LGE Nexus 5 Warning 31660 ResourceType Failure getting entry for 0x7f06002f (t=5 e=47) (error -75)

    When i de-compile my apk i dont see any of the java code that should be in com.google.gms etc, only the dlls are presents
    I think this all has to do with the warning while building with the "Name cannot begin with the '$' character, hexadecimal value 0x24"
    which somehow prevented the java side of the FCM Ads component to be included in the build

  • cwphillicwphilli USMember ✭✭✭

    What are your linker settings for your Android project?
    None, SDK Assemblies or User and SDK Assemblies?
    What is the minimum Android API that you're targeting?
    Would you be able to provide ~5 minutes worth of logcat instead of such a short duration?
    Reason being - when I was recently adding Ads for a new project, I saw that there was a retry mechanism firing every two minutes from the Google Ad API. This should give us a better understanding if there are any ads trying to be loaded.

    I noticed in your logcat you're also seeing some messages worth looking into.

  • shaiifrachshaiifrach ILMember ✭✭

    in Debug config the linker options says none
    in Release config the linker options says sdk assemblies only
    The minimun API i'm targeting is 15.
    I dont think any longer logcat would help since the problems is seeing right in the 3 lines i quoted for you in my previous post, i know about the retry mechanism but as you can see the GooglePlayServicesUtil message says it all i think...

  • cwphillicwphilli USMember ✭✭✭


    Source.

    Likely culprit:

    Source.

    Either way, that error should not be preventing you from ads being served.

  • shaiifrachshaiifrach ILMember ✭✭

    Do you have or know an app on google play that uses xamarin and have FCM ads in it that i can compare to?

  • I am getting the same error after adding this package as well, visual studio shows it as a warning but it is actually stopping my build.

    1>DccClassCancelations.Android -> D:\dev\DccClassCancelationsLite\DccClassCancelations\DccClassCancelations\DccClassCancelations.Android\bin\Debug\DccClassCancelations.Android.dll 1>No way to resolve conflict between "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" and "mscorlib, Version=2.0.5.0, Culture=neutral, PublicKeyToken=7cec85d7bea7798e". Choosing "mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" arbitrarily. 1>Name cannot begin with the '$' character, hexadecimal value 0x24. 1>C:\Program Files (x86)\Android\android-sdk\build-tools\25.0.3\zipalign.exe 4 "D:\dev\DccClassCancelationsLite\DccClassCancelations\DccClassCancelations\DccClassCancelations.Android\obj\Debug\android\bin\com.JacobErnst.DccClassCancelations.apk" "bin\Debug\\com.JacobErnst.DccClassCancelations-Signed.apk" 1>C:\Program Files (x86)\Android\android-sdk\build-tools\25.0.3\apksigner.BAT sign --ks "C:\Users\jacob\AppData\Local\Xamarin\Mono for Android\debug.keystore" --ks-pass pass:android --ks-key-alias androiddebugkey --key-pass pass:android --min-sdk-version 15 --max-sdk-version 27 bin\Debug\com.JacobErnst.DccClassCancelations-Signed.apk 1>"apksigner.BAT" exited with code 2. 1>Done building project "DccClassCancelations.Android.csproj" -- FAILED. 1>Build FAILED. 1> 1>Deploy failed on NExus6 ========== Deploy: 0 succeeded, 1 failed, 0 skipped ==========

Sign In or Register to comment.