「Android/開発環境/AndroidStudio/ビルドバージョンアップ/Android11対応」の版間の差分
提供: 初心者エンジニアの簡易メモ
(→非推奨コード対応) |
|||
| 行57: | 行57: | ||
==非推奨コード対応== | ==非推奨コード対応== | ||
| − | ./gradlew lint | + | build.gradleにoptions.compilerArgsを追加 |
| + | <pre> | ||
| + | allprojects { | ||
| + | gradle.projectsEvaluated { | ||
| + | tasks.withType(JavaCompile) { | ||
| + | options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation" | ||
| + | } | ||
| + | } | ||
| + | } | ||
| + | </pre> | ||
| + | $ ./gradlew lint | ||
===ボタンでMissingConstraintsエラーが出るとき=== | ===ボタンでMissingConstraintsエラーが出るとき=== | ||
2020年8月7日 (金) 14:58時点における版
目次
やり方
公式:https://developer.android.com/preview/setup-sdk?hl=ja
- AndroidStudioのプレビュー版をDL(20200729時点で4.0.1β) https://developer.android.com/studio/preview?hl=ja
- Android/Tools/SDKManager (もしくはAndroidStudioのwelcome画面のConfigureのSDKManager)
- SDK Platformsタブで、Android R Previewを選択
- SDK Toolsタブで、Android SDK Build-Tools 30を選択
app/build.gradleのcompileSdkVersionとtargetSdkVersionを30へ
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
defaultConfig {
targetSdkVersion 30
}
}
AndroidGradleのプラグインを4系へ
プロジェクト直下のbuild.gradle
buildscript {
dependencies {
classpath "com.android.tools.build:gradle:4.0.1"
}
}
gradle/wrapper/gradle-wrapper.propertiesのdistributionUrlを変更
distributionUrl=https\://services.gradle.org/distributions/gradle-6.1.1-all.zip
androidのgradleプラグインとgradleのversionの関係
こちらを参照 https://developer.android.com/studio/releases/gradle-plugin.html
kotlinでCould not initialize class org.jetbrains.kotlin.gradle.plugin.sources.DefaultKotlinSourceSetKtがる場合
build.gradleのkotlin_versionを1.3.10から1.3.72にあげると直る。
buildscript {
ext.kotlin_version = "1.3.72"
}
webviewで端末に保存したファイルが見れない
webviewに"ウェブページへのアクセス不可 ERR_ACCESS_DENIED"と出る場合
以下権限を追加してもだめだった。
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
結局build.gradleをtargetSdkVersion 30から29にしないとならないかも。もしくはandroid11のβが取れるのを一旦待つ。
参考:https://support.wikitude.com/support/discussions/topics/5000095108
非推奨コード対応
build.gradleにoptions.compilerArgsを追加
allprojects {
gradle.projectsEvaluated {
tasks.withType(JavaCompile) {
options.compilerArgs << "-Xlint:unchecked" << "-Xlint:deprecation"
}
}
}
$ ./gradlew lint
ボタンでMissingConstraintsエラーが出るとき
以下エラーが出るとき
app/src/main/res/layout/activity_main.xml:18: Error: This view is not constrained vertically: at runtime it will jump to the top unless you add a vertical constraint [MissingConstraints]
<Button
2020年8月7日 (金) 14:56 (JST)~
修正前
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="text" />
修正後
<Button
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="text"
tools:ignore="MissingConstraints" />
MissingConstraintsを追加する
