0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 1 year has passed since last update.

【Flutter】minSdkVersion 16 cannot be smaller than version 19 declared in library のエラーが出た場合の対処方法

Posted at

エラー内容

Flutter と Firebase の連携をするためにサンプルのコードをコピペして、アプリを実行した場合に以下のエラーメッセージが表示されたのでその対処方法です。

エラーメッセージ:

C:\Users\UserName\StudioProjects\ProjectName\android\app\src\debug\AndroidManifest.xml Error:
	uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [:cloud_firestore] C:\Users\UserName\StudioProjects\ProjectName\build\cloud_firestore\intermediates\merged_manifest\debug\AndroidManifest.xml as the library might be using APIs not available in 16
	Suggestion: use a compatible library with a minSdk of at most 16,
		or increase this project's minSdk version to at least 19,
		or use tools:overrideLibrary="io.flutter.plugins.firebase.firestore" to force usage (may lead to runtime failures)

「minSdkVersion を19以上に設定してください」という意味らしいので、以下の設定をする

C:\Users\UserName\StudioProjects\ProjectName\android\app\build.gradle の設定を以下のように修正する

android {
   defaultConfig {
     minSdkVersion 19 // このように修正(元々は、minSdkVersion flutter.minSdkVersion)
   }
 } 

D8: Cannot fit requested classes in a single dex file (# methods: 92002 > 65536) のエラー

minSdkVersion を19に設定したら別のエラーメッセージが表示された

ERROR:D8: Cannot fit requested classes in a single dex file (# methods: 92002 > 65536)
com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: 
The number of method references in a .dex file cannot exceed 64K.

調べると Android公式サイト に対処方法が載っていたので以下のように修正したらエラーが解消されアプリが起動した

android {
    defaultConfig {
        multiDexEnabled true // これを追加
    }
}

dependencies {
    implementation "androidx.multidex:multidex:2.0.1" // これを追加
}
0
0
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
0
0

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?