HOME技術AndroidAndroidアプリ:ERROR: This project uses AndroidX dependencies, but the ‘android.useAndroidX’ property is not enabled.

Androidアプリ:ERROR: This project uses AndroidX dependencies, but the ‘android.useAndroidX’ property is not enabled.

Android Studioでビルドしようとしたら、「ERROR: This project uses AndroidX dependencies, but the ‘android.useAndroidX’ property is not enabled. Set this property to true in the gradle.properties file and retry.」と表示され、ビルドできなかったことがあったので、その修正方法を記します。

AndroidXに対応させる方法

これはアプリがAndroidXの依存関係を使う設定になっているにも関わらず、「android.useAndroidX」プロパティが有効になっていないことが原因です。
対応するためには、gradle.propertiesで、android.useAndroidxプロパティをtrueにします。

Android Studioで、gradle.propertiesを開き、一番最後の行に以下の2行を追加します。

android.useAndroidX=true
android.enableJetifier=true

関連記事

Androidアプリ:タイトルバーを消す

Android Studioで、タイトルバーを消す方法です。 通常は、以下のように画面上部にタイトルバーが表示されています。 AndroidManifest.xmlを編集する android:them…続きを読む

Androidアプリ:Class ‘Anonymous class derived from OnItemClickListener’…のエラー

Android Studioで開発中に、ListViewを使っていて以下のようなエラーメッセージが出た場合の理由です。 Class ‘Anonymous class derived from OnIt…続きを読む

Androidアプリ:ポリシー違反の警告への対応(APIレベル)

Google Play Console上で、アプリにポリシー違反の警告が表示されていました。 「お客様のアプリはGoogle Playデベロッパープログラムポリシーを遵守していないため、まもなく措置を…続きを読む

Androidアプリ:クリックイベントとロングクリックイベントを取得する

Androidアプリで、クリックイベントとロングクリックイベントの2つを取得して処理する方法です。 OnClickListenerとOnLongClickListenerを併記 public clas…続きを読む

Androidアプリ:ボタンを押すとメッセージが入れ替わる

Android StudioでAndroidアプリを試作します。 今回は「ボタンを1回押すとテキストの内容が変わり、もう1回押すと元に戻る」というだけのアプリをつくります。 プロジェクトの生成 And…続きを読む

Androidアプリ:ボタンの表示/非表示

Androidでボタンの表示/非表示をプログラム上からコントロールします。 MainActivity.java   Button button = findViewById(R.id.but…続きを読む

Androidアプリ:アダプティブアイコンに対応する

AndroidではOS 8.0からAdaptiveアイコン(アダプティブアイコン)というアイコンを用意する必要がでてきました。 これまでの通常のアイコン、ラウンドアイコンに加えて、アダプティブアイコン…続きを読む

Androidアプリ:テキストをリスト表示する

Androidアプリで、ListViewを使い、配列に格納したテキストをリスト表示します。 MainActivity.java import android.app.Activity; import …続きを読む

Androidアプリ:ボタンやEditTextを角丸にする

Android StudioでボタンやEditTextを配置して、角丸にします。 角丸や色などを指定する場合には、それ専用のxmlファイルを別途用意し、読み込ませるようにします。 ボタンの背景色と角丸…続きを読む

Androidアプリ:ボタンをタップして別画面に遷移する

ボタンをタップしたら別画面に遷移させる方法です。 以下の例では、メイン画面の「ボタン」をクリックすると、サブ画面に移動し、サブ画面の「終了」ボタンを押すとメイン画面に戻ってきます。 メイン画面 act…続きを読む

This website stores cookies on your computer. These cookies are used to provide a more personalized experience and to track your whereabouts around our website in compliance with the European General Data Protection Regulation. If you decide to to opt-out of any future tracking, a cookie will be setup in your browser to remember this choice for one year.

Accept or Deny