Skip to content Skip to sidebar Skip to footer

Unexpected Character $ - Java Binding Error

I am trying java binding to a Xamarin forms project and the jar contains class name having $ and also variable names with $. I am getting 'Unexpected Character $' error. I am tryin

Solution 1:

The sample you tried disables obfuscation for certain types or members. But $ doesn't necessary mean the code has been obfuscated. Here's the common flow for you of what to do in such cases:

  1. Navigate to the error source to see the generated output C# code. In your error message you'll most likely see something like Error: obj/Debug/src/234.cs (30, 50). Look into this file and see what happens in it on line 30. In your case you'll see a field containing $ in its name which leads to compilation error. Pay attention there is a generator comment line in this file starting with // Metadata.xml XPath ... path="/api/package[@name=...]", like this. You can just copy the path="..." part to use it for configurations in manifest.xml.
  2. Look into generated api.xml file located in obj/Debug (or obj/Release depending or your current config). Try looking for the member definition you have issue in. You should be able to find your field, method or another member there with all its attributes like static, deprecated, obfuscated etc. That's what you can affect with metadata transformations.

Now depending on your situation try one of the following:

  1. If you don't need this type or member in your code, just get rid of it by using remove-node metadata element. Get the path value from the generated sources as described above. Remember you can either remove the error member or the whole type if you don't need it.
  2. If you do need this member, define a rename transformation in metadata like this: <attr path="<copied_from_sources>" name="managedName">ValidNameHere</attr>.

Sometimes you'll need to clean the obj folder to make changes applied. Usually it works correct though.

Post a Comment for "Unexpected Character $ - Java Binding Error"