Bug 15559 - javac compilation failed is path contains accentuated characters
Summary: javac compilation failed is path contains accentuated characters
Alias: None
Product: Android
Classification: Xamarin
Component: Tools and Addins ()
Version: 4.10.0.x
Hardware: Macintosh Mac OS
: Normal normal
Target Milestone: 4.12.0 (KitKat)
Assignee: Jonathan Pryor
Depends on:
Reported: 2013-10-21 15:09 UTC by Stephane Delcroix
Modified: 2013-12-17 02:55 UTC (History)
5 users (show)

Is this bug a regression?: ---
Last known good build:

Test Project (13.37 KB, application/x-zip-compressed)
2013-12-16 03:46 UTC, narayanp

Notice (2018-05-24): bugzilla.xamarin.com is now in read-only mode.

Please join us on Visual Studio Developer Community and in the Xamarin and Mono organizations on GitHub to continue tracking issues. Bugzilla will remain available for reference in read-only mode. We will continue to work on open Bugzilla bugs, copy them to the new locations as needed for follow-up, and add the new items under Related Links.

Our sincere thanks to everyone who has contributed on this bug tracker over the years. Thanks also for your understanding as we make these adjustments and improvements for the future.

Please create a new report on Developer Community or GitHub with your current version information, steps to reproduce, and relevant error messages or log files if you are hitting an issue that looks similar to this resolved bug and you do not yet see a matching new report.

Related Links:

Description Stephane Delcroix 2013-10-21 15:09:55 UTC
So I have a project which is in French and happen to have a "é" in the name. I wasn't forced to, it's even a bad practice, but I used that accentuated character in namespace and project name.

Compilation works fine on monotouch, but fails when I compile an android project:

/Library/Frameworks/Mono.framework/External/xbuild/Xamarin/Android/Xamarin.Android.Common.targets: error : Tool exited with code: 2. Output: javac: file not found: obj/Debug/android/src/aéiou/MainActivity.java

it looks related to #bug 10669, which is marked as resolved. But I'm up to date and it still fails
Comment 1 Jonathan Pryor 2013-11-21 16:58:14 UTC
Bug #10669 was (1) on Windows, not OS X, and (2) didn't involve javac.

Javac is...interesting. In order to avoid command line length limits, we generate a response file for Javac to use. Javac in turn wants the response file to be encoded in the default encoding for the platform -- it doesn't use the `javac -encoding` parameter to control the encoding of response files (go figure).

We had assumed that on OS X, "of course" the default character set for Java would be UTF-8, and always generated UTF-8 formatted response files.

This assumption was wrong; the default character set for Java is, in fact, MacRoman.


So the short (ha!) version is that compilation fails for you because the filename we stuck in the response file doesn't decode properly in MacRoman, so it can't find the file.

Unfortunately, MacRoman isn't a Unicode-aware character set, so even if we did generate a MacRoman-encoded response file you couldn't use full Unicode. ('é' may work, but use Japanese or some other eastern character and you're screwed.)
Comment 2 Jonathan Pryor 2013-11-21 17:00:46 UTC
The desired fix, then, is to somehow coerce javac to use a UTF-8 encoded response file. Some investigation later, and this is actually possible by using `javac -J-Dfile.encoding=UTF8`. Yay! (Then we hit a Unicode Normalization issue, but that's neither here nor there...)

Fixed in monodroid/1c565055
Comment 3 narayanp 2013-12-16 03:44:59 UTC
I have checked this issue with following build:

Mac Lion
X.S 4.2.2(build 2)
Mono 3.2.6
X.Android 4.11.0-208

I am still getting same error when debug/run the application which is having é in name and namesapce.

Build Output: https://gist.github.com/saurabh360/62a51bbf359d1255826b

Hence, Reopening this issue
Comment 4 narayanp 2013-12-16 03:46:15 UTC
Created attachment 5668 [details]
Test Project
Comment 5 Jonathan Pryor 2013-12-16 11:06:57 UTC
@narayanp: Comment #3 is a different bug. The original report was that `javac` issued an error because it couldn't find a file, while Comment #3 is that `jarsigner` is failing with a java.lang.NullPointerException.

`javac` was executed and finished successfully.

However, your test case (Attachment #5668 [details]) is not in fact a testcase for _this_ bug; it would be an excellent testcase for a _new_ bug.

To test _this_ bug, the project would need to contain a type that contains accented characters and also subclasses Java.Lang.Object, for example:

    [Activity(Label = "éqnéè", MainLauncher = true)]
    partial class éqnéè : Activity {

The above should build without error so long as it's in an assembly that doesn't contain accented characters.

Please file a new bug for Comment #3. The issue is (apparently) that we're not UTF-8 encoding filenames _within_ the .apk/ZIP container: http://bugs.sun.com/view_bug.do?bug_id=6272251

> Unlike a zip file, the jar file's entry names must be UTF-8 encoded, therefore it should be
> maintained by the jar/jarsigner command only for safety.
Comment 6 Prashant manu 2013-12-17 02:55:05 UTC
I have checked this issue with following builds:

All Mac
X.S 4.2.3(build 20)
Mono 3.2.6

I have used below code in my application:
[Activity(Label = "éqnéè", MainLauncher = true)]
    partial class éqnéè : Activity {

Application deployed and launched on device.