简体   繁体   中英

Adding Firebase Ads to Xamarin.Forms causes: Name cannot begin with the '$' character, hexadecimal value 0x24

Windows ONLY This bug does NOT happen on a mac using the same solution.

Adding Firebase Ads to Xamarin.Forms causes: Name cannot begin with the '$' character, hexadecimal value 0x24 Visual studio shows this as a warning but it is actually stopping by the 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 ==========

No files in the visual studio solution have names starting with '$'

Steps to reproduce

  1. Make a new Xamarin.Forms project
  2. Install the Xamarin.Firebase.Ads package from NuGet
  3. Build the Android project

1>Name cannot begin with the '$' character, hexadecimal value 0x24. should not break your code. (Admittedly I've been ignoring this error for weeks now and I have no issue compiling).

From your output I would assume the issue is because 1>"apksigner.BAT" exited with code 2. From experience, I have had a similar issue as the result of a application size. Android has a limit of 65k methods that can easily be met when including Google Services. The solution is to enable multidex.

All in all, Name cannot begin with the '$' character should not cause a fatal error yet if my previous suggestion does not work, I suggest you look into renaming mscorlib properly (yet similarly unlikely to be the root of your problem) and then your signing process (without proper details I can't suggest a solution here, but errors while signing your apk will at the very least crash your app if not terminate the build) because

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM