# config.xml

`config.xml` 設定ファイルを使用して、Cordova のさまざまな設定を管理します。

![](/files/-Mgd5atp_RFkfQ8JWVix)

設定可能な要素と preference を次に記します。必要に応じて設定します。

## \<widget> 要素

| 属性                    | 型   | デフォルト値                                                                                                                                                                                          | 解説                                                                                             |
| --------------------- | --- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ---------------------------------------------------------------------------------------------- |
| `version`             | 文字列 | `1.0.0`                                                                                                                                                                                         | ユーザー側に表示するバージョン番号です。                                                                           |
| `android-versionCode` | 文字列 | 自動的にセットされます。`version` 属性に `"1.22.33"` を設定した場合、 102233 (=1 *10000 + 22* 100 + 33) となります。また、Crosswalk をプロジェクトで使用している場合、ARM アーキテクチャを使用しているときは、`2xxxxxx` となり、x86 アーキテクチャを使用しているときは、`7xxxxxx` となります。 | 内部で使用するバージョン番号です。最新バージョンを決定するときに使用されます。比較して、数が多いほうが、より新しいバージョンとなります。このバージョン番号は、ユーザー側には表示されません。 |

**例**

```markup
<widget id="com.example.helloworld" version="0.0.1" android-versionCode="7">
  ...
</widget>
```

## \<content> 要素

| 属性    | 型   | デフォルト値        | 解説                                                                                                                       |
| ----- | --- | ------------- | ------------------------------------------------------------------------------------------------------------------------ |
| `src` | 文字列 | `indext.html` | `<content>` 要素には、アプリ起動時のページを指定します ( 通常、Web アセットを置いた、最上位のディレクトリーにこのページは置かれます )。 `src` 属性の値に、他の URL を指定すれば、起動時のページを変更できます。 |

**例**

```markup
<widget id="com.example.helloworld" version="1.0.0">
  ...
  <content src="https://monaca.io/" />
</widget>
```

## \<access> 要素

| 属性       | 型   | デフォルト値 | 解説                                                                                    |
| -------- | --- | ------ | ------------------------------------------------------------------------------------- |
| `origin` | 文字列 | `*`    | `<access>` 要素を使用して、特定のネットワークドメインへのアクセスを宣言します。 `*` に設定された場合、アプリからすべてのドメインへのアクセスを許可します。 |

**例**

```markup
...
<access origin="*" />
...
```

## *\<preference> 要素*

`<preference>` タグでは、name と value の組み合わせ形式で、オプションを設定します。preference の name では、大文字小文字は区別されません。preference の多くは、各プラットフォーム毎に設定する必要があります。次の preference に関しては、複数のプラットフォームに適用できます。

<table data-header-hidden><thead><tr><th>Preference 名</th><th width="106">型</th><th width="135">デフォルト値</th><th>解説</th></tr></thead><tbody><tr><td>Preference 名</td><td>型</td><td>デフォルト値</td><td>解説　　　　</td></tr><tr><td><code>KeepRunning</code></td><td>真偽値</td><td><code>true</code></td><td>バックグラウンドで、Cordova が動作し続けるか否かを指定します。</td></tr><tr><td><code>DisallowOverscroll</code></td><td>真偽値</td><td><code>false</code></td><td>コンテンツのスクロール中に、コンテンツの始点または終点を過ぎた場合でも、そのことをユーザーに通知しないときには、 <code>true</code> に設定します。</td></tr><tr><td><code>Fullscreen</code></td><td>真偽値</td><td><code>false</code></td><td>画面上部のステータスバーを、非表示にできます。</td></tr><tr><td><code>SplashScreenDelay</code></td><td>数値</td><td><code>3000</code></td><td>スプラッシュ画像の表示時間を設定します ( ミリ秒単位 )。表示時間の長さは、アプリが起動するまでの最長待ち時間を意味します。</td></tr><tr><td><code>LogLevel</code></td><td>文字列</td><td><code>ERROR</code></td><td>ログの出力レベルを設定します。 <code>ERROR</code>、 <code>DEBUG</code>、 <code>WARN</code>、 <code>INFO</code>、 <code>VERBOSE</code> の 5 段階のレベルを選べます。</td></tr><tr><td><code>AndroidPersistentFileLocation*</code></td><td>文字列</td><td><code>Internal</code></td><td><p>ファイルの出力先を設定します。2 つの出力先を選択できます。</p><p></p><ul><li><code>Internal</code> : アプリで使用している内部ストレージのディレクトリーを、ファイルの出力先として指定します。</li><li><code>Compatibility</code> : 他の設定で指定されたストレージ ( または、端末側で指定するストレージ ) のルートを、ファイルの出力先として指定します。</li></ul></td></tr><tr><td><code>ScreenOrientation</code>**</td><td>文字列</td><td><code>default</code></td><td><p>端末の画面のオリエンテーションを設定します。次の 3 つの値を設定できます。</p><p></p><ul><li><code>default</code>: システム側のデフォルトのオリエンテーションを使用します。</li><li><code>landscape</code>: landscape ( 横向き ) のオリエンテーションを使用します。</li><li><code>portrait</code>: portrait ( 縦向き ) のオリエンテーションを使用します。</li></ul></td></tr></tbody></table>

**例**

```markup
...
<preference name="KeepRunning" value="false" />
<preference name="DisallowOverscroll" value="true"/>
<preference name="Fullscreen" value="true" />
<preference name="SplashScreenDelay" value="10000" />
<preference name="loglevel" value="DEBUG" />
<preference name="AndroidPersistentFileLocation" value="Internal" />
<preference name="orientation" value="default"/>
...
```

**\***: このプラグインの旧バーション ( 3.0.0 より前 ) を実装したアプリの配布をすでに行っており、加えて、なんらかのファイルシステムにファイルを保存していた場合には、preference を `Compatibility` に設定する必要があります ( データの保存先となるファイルシステムを、`config.xml` で指定していないときも同様 )。`Compatibility` から `Internal` に変更した場合、既存のユーザーは、以前使用していたファイルへアクセスできないことがあります ( 端末により、動作は異なります )。

**\*\***: There are two use ways to configure `ScreenOrientation` preference:

1. 全プラットフォーム共通の設定方法

   ```markup
   <widget>
    ....
    <preference name="orientation" value="default"/>
    ....
   </widget>
   ```
2. プラットフォーム毎の設定方法

   ```markup
   <widget>
    ...
    <platform name="android">
       <preference name="orientation" value="default"/>
    </platform>
    ...
   </widget>
   ```

## ターゲットAPIレベルの指定

`<preference>` タグに `android-targetSdkVersion` を指定することで任意のターゲットAPIレベルを指定できます。

```markup
<platform name="android">
    ...
    <preference name="android-targetSdkVersion" value="34" />
    ...
</platform>
```

また、次の方法においても、ターゲットAPIレベルを設定できます。\
Monaca IDEのヘッダーメニュー「設定」→ 「Androidアプリの設定」を開き、下記の「ターゲットSDKバージョン」を指定する。

<figure><img src="/files/VlXFhYX4KCO5yYjhLrh9" alt="" width="359"><figcaption><p>ターゲットAPIレベルを設定する</p></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://ja.docs.monaca.io/reference/config/android/config_xml.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
