実現したいこと
- Android 10.0で万全に動作するアプリのビルドを完了させる
前提
Android Studioを用いてAndroidアプリの開発を行っています。
Androidといっても普通の機種ではなく、Android搭載のコントローラーといったもので、都合上Android 9.0もしくは10.0しか使うことができません。
本格的な開発を始める前に、ひとまずビルドができる状況にしようと考えています。
この条件で開発を問題なく始められるか、始められるならばどうすればよいかを知りたいです。
発生している問題・エラーメッセージ
10.0前提で開発するためtargetApiを29に設定してビルドを行ったところ、以下のエラーが発生しビルドができませんでした。
Executing tasks: [:app:assembleDebug] in project C:\Users\PC_User\AndroidStudioProjects\MyApplication ・・・字数超過の為中略。必要であれば書きます・・・ > Task :app:writeDebugSigningConfigVersions UP-TO-DATE > Task :app:processDebugResources FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:processDebugResources'. > A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction > Android resource linking failed com.example.myapplication.app-mergeDebugResources-16:/values-v31/values-v31.xml:3: error: resource android:color/system_neutral1_1000 not found. com.example.myapplication.app-mergeDebugResources-16:/values-v31/values-v31.xml:4: error: resource android:color/system_neutral1_900 not found. com.example.myapplication.app-mergeDebugResources-16:/values-v31/values-v31.xml:5: error: resource android:color/system_neutral1_0 not found. com.example.myapplication.app-mergeDebugResources-16:/values-v31/values-v31.xml:6: error: resource android:color/system_neutral1_800 not found. com.example.myapplication.app-mergeDebugResources-16:/values-v31/values-v31.xml:7: error: resource android:color/system_neutral1_700 not found. ・・・字数超過の為中略。xml:8/600、xml:9/500、xml:10/400、xml:11/300と続く・・・ com.example.myapplication.app-mergeDebugResources-16:/values-v31/values-v31.xml:12: error: resource android:color/system_neutral1_200 not found. com.example.myapplication.app-mergeDebugResources-16:/values-v31/values-v31.xml:13: error: resource android:color/system_neutral1_100 not found. com.example.myapplication.app-mergeDebugResources-16:/values-v31/values-v31.xml:14: error: resource android:color/system_neutral1_50 not found. com.example.myapplication.app-mergeDebugResources-16:/values-v31/values-v31.xml:15: error: resource android:color/system_neutral1_10 not found. com.example.myapplication.app-mergeDebugResources-16:/values-v31/values-v31.xml:16: error: resource android:color/system_neutral2_1000 not found. com.example.myapplication.app-mergeDebugResources-16:/values-v31/values-v31.xml:17: error: resource android:color/system_neutral2_900 not found. com.example.myapplication.app-mergeDebugResources-16:/values-v31/values-v31.xml:18: error: resource android:color/system_neutral2_0 not found. com.example.myapplication.app-mergeDebugResources-16:/values-v31/values-v31.xml:19: error: resource android:color/system_neutral2_800 not found. com.example.myapplication.app-mergeDebugResources-16:/values-v31/values-v31.xml:20: error: resource android:color/system_neutral2_700 not found. com.example.myapplication.app-mergeDebugResources-16:/values-v31/values-v31.xml:21: error: resource android:color/system_neutral2_600 not found. com.example.myapplication.app-mergeDebugResources-16:/values-v31/values-v31.xml:22: error: resource android:color/system_neutral2_500 not found. * 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. * Get more help at https://help.gradle.org BUILD FAILED in 901ms 25 actionable tasks: 1 executed, 24 up-to-date
該当のソースコード
AndroidManifest.xml
1<?xml version="1.0" encoding="utf-8"?> 2<manifest xmlns:android="http://schemas.android.com/apk/res/android" 3 xmlns:tools="http://schemas.android.com/tools"> 4 5 <application 6 android:allowBackup="true" 7 android:dataExtractionRules="@xml/data_extraction_rules" 8 android:fullBackupContent="@xml/backup_rules" 9 android:icon="@mipmap/ic_launcher" 10 android:label="@string/app_name" 11 android:roundIcon="@mipmap/ic_launcher_round" 12 android:supportsRtl="true" 13 android:theme="@style/Theme.MyApplication" 14 tools:targetApi="29"> <!-- ←33から29にした --> 15 <activity 16 android:name=".MainActivity" 17 android:exported="true"> 18 <intent-filter> 19 <action android:name="android.intent.action.MAIN" /> 20 21 <category android:name="android.intent.category.LAUNCHER" /> 22 </intent-filter> 23 </activity> 24 </application> 25 26</manifest>
MainActivity.kt
1package com.example.myapplication 2 3import androidx.appcompat.app.AppCompatActivity 4import android.os.Bundle 5 6class MainActivity : AppCompatActivity() { 7 override fun onCreate(savedInstanceState: Bundle?) { 8 super.onCreate(savedInstanceState) 9 setContentView(R.layout.activity_main) 10 } 11} 12// まだ何も触っていません
build.gradle(My_Application)
1// Top-level build file where you can add configuration options common to all sub-projects/modules. 2plugins { 3 id 'com.android.application' version '8.0.0' apply false 4 id 'com.android.library' version '8.0.0' apply false 5 id 'org.jetbrains.kotlin.android' version '1.8.0' apply false 6} 7// 実際は下線ではなく半角スペース
build.gradle(:app)
1plugins { 2 id 'com.android.application' 3 id 'org.jetbrains.kotlin.android' 4} 5 6android { 7 namespace 'com.example.myapplication' 8 compileSdk 29 9 10 defaultConfig { 11 applicationId "com.example.myapplication" 12 minSdk 29 13 //noinspection ExpiredTargetSdkVersion 14 targetSdk 29 15 versionCode 1 16 versionName "1.0" 17 18 testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" 19 } 20 21 buildTypes { 22 release { 23 minifyEnabled false 24 proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' 25 } 26 } 27 compileOptions { 28 sourceCompatibility JavaVersion.VERSION_1_8 29 targetCompatibility JavaVersion.VERSION_1_8 30 } 31 kotlinOptions { 32 jvmTarget = '1.8' 33 } 34} 35 36dependencies { 37 //以下、targetSdkVersionが29以下のバージョンを指定 38 implementation 'androidx.core:core-ktx:1.5.0-alpha01' 39 implementation 'androidx.appcompat:appcompat:1.3.0-alpha01' 40 implementation 'com.google.android.material:material:1.5.0' 41 implementation 'androidx.constraintlayout:constraintlayout:2.1.0-alpha2' 42 testImplementation 'junit:junit:4.13.2' 43 androidTestImplementation 'androidx.test.ext:junit:1.1.5' 44 androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1' 45}
試したこと
- AndroidManifestからtools:targetApi="29"を消してみる
特に変わらず。
- Run with --scanを試してみる
以下のエラーが出て失敗。
Executing tasks: [:app:assembleDebug] in project C:\Users\PC_User\AndroidStudioProjects\MyApplication Download https://plugins.gradle.org/m2/com/gradle/gradle-enterprise-gradle-plugin/3.12.3/gradle-enterprise-gradle-plugin-3.12.3.module, took 1 s 24 ms (3.67 kB) Download https://plugins.gradle.org/m2/com/gradle/gradle-enterprise-gradle-plugin/3.12.3/gradle-enterprise-gradle-plugin-3.12.3.jar, took 2 s 557 ms (10.93 MB) ・・・中略・・・ > Task :app:mergeExtDexDebug > Task :app:processDebugResources FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:processDebugResources'. > A failure occurred while executing com.android.build.gradle.internal.res.LinkApplicationAndroidResourcesTask$TaskAction > Android resource linking failed com.example.myapplication.app-mergeDebugResources-16:/values-v31/values-v31.xml:3: error: resource android:color/system_neutral1_1000 not found. ・・・さっきと同じなので中略・・・ com.example.myapplication.app-mergeDebugResources-16:/values-v31/values-v31.xml:22: error: resource android:color/system_neutral2_500 not found. * Try: > Run with --stacktrace option to get the stack trace. > Run with --info or --debug option to get more log output. * Get more help at https://help.gradle.org BUILD FAILED in 32s 25 actionable tasks: 25 executed The build scan was not published due to a configuration problem. The Gradle Terms of Service have not been agreed to. For more information, please see https://gradle.com/help/plugin-terms-of-service. Alternatively, if you are using Gradle Enterprise, specify the server location. For more information, please see https://gradle.com/help/plugin-enterprise-config.
- AndroidManifest.xmlとbuild.gradle(:app)の、compileSdkとtargetSdkを33にしてみた
以下のエラーが出た。おま環?のようだが調べても決定打は出ず。
そもそも、これが成功したとして、目的の9.0~10.0で安定して動かすことができるか少々不安。
Executing tasks: [:app:assembleDebug] in project C:\Users\PC_User\AndroidStudioProjects\MyApplication ・・・中略・・・ > Task :app:writeDebugSigningConfigVersions UP-TO-DATE > Task :app:packageDebug FAILED FAILURE: Build failed with an exception. * What went wrong: Execution failed for task ':app:packageDebug'. > A failure occurred while executing com.android.build.gradle.tasks.PackageAndroidArtifact$IncrementalSplitterRunnable > java.io.FileNotFoundException: C:\Users\PC_User\AndroidStudioProjects\MyApplication\app\build\intermediates\incremental\packageDebug\tmp\debug\zip-cache\androidResources (アクセスが拒否されました。) * 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. * Get more help at https://help.gradle.org BUILD FAILED in 622ms 30 actionable tasks: 2 executed, 28 up-to-date
補足情報(FW/ツールのバージョンなど)
Windows 11 Home
Android Studio Flamingo 2022.2.1

回答1件
あなたの回答
tips
プレビュー