flutterでapkファイルを作成して、android端末でインストールしようとすると、「インストールされていません」と出てしまいます。
1週間前にapkファイルを作成した時は、正常にインストールはできたのですが、アプリが正常動作しなかった(画面表示が想定とは異なった)ため、以下2ファイルをいじりました。
・AndroidManifest.xml
・app/build.gradle
現在、AndroidManifest.xmlの以下にてエラーが起こっているので、apkがうまくインストールできないのは、それが原因だと考えています。
android:name="${applicationName}"
apkを作成する記事等は数記事あるのですが、古い情報や古いverのため参考になる記事が見つからないため、どうしたらいいのかわかりませんので、ご教示いただけますと幸いです。
【AndroidManifest.xml】
<manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.test_app"> <application android:name="${applicationName}" android:label="test_app" android:icon="@mipmap/ic_launcher"> <activity android:name=".MainActivity" android:exported="true" android:launchMode="singleTop" android:theme="@style/LaunchTheme" android:configChanges="orientation|keyboardHidden|keyboard|screenSize|smallestScreenSize|locale|layoutDirection|fontScale|screenLayout|density|uiMode" android:hardwareAccelerated="true" android:windowSoftInputMode="adjustResize"> <!-- Specifies an Android theme to apply to this Activity as soon as the Android process has started. This theme is visible to the user while the Flutter UI initializes. After that, this theme continues to determine the Window background behind the Flutter UI. --> <intent-filter> <action android:name="android.intent.action.MAIN"/> <category android:name="android.intent.category.LAUNCHER"/> </intent-filter> </activity> <!-- Don't delete the meta-data below. This is used by the Flutter tool to generate GeneratedPluginRegistrant.java --> <meta-data android:name="flutterEmbedding" android:value="2" /> </application> </manifest>
【app/build.gradle】
def localProperties = new Properties() def localPropertiesFile = rootProject.file('local.properties') if (localPropertiesFile.exists()) { localPropertiesFile.withReader('UTF-8') { reader -> localProperties.load(reader) } } def flutterRoot = localProperties.getProperty('flutter.sdk') if (flutterRoot == null) { throw new GradleException("Flutter SDK not found. Define location with flutter.sdk in the local.properties file.") } def flutterVersionCode = localProperties.getProperty('flutter.versionCode') if (flutterVersionCode == null) { flutterVersionCode = '1' } def flutterVersionName = localProperties.getProperty('flutter.versionName') if (flutterVersionName == null) { flutterVersionName = '1.0' } apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply from: "$flutterRoot/packages/flutter_tools/gradle/flutter.gradle" apply plugin: 'com.google.gms.google-services' android { compileSdkVersion 32 compileOptions { sourceCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8 } kotlinOptions { jvmTarget = '1.8' } sourceSets { main.java.srcDirs += 'src/main/kotlin' } defaultConfig { // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html). applicationId "com.example.test_app" minSdkVersion 21 targetSdkVersion 32 versionCode flutterVersionCode.toInteger() versionName flutterVersionName multiDexEnabled true //manifestPlaceholders = [applicationName: "android.app.Application"] } buildTypes { debug { resValue "string", "app_name", "(d)testapp" applicationIdSuffix ".debug" versionNameSuffix "-d" } release { resValue "string", "app_name", "testapp" } } } flutter { source '../..' } dependencies { implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation "androidx.multidex:multidex:2.0.1" }
あなたの回答
tips
プレビュー