将棋プログラミング

(将棋に関する)ソフトウェア開発のノウハウ等。

Android

Android: Gradle と Java のバージョン

新しい PC で、Android Studio (Giraffe | 2022.3.1) をインストールし、従来のプロジェクトをビルドしようとしたところ、次のエラーが表示されるようになった。 Gradle project sync failed. Basic functionality.Unable to make field private static fina…

Android Studio のプロファイル

Android アプリのある機能の実行が遅く、 「***」は応答していませんが表示されていた。入力イベントに対する応答が 5 秒以内にないと、この ANR ダイアログが表示されると説明されている。developer.android.comそれで、Android Studio のプロファイルを…

java.lang.NoSuchFieldError: No field Companion of type Lokhttp3/RequestBody$Companion;

Android で使っているライブラリを更新したところ、次の Crash が起きた。 java.lang.NoSuchFieldError: No field Companion of type Lokhttp3/RequestBody$Companion;次のように、com.squareup.okhttp3:okhttp: のバージョンを上げる必要があった。 depende…

Android SDK Platform-Tools の更新失敗

Android Studio で Android SDK Platform-Tools を更新しようとして失敗した。 次がログの一部である。 "Install Android SDK Platform-Tools (revision: 33.0.3)" failed. Failed to complete operation using com.android.tools.idea.sdk.install.patch.Fu…

Android 12 対応

アプリをアップデートしようとしたところ、次のエラーが表示された。 現在、お客様のアプリは API レベル 30 を対象にしています。セキュリティとパフォーマンスが最適化された最新の API を利用するには、API レベル 31 以上を対象にする必要があります。ア…

Android でビルドエラー:A problem occurred ...

ある日、Android Studio で、次のビルドエラーが出るようになった。 A problem occurred configuring root project 'MyProject'. > Could not resolve all artifacts for configuration ':classpath'. > Could not download j2objc-annotations.jar (com.goo…

Android:Google Play Billing Library V3 の落とし穴

2021 年 8 月 2 日以降、すべての新規アプリでは Billing Library バージョン 3 以降を使用する必要がある。 2021 年 11 月 1 日までに、既存のアプリのアップデートはすべて Billing Library バージョン 3 以降を使用する必要がある。 android-developers.g…

Android の開発で Attribute Signature requires InnerClass attribute

Android での開発中、次のエラーが出た。 Attribute Signature requires InnerClasses attribute. Check -keepattributes directive.proguard.cfg、または、proguard-rules.pro に次の行を追加し、解決した。 -keepattributes InnerClasses参考サイト: stac…

Android の開発で Unsupported method

Android での開発中、次のエラーが出た。 Unsupported method: TaskExecutionResult.getExecutionReasons(). The version of Gradle you connect to does not support that method.Clean Project メニューの実行で、解決した。

Android 10 対応で Error: json defines classes that conflict

2020年11月2日以降、アプリを更新する場合、ターゲットを Android 10 以上にしないといけない、と Google から案内されている。www.google.comそこで、targetSdkVersion と compileSdkVersion を 28 から 29 に上げた。 すると、APK 作成時に、次のエラーが…

Android の VideoView のタッチ操作を無効にする / 処理する

Android の VideoView を使ったとき、VideoView をタッチすると、その下の View でタッチ操作が処理される。 それを防止するため、VideoView のタッチ操作を無効にしようとする。 通常、View のタッチ操作を無効にするには、次のようにする。 (1) view.setEn…

Unexpected error while obtaining screenshot from device: EOF

多分、Android SDK Build-Tools を r29 にアップデイトしたことが原因で、スクリーンショットを撮る際、次のエラーになるようになった。 Unexpected error while obtaining screenshot from device: EOF次の対策で、この問題が解決した。1. Android Studio …

Android Gradle Plugin のアップデイト(2) - This should not happen under normal circumstances

リリースビルドを作成しようとしたら、次のエラーが起きた。 This should not happen under normal circumstances, please file an issue if it does. ...Gradle Plugin 3.3.2 で、2MB以上の大きさの画像を使うときに起きる Gradle Plugin のバグらしい。 次…

Android Gradle Plugin のアップデイト - ERROR: Could not find com.android.tools.build:gradle:3.3.2.

次のエラーが起きた。 ERROR: The versions of the Android Gradle plugin and Gradle are not compatible. Please do one of the following: Update your plugin to version 2.4. This will require changes to build.gradle due to API changes.そのため、…

Android - ScrollView を2重にする - NestedScrollView

Android で ScrollView を単純に2重に使った場合、一方しかスクロールしないようだ。 NestedScrollView で、2重にスクロール可能となった。 ScrollView では setScrollbarFadingEnabled が使えたが、NestedScrollView では、NullPointerException が発生し…

Twitter apps dashboard: Error You must add your mobile phone to your Twitter profile before creating an application.

Twitter を使うアプリを開発する際、Twitter apps dashboard にアプリを登録する。 今回、新しいアプリを登録しようとすると、次のエラーになった。 Error You must add your mobile phone to your Twitter profile before creating an application. Please …

android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an application

Androidアプリ開発中に、次のコードを書き、 AlertDialog.Builder ad = new AlertDialog.Builder(getApplicationContext()); 次のエラーが発生した。 android.view.WindowManager$BadTokenException: Unable to add window -- token null is not for an appl…

java.lang.NumberFormatException: Invalid int:

最近、Androidアプリ開発中に、サーバから受信したデータを数値化するため、次のコードを書いた。 String str; // サーバから受信したデータ int int_value = Integer.parseInt(str); 実行すると、次の例外が発生した。 java.lang.NumberFormatException: In…