책보며 쉬엄쉬엄 플러터 공부중인데.. 다음과 같은 오류가 떴다.

참고로, 요즘 개발환경이 하두 빠르게 변해서서.. 책에 있는 버전이 좀 구버전이 되어 버렸다.
또한, iphone용 앱도 해 볼 생각이라서, 구형 맥북에서도 같이 하고 있는데.. 구형 맥북이다 보니 개발환경도 구버전이다.

책에 있는대로 하다 보니, firebase부분에서 다음과 같은 오류가 떴다.

C:\FlutterProjects\firebase_example\android\app\src\debug\AndroidManifest.xml Error:
	uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [com.google.firebase:firebase-analytics:20.0.2] C:\Users\___\.gradle\caches\transforms-2\files-2.1\9c075d413bca5e1f4fcf6e259a7bb508\jetified-firebase-analytics-20.0.2\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="com.google.firebase.firebase_analytics" to force usage (may lead to runtime failures)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugMainManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 16 cannot be smaller than version 19 declared in library [com.google.firebase:firebase-analytics:20.0.2] C:\Users\____\.gradle\caches\transforms-2\files-2.1\9c075d413bca5e1f4fcf6e259a7bb508\jetified-firebase-analytics-20.0.2\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="com.google.firebase.firebase_analytics" to force usage (may lead to runtime failures)

* 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 30s
Exception: Gradle task assembleDebug failed with exit code 1

Mac서는 다음과 같은 메시지가 떴다.

Launching lib/main.dart on iPhone 12 Pro in debug mode...
Running pod install...
CocoaPods' output:
↳
      Preparing

    Analyzing dependencies

    Inspecting targets to integrate
      Using `ARCHS` setting to build architectures of target `Pods-Runner`: (``)

    Fetching external sources
    -> Fetching podspec for `Flutter` from `Flutter`
    -> Fetching podspec for `firebase_analytics` from `.symlinks/plugins/firebase_analytics/ios`
    firebase_analytics: Using Firebase SDK version '8.11.0' defined in 'firebase_core'
    -> Fetching podspec for `firebase_core` from `.symlinks/plugins/firebase_core/ios`
    firebase_core: Using Firebase SDK version '8.11.0' defined in 'firebase_core'
    -> Fetching podspec for `firebase_database` from `.symlinks/plugins/firebase_database/ios`
    firebase_database: Using Firebase SDK version '8.11.0' defined in 'firebase_core'

    Resolving dependencies of `Podfile`
      CDN: trunk Relative path: CocoaPods-version.yml exists! Returning local because checking is only performed in repo update
      CDN: trunk Relative path: all_pods_versions_0_3_5.txt exists! Returning local because checking is only performed in repo update
      CDN: trunk Relative path: Specs/0/3/5/Firebase/10.24.0/Firebase.podspec.json exists! Returning local because checking is only performed in repo update
      CDN: trunk Relative path: Specs/0/3/5/Firebase/8.11.0/Firebase.podspec.json exists! Returning local because checking is only performed in repo update
      CDN: trunk Relative path: Specs/0/3/5/Firebase/8.11.0/Firebase.podspec.json exists! Returning local because checking is only performed in repo update
    [!] CocoaPods could not find compatible versions for pod "firebase_database":
      In Podfile:
        firebase_database (from `.symlinks/plugins/firebase_database/ios`)

    Specs satisfying the `firebase_database (from `.symlinks/plugins/firebase_database/ios`)` dependency were found, but they required a higher minimum deployment target.

    /Users/___/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:317:in `raise_error_unless_state'
    /Users/___/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/molinillo-0.8.0/lib/molinillo/resolution.rb:299:in `block in unwind_for_conflict'
    (... 생략 ...)
    /Users/___/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.11.3/lib/cocoapods/command.rb:52:in `run'
    /Users/___/.rbenv/versions/2.7.6/lib/ruby/gems/2.7.0/gems/cocoapods-1.11.3/bin/pod:55:in `<top (required)>'
    /Users/___/.rbenv/versions/2.7.6/bin/pod:23:in `load'
    /Users/___/.rbenv/versions/2.7.6/bin/pod:23:in `<main>'

Error output from CocoaPods:
↳

    [!] Automatically assigning platform `iOS` with version `9.0` on target `Runner` because no platform was specified. Please specify a platform for this target in your Podfile. See `https://guides.cocoapods.org/syntax/podfile.html#platform`.

Error running pod install
Error launching application on iPhone 12 Pro.

원인을 찾다가..(다른버전 SDK도 설치해보고, Mac의 cocoapods도 버전업 해보고..)
결국 Project에 설정된 최소 버전이랑, 지금 사용하려는 firebase의 최소 요구버전이랑 달라서 생기는 걸로 파악. Project의 버전 설정을 찾아보기로 한다.

먼저 Android

Android는 다음의 파일에서 수정할 수 있다.
(아래는 참고했던 URL)

https://progdev.tistory.com/50

기본적으로
Flutter설치위치\packages\flutter_tools\gradle\flutter.gradle
파일에 default 값이 선언 되어있고.. 이 값을
Project> android> app> build.gradle 파일에서 갖다 쓴다.

(... 생략 ...)
android {
    (... 생략 ...)
    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "net.heyo.exam.firebase_example"
        minSdkVersion flutter.minSdkVersion             // <== 여기 minSkdVersion
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
    (... 생략 ...)
}
(... 생략 ...)

좀 깔끔하게 하려면.. local.properties 에 설정해놓고, 그 값을 불러오라는데.. (local에 없으면 기본값)
나는 우선 급하고, 교재 연습하는 거라 직접 수정해버렸다.

(... 생략 ...)
android {
    (... 생략 ...)
    defaultConfig {
        // TODO: Specify your own unique Application ID (https://developer.android.com/studio/build/application-id.html).
        applicationId "net.heyo.exam.firebase_example"
        minSdkVersion 19             // <== 여기 minSkdVersion 수정
        targetSdkVersion flutter.targetSdkVersion
        versionCode flutterVersionCode.toInteger()
        versionName flutterVersionName
    }
    (... 생략 ...)
}
(... 생략 ...)

Mac OS (iOS)

참고했던 URL

https://stackoverflow.com/questions/63973136/the-ios-deployment-target-iphoneos-deployment-target-is-set-to-8-0-in-flutter

  • Project> ios> Flutter> AppFrameworkInfo.plist 파일에 MinimumOSVersion 값을 바꿈
  • Project>ios>Podfile 파일에 # platform :ios, ‘9.0’ 주석을 풀고 10.0 으로 바꿔줌
  • Porject>ios>Podfile 파일에 아래 부분을 수정해 줌.
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
  (... 생략 ...)
  <key>MinimumOSVersion</key>
  <string>10.0</string>    <!-- 이거 수정함 9.0 => 10.0 -->
</dict>
</plist>
# Uncomment this line to define a global platform for your project
platform :ios, '10.0'    # 주석 풀고 9.0 => 10.0 으로 바꿔줌

(... 생략 ...)

post_install do |installer|
  installer.pods_project.targets.each do |target|
    flutter_additional_ios_build_settings(target)
    target.build_configurations.each do |config|                    # 여기 3줄 추가함
      config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '10.0'  # 여기 3줄 추가함
    end                                                             # 여기 3줄 추가함
  end
end

이렇게 했더니 우선 문제는 해결되어 정상 작동 했다.

Loading

Similar Posts