AndroidでToolbarを使いMenu表示させると、
以下のように文字が見えず空欄のMenuが表示されてしまう。
これはMenuの文字色が白、背景色も白であることが原因だった。
なのでMenuの文字色を調整する方法を記載する。
AndroidでToolbarを使いMenu表示させると、
以下のように文字が見えず空欄のMenuが表示されてしまう。
これはMenuの文字色が白、背景色も白であることが原因だった。
なのでMenuの文字色を調整する方法を記載する。
メールアドレスのみで認証する、パスワード設定が不要な認証方法です。
こうすると、
- // 押下したリストのアイテム情報をトースト表示する
- listView.setOnItemClickListener { parent, view, position, id ->
- Toast.makeText(this, array[position], Toast.LENGTH_SHORT).show()
- }
Build file 'E:\Document\MyApplication11\app\build.gradle' line: 2 An exception occurred applying plugin request [id: 'com.android.application'] > Failed to apply plugin 'com.android.internal.application'. > Android Gradle plugin requires Java 11 to run. You are currently using Java 1.8. You can try some of the following options: - changing the IDE settings. - changing the JAVA_HOME environment variable. - changing `org.gradle.java.home` in `gradle.properties`. * Try: Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
- Please remove usages of `jcenter()` Maven repository from your build scripts and migrate your build to other Maven repositories.
- This repository is deprecated and it will be shut down in the future.
- See http://developer.android.com/r/tools/jcenter-end-of-service for more information.
- Currently detected usages in: root project 'My Application', project ':app'
- Affected Modules: app
どうやら「jcenter()が非推奨になって、じきに完全消滅するから、ビルドスクリプトから消してくれ」とのこと
- A problem occurred configuring root project 'My Application'.
- > Could not resolve all artifacts for configuration ':classpath'.
- > Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.10-release-894.
- Searched in the following locations:
- - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.5.10-release-894/kotlin-gradle-plugin-1.5.10-release-894.pom
- - https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.5.10-release-894/kotlin-gradle-plugin-1.5.10-release-894.pom
- Required by:
- project :
- Possible solution:
- - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
どうやらkotlinのプラグイン「1.5.10-release-894」が見つからないらしい。。
AndroidStudio4.2がリリースされたのでアップデートしてみたら
新規プロジェクトをKotlinで作成すると、以下のエラーが出てビルドできなくなった。
- A problem occurred configuring root project 'My Application'.
- > Could not resolve all artifacts for configuration ':classpath'.
- > Could not find org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.0-release-764.
- Searched in the following locations:
- - https://dl.google.com/dl/android/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.5.0-release-764/kotlin-gradle-plugin-1.5.0-release-764.pom
- - https://repo.maven.apache.org/maven2/org/jetbrains/kotlin/kotlin-gradle-plugin/1.5.0-release-764/kotlin-gradle-plugin-1.5.0-release-764.pom
- Required by:
- project :
- Possible solution:
- - Declare repository providing the artifact, see the documentation at https://docs.gradle.org/current/userguide/declaring_repositories.html
どうやらkotlinのプラグイン「1.5.0-release-764」が見つからないらしい。。
Fragmentをpublic以外のアクセス修飾子でクラス定義していると、FragmentManagerに追加する際、以下のIllegalStateExceptionが投げられクラッシュする。
Caused by: java.lang.IllegalStateException: Fragment com.sample.test.myapplication.MainActivity.MyDialogFragment must be a public static class to be properly recreated from instance state. at androidx.fragment.app.FragmentTransaction.doAddOp(FragmentTransaction.java:165) at androidx.fragment.app.BackStackRecord.doAddOp(BackStackRecord.java:179) at androidx.fragment.app.FragmentTransaction.add(FragmentTransaction.java:125) at androidx.fragment.app.DialogFragment.show(DialogFragment.java:154) at com.sample.test.myapplication.MainActivity.onClick(MainActivity.java:32)
AndroidアプリでButtonの上にViewやFragmentを乗せても、
Buttonが表示物に隠れず、ボタンが上に重なって表示される。
解決方法として、ボタンの属性「stateListAnimator」に「"@null"」を設定すれば良い。
例えば、ボタンの上に画像(ImageView)を配置したいときは以下のようにする。
- <?xml version="1.0" encoding="utf-8"?>
- <androidx.constraintlayout.widget.ConstraintLayout
- xmlns:android="http://schemas.android.com/apk/res/android"
- xmlns:app="http://schemas.android.com/apk/res-auto"
- xmlns:tools="http://schemas.android.com/tools"
- android:layout_width="match_parent"
- android:layout_height="match_parent"
- tools:context=".MainActivity">
- <Button
- android:id="@+id/button"
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:text="Button"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent"
- android:stateListAnimator="@null" ★ コレ! ★
- />
- <ImageView
- android:layout_width="wrap_content"
- android:layout_height="wrap_content"
- android:src="@drawable/ic_launcher_background"
- app:layout_constraintBottom_toBottomOf="parent"
- app:layout_constraintEnd_toEndOf="parent"
- app:layout_constraintStart_toStartOf="parent"
- app:layout_constraintTop_toTopOf="parent"
- />
- </androidx.constraintlayout.widget.ConstraintLayout>
Androidは公式がGitHubにサンプルプロジェクトを公開している。
これらのサンプルコードを取り込んでビルドしたいときの方法を残しておく。
※GitHubからソースコードを落としたいだけなら、手順2までで良い
- // java版
- Set<String> set = new HashSet<>(
- getSharedPreferences("set",MODE_PRIVATE).getStringSet("data", new HashSet<>()));
- // Kotlin版
- val set = getSharedPreferences("set", MODE_PRIVATE)
- .getStringSet("data", mutableSetOf())?.toMutableSet()
MyApplication\app\src\main\res\layout\activity_main.xml:1: AAPT: error: XML or text declaration not at start of entity.
- apply plugin: 'com.android.application'
- apply plugin: 'kotlin-android'
- apply plugin: 'kotlin-android-extensions' // 追加プラグイン
- plugins {
- id 'com.android.application'
- id 'kotlin-android'
- id 'kotlin-android-extensions' // 追加プラグイン
- }
AndroidでTextViewなどのViewの表示切替を行った後、次回のアプリ起動でそのView表示可否状態を維持したいときの保存はSharedPreferencesが便利です。
>adb shell error: device unauthorized. This adb server's $ADB_VENDOR_KEYS is not set Try 'adb kill-server' if that seems wrong. Otherwise check for a confirmation dialog on your device.
APKファイルの逆コンパイル(Decompile Files)には成功し、「3-Out」フォルダに各ファイルができているのに、再コンパイル(Recompile Files)すると、「4-Done」フォルダにAPKファイルができず失敗していた。
なので、原因を調べてみた。
スマホアプリの動作をブログに張るのにgifファイルが便利だったので、
スマホ操作をGifにする方法を残しておく。
mp4をgifに変換するだけなら手順7のサイトで変換するだけでよい