2011年6月28日火曜日

Show GIF images in Windows Phone applications

JPEG and PNG are supported by BitmapImage of Silverlight, but GIF is not supported. However, with ImageTools available at CodePlex, GIF images can be handled.

(1) Download ImageTools from CodePlex.

http://imagetools.codeplex.com/

The format of the binary + documentation package is .rar, so utility software that can extract RAR files is required.


(2) Add DLLs found in bin\Phone folder to your project as necessary.

ImageTools.dll
ImageTools.IO.Gif.dll
ImageTools.Utils.dll


(3) Register the GIF decoder in initialization code.

ImageTools.IO.Decoders.AddDecoder<GifDecoder>();


(4) Construct an ExtendedImage instance based on GIF data.

// Create an empty ExtendedImage instance.
ExtendedImage exImage = new ExtendedImage();

// Create an instance of GIF decoder.
GifDecoder gifDecoder = new GifDecoder();

// Get a stream of GIF data from somewhere.
Stream gifStream = ...;

// Interpret the stream as GIF and set the result
// to the ExtendedImage instance.
gifDecoder.Decode(exImage, gifStream);


(5) Use as BitmapImage.

// Get a BitmapImage instance from somewhere.
BitmapImage bitmap = ...;

// Specify the ExtendedImage constructed based on GIF data
// as source of the BitmapImage.
using (var stream = exImage.ToStream())
{
    bitmap.SetSource(stream);
}


The above is an example for the case where input GIF data is available as stream, but if available as Uri, it seems to be enough to simply set the Uri to UriSource property of ExtendedImage. A code example for that case can be found at the following.

http://imagetools.codeplex.com/documentation

A class named ImageConverter implementing IValueConverter is also provided. It seems to be able to be used in XAML files.


Windows PhoneアプリでGIFを表示する

Silverlight の BitmapImage では JPEG と PNG はサポートされているものの、GIF はサポートされていない。しかし、CodePlex で公開されている ImageTools を使用すると、GIF 画像を扱うことができる。

(1) ImageTools を CodePlex からダウンロードする。

http://imagetools.codeplex.com/

バイナリ+ドキュメントのパッケージが .rar 形式なので、RAR を扱える解凍ソフトが別途必要。


(2) 解凍後の bin\Phone フォルダ以下にある DLL のうち、必要なものを適宜プロジェクトに追加する。

ImageTools.dll
ImageTools.IO.Gif.dll
ImageTools.Utils.dll


(3) 初期化コードで GIF デコーダを登録する。

ImageTools.IO.Decoders.AddDecoder<GifDecoder>();


(4) GIF データをもとに ExtendedImage のインスタンスを構築する。

// 空の ExtendedImage のインスタンスを作成する。
ExtendedImage exImage = new ExtendedImage();

// GIF デコーダのインスタンスを作成する。
GifDecoder gifDecoder = new GifDecoder();

// GIF データのストリームをどこかから持ってくる。
Stream gifStream = ...;

// ストリームを GIF として解釈し、デコード結果を ExtendedImage にセットする。
gifDecoder.Decode(exImage, gifStream);


(5) BitmapImage として利用する。

// BitmapImage インスタンスをどこかから持ってくる。
BitmapImage bitmap = ...;

// BitmapImage のソースとして、GIF データをもとに構築した
// ExtendedImage を指定する。
using (var stream = exImage.ToStream())
{
    bitmap.SetSource(stream);
}


上記は、入力 GIF データがストリームとして得られる場合の例だが、Uri として得られる場合は、単純に ExtendedImage の UriSource プロパティに Uri を設定するだけでよさそう。その場合のコード例は次の場所にある。

http://imagetools.codeplex.com/documentation

IValueConverter を実装した ImageCoverter というクラスもあるので、XAML の中でも使えそう。

2011年6月10日金曜日

Windows Phoneアプリをローカライズする

1. リソースの準備

1.1 デフォルト言語用リソースファイルを追加する

  • Visual Studio でプロジェクトを開く。
  • Solution Explorer でプロジェクト名を右クリックし、Add → New Item... と進む。
  • Add New Item ダイアログで Resources File を選択、適当なファイル名(例:AppResources.resx)を付けて Add ボタンをクリックする。


1.2 サポート対象言語用リソースファイルを追加する

  • 上記と同じ方法でリソースファイルを追加する。ファイル名にはカルチャーとランゲージを含めておく
日本語の例: AppResources.ja-JP.resx


1.3 リソースファイルをPublicアクセス可能にする

  • Solution Explorer でリソースファイルを開く。
  • AccessModifier リストボックスで Public を選択する
  • 同じ処理をすべてのリソースファイルに対しておこなう。


1.4 リソースファイルにエントリーを追加する

例:
AppResources.resx (en-US用) に次のエントリーを追加
Name=ApplicationDescriptionText
Value=This is an i18n-aware application.

AppResources.ja-JP.resx (ja-JP用) に次のエントリーを追加
Name=ApplicationDescriptionText
Value=これは国際化対応したアプリケーションです。



2. リソースの設定

2.1 デフォルトのカルチャーを定義する

  • Solution Explorer でプロジェクト名を右クリックし、Properties を選ぶ。
  • Application タブで、Assembly Information ボタンをクリックする。
  • Neutral Language でデフォルトのカルチャー(例: English (United States))を選択し、OK ボタンをクリックする。


2.2 サポート対象言語を宣言する

  • プロジェクトを閉じ、プロジェクトファイル(*.csproj)をテキストエディターで開く。
  • <SupportedCultures> タグを見つけ、そこに、セミコロン区切りでサポート対象言語をリストアップする。

日本語の例: <SupportedCultures>ja-JP;</SupportedCultures>




3. リソースにアクセスするための準備

3.1 リソースクラスにアクセスするためのアクセッサークラスを作成する

namespace MyApplication
{
    public class AppResourcesProvider
    {
        public AppResourcesProvider()
        {
        }

        private static AppResources appResources_ = new AppResources();

        public AppResources AppResources { get { return appResources_; } }
    }
}


3.2 アクセッサークラスのインスタンスを生成し、参照できるよう、App.xaml を編集する

Application タグに xmlns:local を追加し、Application.Resources タグに local:AppResourcesProvider を追加する。

<Application
    x:Class="MyApplication.App"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"      
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:local="clr-namespace:MyApplication"
    >

    <!--Application Resources-->
    <Application.Resources>
        <local:AppResourcesProvider x:Key="AppResourcesProvider" />
    </Application.Resources>

    <Application.ApplicationLifetimeObjects>
        <!--Required object that handles lifetime events for the application-->
        <shell:PhoneApplicationService
            Launching="Application_Launching" Closing="Application_Closing"
            Activated="Application_Activated" Deactivated="Application_Deactivated"/>
    </Application.ApplicationLifetimeObjects>

</Application>



4. リソースの利用

4.1 データバインディングを使い、アクセッサークラス経由でリソースを利用する

例:リソース ApplicationDescriptionText の値を TextBlock に設定する場合

<TextBlock Name="ApplicationDescription"
           Text="{Binding Source={StaticResource AppResourcesProvider},
                      Path=AppResources.ApplicationDescriptionText}" />



以上でローカライズの作業は終了。詳細は How to: Build a Localized Application for Windows Phone を参照のこと。

なお、リソースファイルを自動生成するためのコマンド ResGen が、自動生成するクラスのコンストラクタを internal ではなく public にしてくれれば、リソースクラスにアクセスするためのアクセッサークラスをわざわざ作成する必要はない:

http://connect.microsoft.com/VisualStudio/feedback/details/628281/silverlight-wp7-resource-files-and-binding

しかし、この問題はまだ解消されていない。

2011年6月9日木曜日

Windows Phoneのタイルにアプリケーションタイトルを表示させない

Windows Phone のタイルにアプリケーションタイトルを表示させないようにするには、WMAppManifest.xml の PrimaryToken の Title を空にする。これで、Office や XBOX のタイルのように、画像だけでタイルの見た目を構成することができる。

WMAppManifest.xml を直接編集しなくても、下記の手順でもいけそう。

  1. Visual Studio でプロジェクトを開く。
  2. Solution Explorer でプロジェクト名を右クリックし、Propertiesを選択する。
  3. Application タブの Tile options のところで、Title: を空にする。

・・・と思ったが、実際にやってみると、既に Title: に文字列が入っている状態から空文字列にしようとすると、Visual Studio が「An empty string is not allowed for Title」という警告ポップアップを出し、空文字列にすることを許してくれない(← さんからの指摘)。空文字列にしたい場合は、やはり直接 WMAppManifest.xml を編集しなければならないようだ。

2011年5月27日金曜日

How to solve "Invalid cross-thread access" error in Silverlight

In Silverlight, an UnauthorizedAccessException with the message "Invalid cross-thread access" is thrown when jobs that should be done in the UI thread are tried to be done in other threads.

To make the UI thread do something, the instance of Dispatcher class of the UI thread (there is one Dispatcher instance per Thread) needs to be obtained and jobs for the UI thread should be passed to BeginInvoke method of the instance. For example, given a variable named 'dispatcherInstance' holds an instance of Dispatcher class, the following code will work.

    dipatcherInstance.BeginInvoke(() => DoMyJob());

There are some ways to access an instance of Dispatcher class. DependencyObject class has a property named 'Dispatcher' and it is the simplest way to use it. Within classes which are derived from DependencyObject class (because UIElement class is derived from DependencyObject class, as a result, all sub classes of UIElement are included), using the property, jobs can be passed to the dispatcher by the code like below.

    Dispatcher.BeginInvoke(() => DoMyJob());

To access the Dispatcher instance of the UI thread from where the Dispatcher property is not available, System.Windows.Deployment class can be used like the following.

    Deployment.Current.Dispatcher.BeginInvoke(() => DoMyJob());

Note that because an UnauthorizedAccessException may be raised when it is tried to access the Dispatcher instance of the UI thread via the property 'Application.Current.RootVisual' (because RootVisual belongs to the UI thread), it is better to use Deployment class.

------

"Invalid cross-thread access" 問題の解決の仕方 (Silverlight)

Silverlight において、UI スレッドで処理すべきことをそれ以外のスレッドからおこなおうとすると、Invalid cross-thread access というメッセージを伴う UnauthorizedAccessException が発生してしまう。

UI スレッドに処理をさせたい場合は、UI スレッド用の Dispatcher クラスのインスタンスを取得して(UI スレッドに限らず、それぞれのスレッドが、Dispatcher クラスのインスタンスを一つだけ持っている)、そのインスタンスの BeginInvoke メソッドに、UI スレッドで実行してほしい処理を渡せばよい。例えば、dispatcherInstance という変数に Dispatcher クラスのインスタンスが入っているとした場合、次のように記述する。

    dipatcherInstance.BeginInvoke(() => DoMyJob());

Dispatcher クラスのインスタンスにアクセスする方法は幾つかある。DependencyObject には、その名も Dispatcher というプロパティーがあるので、それを利用するのが一番簡単である。DependencyObject から派生するクラス(UIElement クラスは DependencyObject クラスから派生しているので、結果的に、これには UIElement から派生する全てのクラスが含まれる)内のコードでは、このプロパティーを利用して次のように記述することで、Dispatcher に処理を渡すことができる。

    Dispatcher.BeginInvoke(() => DoMyJob());

Dispatcher プロパティーにアクセスできない場所から UI スレッドの Dispatcher インスタンスを取得したい場合は、System.Windows.Deployment クラスを使用して、次のように記述する。

   Deployment.Current.Dispatcher.BeginInvoke(() => DoMyJob());

なお、Application.Current.RootVisual というプロパティー経由で UI スレッドの Dispatcher にアクセスしようとすると、UnauthorizedAccessException が発生しうるので(RootVisual は UI スレッドに属しているので)、Deployment クラスの方を使うのがよい。

2011年4月13日水曜日

Programming Windows Phone 7 : The Standard Silverlight Files

Programming Windows Phone 7
Chapter 1: Hello, Windows Phone 7
The Standard Silverlight Files (p10)

スケルトンファイルの組が二つある。App.xaml と App.xaml.cs という組と MainPage.xaml と MainPage.xaml.cs という組の二つ。xaml は Extensible Application Markup Language (XAML) で、zammel と発音する。cs は C# のこと。 cs ファイルは xaml ファイルに関連付けられている。

App.xaml.cs には、プロジェクト名と同じネームスペースで、Silverlight の Application を拡張する App クラスが定義される。

namespace SilverlightHelloPhone
{
    public partial class App : Application
    {
        public App()
        {
            ...
            InitializeComponent();
            ...
        }
        ...
    }
}

アプリケーションの初期化、起動、終了等のアプリケーション全体の処理はここに記述する。

App.xaml のほうは次のようになる。

<Application
    x:Class="SilverlightHelloPhone.App"
    ...>
    ...
</Application>

x:Class で指定されたクラスが、Silverlight の Application クラスを拡張したクラスであるという意味になる。

Visual Studio はコンパイル時に App.xaml をパースし、App.g.cs を生成する。g は generated を意味する。App.g.cs は \obj\Debug サブディレクトリに作成される。App.g.cs には partial である App クラスの追加の partial 定義が含まれる。InitializeComponent もそこで定義されていて、App.xaml.cs 内のコンストラクタから呼ばれる。

プログラムが開始されると、App クラスは PhoneApplicationFrame 型のオブジェクトを作成し、それをRootVisual プロパティーに設定する。このフレームは 480x800 ピクセルで、画面全体を覆う。PhoneApplicationFrame オブジェクトは Web ブラウザのように動作し、MainPage と呼ばれるオブジェクトへと誘導する。

MainPage は Silverlight プログラムにおいて二番目の主要クラスで、MainPage.xaml と MainPage.xaml.cs で定義される。MainPage.xaml.cs は次のようになる。

using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Microsoft.Phone.Controls;

namespace SilverlightHelloPhone
{
    public partial class MainPage : PhoneApplicationPage
    {
        public MainPage()
        {
            InitializeComponent();
        }
    }
}

System.Windows で始まる using は、Silverlight クラス群のためのもので、Microsoft.Phone.Controls 名前空間は phone 用の Silverlight 拡張のためのもので、PhoneApplicationPage クラスもそこに含まれる。

PhoneApplicationPage を拡張するクラス MainPage が、プログラムを起動したときの見た目を定義するものとなる。

MainPage.xaml は次のようになる。

<phone:PhoneApplicationPage
    x:Class="SilverlightHelloPhone.MainPage"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    xmlns:phone="clr-namespace:Microsoft.Phone.Controls;assembly=Microsoft.Phone"
    xmlns:shell="clr-namespace:Microsoft.Phone.Shell;assembly=Microsoft.Phone"
    xmlns:d="http://schemas.microsoft.com/expression/blend/2008"
    xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
    mc:Ignorable="d" d:DesignWidth="480" d:DesignHeight="768"
    FontFamily="{StaticResource PhoneFontFamilyNormal}"
    FontSize="{StaticResource PhoneFontSizeNormal}"
    Forground="{StaticResource PhoneForegroundBrush}"
    SupportedOrientation="Portrait" Orientation="Portrait"
    shell:SystemTray.IsVisible="True">

    <!--LayoutRoot is the root grid where all page content is placed-->
    <Grid x:Name="LayoutRoot" Background="Transparent">
        <Grid.RowDefinitions>
            <RowDefinition Height="Auto"/>
            <RowDefinition Height="*"/>
        </Grid.RowDefinitions>

        <!--TitlePanel contains the name of the application and page title-->
        <StackPanel x:Name="TitlePanel" Grid.Row="0" Margin="12,17,0,28">
            <TextBlock x:Name="ApplicationTitle" Text="MY APPLICATION"
                       Style="{StaticResource PhoneTextNormalStyle}"/>
            <TextBlock x:Name="PageTitle" Text="page name" Margin="9,-7,0,0"
                       Style="{StaticResource PhoneTextTitle1Style}"/>
        </StackPanel>

        <!--ContentPanel - place additional content here-->
        <Grid x:Name="ContentPanel" Grid.Row="1" Margin="12,0,12,0">
        </Grid>
    </Grid>
</phone:PhoneApplicationPage>

x:Class で指定されている SilverlightHelloPhone.MainPage が PhoneApplicationPage クラスを拡張するクラスだということがわかる。

d ("designer") と mc ("markup compatibility") の二つの名前空間は、Expression Blend や Visual Studio といった、XAML デザインプログラムのためのもの。

コンパイルにより、MainPage.g.cs が生成され、そこに MainPage クラスの追加部分定義が含まれる。そこには InitializeComponent メソッドも含まれ、それは MainPage.xaml.cs 内のコンストラクタから呼ばれる。

Silverlight の多くのクラスが次のクラス階層内にある。


    Object
        DependencyObject (abstract)
            UIElement (abstract)
                FrameworkElement (abstract)


UIElement はビジュアルオブジェクトで、ユーザ入力を受け付ける。Silverlight では、全てのビジュアルオブジェクトがユーザ入力を受け取ることができる。


FrameworkElement は UIElement から派生する唯一のクラスであるが、これは Windows Presentation Foundation 由来のもので、開発者が独自のフレームワークを作成するためのものであるが、Silverlight ではそういうことはできないので、UIElement と FrameworkElement の違いに意味はない。

FrameworkElement を拡張するクラスとして、Control、Panel、TextBlock、などがある。

MainPage.xaml 内のネストされた要素群はビジュアルツリーを定義する。Windows Phone 7 用の Silverlight プログラムでは、ビジュアルツリーは常に PhoneApplicationFrame 型のオブジェクトから開始し、これは、端末の全画面を覆う。 Windows Phone 7 用の Silverlight プログラムは、常に PhoneApplicationFrame のインスタンスを一つだけ持つ。これは非公式に「フレーム」と呼ばれる。

一方、PhoneApplicationPage のインスタンスは複数存在する。これは非公式には「ページ」と呼ばれる。フレームは一度に一つのページしか保持しない。デフォルトでは、システムトレイ(ステータスバー)用の領域をあけるため、ページはフレームの全サーフィスを覆うことはしない。

TextBlock をセンタリングするため、HorizontalAlignment、VerticalAlignment というプロパティーを使用できる。

    <TextBlock Text="Hello, Windows Phone 7!"
        HorizontalAlignment="Center"
        VerticalAlignment="Center"/>

2011年4月10日日曜日

Eclipse に Javadoc を英語で生成させる

Eclipse で、「プロジェクト」→「Javadoc の生成」により Javadoc を生成させるとき、デフォルトの言語用のテンプレートが使用されるようで、「Javadoc を英語で生成したいのだけど、日本語用のテンプレートが使用されてしまう」というようなことがおこってしまう。

「Javadoc の生成」→「次へ」→「次へ」で表示されるダイアログに「追加の javadoc オプション」というのがあるので、これに「-locale en_US」を加えても、「javadoc: エラー - オプション -locale は、コマンド行の最初に指定する必要があります。」というエラーが出てしまう。このとき、「この Javadoc エクスポートの設定を Ant スクリプトとして保管」にチェックを付けて Eclipse に生成させた javadoc.xml の中身を確認すると、Ant の javadoc タスクに「additionalparam=" -locale en_US"」というのが追加されているのが分かる。

    <javadoc access="public" additionalparam=" -locale en_US" ...>

この additionalparam を削除し、(javadoc タスクには locale というパラメータがあるので)かわりに「locale="en_US"」を追加する、ということを手作業でおこなっても、依然として日本語のテンプレートが使われてしまう。

最終的には、「追加の javadoc オプション」ではなく、「VM オプション」のほうに「 -J-Duser.language=en 」を指定することで、英語用テンプレートを使って Javadoc を生成させることができた。

2011年3月18日金曜日

Usage of dx --dex (dx --dex の使い方)

USAGE

    dx --dex [OPTIONS] FILES...


OVERVIEW

    Convert Java class files into Dalvik dex format.


OPTIONS

    --

        Stops parsing options. Arguments after this are regarded as FILES
        even if they start with "-". Note that parsing options is stopped
        also when an argument that does not start with "-" is found.

    --debug

    --verbose

    --verbose-dump

    --no-files

        Ignores input files. If this option is given, FILES specified on
        the command line are ignored. To put it another way, if this
        option is not given, FILES must be specified on the command line.

    --no-optimize

        Skips optimization on methods. The resultant dex file is not
        optimized but is generated speedily. See --optimize-list option.

    --no-strict

        Skips the following checks.

          1. Whether the format version of input class files are in the
             range which this dx command can handle.

          2. Whether path names of input class files match the declared
             package/class names.

    --core-library

        Allows classes under the following packages to be contained as
        input files. Note that javax sub packages that are not listed below
        can be contained without this option except classes which directly
        belong to javax package (e.g. javax.MyClass).

          java
          javax.accessibility
          javax.crypto
          javax.imageio
          javax.management
          javax.naming
          javax.net
          javax.print
          javax.rmi
          javax.security
          javax.sound
          javax.sql
          javax.swing
          javax.transaction
          javax.xml

    --statistics

    --optimize-list=FILE

        Specifies a file which contains a newline-separated list of method
        names. Methods listed in the file are optimized. Note that if this
        option is given, methods which are not explicitly listed are not
        optimized.

        This option and --no-optimize-list option are mutually exclusive.
        If neither of this option nor --no-optimize-list option is given,
        all methods are optimized by default unless --no-optimize option
        is given.

    --no-optimize-list=FILE

        Specifies a file which contains a newline-separated list of method
        names. Methods listed in the file are not optimized. Note that if
        this option is given, methods which are not explicitly listed are
        optimized.

        This option and --optimize-list option are mutually exclusive. If
        neither of this option nor --optimize-list option is given, all
        methods are optimized by default unless --no-optimize option is
        given.

    --keep-classes

        Adds input class files into the output dex file. Output files
        generated with this option contain both classes.dex file and
        .class files, so the size is larger than ones generated without
        this option, but such files can be used both on Dalvik VM and
        Java Standard Edition VM.

    --output=FILE

        Specifies the name of the output file. The extension of FILE must
        be one of the following: ".zip", ".jar", ".apk" and ".dex". "-" is
        also allowed as FILE and if it is specified, the output goes to the
        standard output.

    --dump-to=FILE

        Specifies where human-readable output should go. If --dump-method
        option is not given, the default value used when this option is
        not explicitly specified is "-" which means that human-readable
        output is written to the standard output.

    --dump-width=N

        Specifies the maximum width of the human-oriented output. N must
        be equal to or greater than 40.

    --dump-method=METHOD

        Dumps information about a specified method in human-readable format.
        If this option is given, the normal dex output is not generated.

        METHOD is a fully-qualified method name. The last letter of METHOD
        can be '*', and in such a case, '*' is regareded as a wildcard and
        all methods that match the pattern are dumped.

    --positions=POSITION

        Specifies how much position information should be preserved.
        Possible values of POSTION and their meanings are as follows.
        The default value is "lines".

          "none"         No position information is preserved.

          "lines"        Line number information is preserved.

          "important"    Important position information is preserved.
                         This contains block starts and instructions
                         that might throw.

    --no-locals

        Discards information about local variables.


FILES

    Class files, jar files or directories which contain class files.


-------------------------------------------------

■ 使い方

    dx --dex [オプション] ファイル...


■ 概要

    Java クラスファイルを Dalvik DEX フォーマットに変換する。


■ オプション

    --

        オプション解析を終了する。これに続く引数は、たとえ "-" で始まって
        いてもファイルとみなされる。"-" で開始しない引数が見つかったときにも
        オプション解析は終了する。

    --debug

    --verbose

    --verbose-dump

    --no-files

        入力ファイルを無視する。このオプションが与えられると、コマンド
        ライン上に指定されたファイル群は無視される。別の言い方をすると、
        このオプションを与えない場合は、コマンドライン上でファイル群を
        必ず指定しなければならない。

    --no-optimize

        メソッドの最適化をおこなわない。出力 DEX ファイルは最適化されないが、
        生成処理は速くなる。--optimize-list オプションを参照のこと。

    --no-strict

        次のチェックをおこなわない。

          1. 入力クラスファイルのフォーマットバージョンが、dx コマンドが
             扱える範囲にあるかどうか。

          2. 入力クラスファイルのパス名と、宣言されているパッケージ/
             クラス名が合っているかどうか。

    --core-library

        下記のパッケージ下のクラスが入力ファイルに含まれていても許容する。
        このオプションを与えなくても、下記にリストされていない javax サブ
        パッケージを含めることはできるが、javax パッケージに直接属するクラス
        (javax.MyClass 等) は除く。

          java
          javax.accessibility
          javax.crypto
          javax.imageio
          javax.management
          javax.naming
          javax.net
          javax.print
          javax.rmi
          javax.security
          javax.sound
          javax.sql
          javax.swing
          javax.transaction
          javax.xml

    --statistics

    --optimize-list=FILE

        改行で区切られたメソッド名のリストを含むファイルを指定する。その
        ファイルにリストされているメソッド群は最適化される。このオプションが
        指定された場合、明示的にリストされていないメソッドは最適化されない
        ので注意。

        このオプションと --no-optimize-list オプションは相互排他である。
        このオプションも --no-optimize-list オプションも与えられなかった
        場合、--no-optimize オプションが与えられない限り、デフォルトで
        全てのメソッドが最適化される。

    --no-optimize-list=FILE

        改行で区切られたメソッド名のリストを含むファイルを指定する。その
        ファイルにリストされているメソッド群は最適化されない。このオプションが
        指定された場合、明示的にリストされていないメソッド群は最適化される。

        このオプションと --optimize-list オプションは相互排他である。この
        オプションも --optimize-list オプションも与えられなかった場合、
        --no-optimize オプションが与えられない限り、デフォルトで全ての
        メソッドが最適化される。

    --keep-classes

        入力クラスファイル群を出力 DEX ファイルに追加する。このオプションを
        与えて生成されたファイルは classes.dex ファイルと .class ファイル群の
        両方を含む。そのため、このオプション無しで生成されたものよりもサイズは
        大きくなるが、Dalvik VM と Java Standard Edition VM の両方で使用する
        ことができるようになる。

    --output=FILE

        出力ファイルの名前を指定する。FILE の拡張子は、".zip", ".jar", ".apk",
        ".dex" のいずれかでなければならない。FILE として "-" を指定することも
        可能で、その場合、出力は標準出力に対してなされる。

    --dump-to=FILE

        人間が読める形式の出力の送り先を指定する。--dump-method オプションが
        与えられていない場合、このオプションが明示的に指定されていないときの
        デフォルト値は "-" であり、これは、人間が読める形式の出力が標準出力に
        書き込まれることを意味する。

    --dump-width=N

        人間が読める形式の出力の最大幅を指定する。N は 40 以上でなければならない。

    --dump-method=METHOD

        指定されたメソッドに関する情報を人間が読める形式で出力する。この
        オプションが与えられた場合、通常の DEX 出力は生成されない。

        METHOD は完全修飾メソッド名である。METHOD の最後の文字を '*' にする
        ことができ、その場合は '*' はワイルドカードとみなされ、そのパターンに
        適合する全てのメソッドがダンプされる。

    --position=POSITION

        位置情報をどの程度保持するかを指定する。POSITION に取りうる値とそれらの
        意味は下記のとおり。デフォルト値は "lines"。

          "none"         位置情報を保持しない。

          "lines"        行番号情報を保持する。

          "important"    重要な位置情報を保持する。これには、ブロックの
                         開始や例外を投げうるインストラクションが含まれる。

    --no-locals

        ローカル変数に関する情報を破棄する。


■ ファイル...

    クラスファイル、JAR ファイル、もしくはクラスファイルを含むディレクトリ。