Flutter_blue android 설정

Flutter_blue 패키지 버전 0.8.0에서 안드로이드 에뮬레이터, 혹은 안드로이드 디바이스에서 예제코드를 실행할 때에 다음과 같은 에러가 발생하면서, 제대로 작성이 되지 않는다. (iOS 타겟에서는 제대로 작동한다)

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':flutter_blue:generateDebugProto'.
> Could not resolve all files for configuration ':flutter_blue:protobufToolsLocator_protoc'.
   > Could not find protoc-3.11.4-osx-aarch_64.exe (com.google.protobuf:protoc:3.11.4).
     Searched in the following locations:
         https://repo.maven.apache.org/maven2/com/google/protobuf/protoc/3.11.4/protoc-3.11.4-osx-aarch_64.exe

* 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 16s

위의 에러를 해결하기 위해서는 Gradle info를 수정해주어야 한다.

Android Studio를 실행하여 flutter앱이 위치한 폴더에 위치한 android 폴더를 프로젝트폴더로 지정하여 연다. 이후 프로젝트 로딩이 끝나면, 오른쪽편에 위치한 Gradle탭을 열고, android>flutter_blue 트리항목위에 마우스 커서를 올리고 오른쪽 버튼을 눌러 ‘Open Gradle Config’로 진입한다.

Config 내용 중 ‘

'com.google.protobuf:protoc:3.11.4' 을
'com.google.protobuf:protoc:3.17.3' 으로 수정한다.

'com.google.protobuf:protobuf-javalite:3.11.4'을
'com.google.protobuf:protobuf-javalite:3.17.3'으로 수정한다.

수정 후 config 중 해당부분의 내용은 다음과 같다.

protobuf {
    protoc {
        artifact = 'com.google.protobuf:protoc:3.17.3'
    }
    generateProtoTasks {
        all().each { task ->
            task.builtins {
                java {
                    option "lite"
                }
            }
        }
    }
}

dependencies {
    implementation 'com.google.protobuf:protobuf-javalite:3.17.3'
}

저장한 이후 Android Studio를 닫고, flutter에서 앱 시작을 해보면, 잘 실행되는 것을 볼 수가 있다.

Flutter m1칩 pod 에러

flutter로 작성한 앱을 아이폰 에뮬레이터에서 구동하려고 하니, 다음과 같은 에러가 발생.

Launching lib/main.dart on iPhone 13 in debug mode...
lib/main.dart:1
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 `webview_flutter_wkwebview` from `.symlinks/plugins/webview_flutter_wkwebview/ios`
    Resolving dependencies of `Podfile`
Error output from CocoaPods:
↳
    /System/Library/Frameworks/Ruby.framework/Versions/2.6/usr/lib/ruby/2.6.0/rubygems/core_ext/kernel_require.rb:54:in `require': dlopen(/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi_c.bundle, 9): no suitable image found.  Did find: (LoadError)
    	/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi_c.bundle: mach-o, but wrong architecture
    	/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi_c.bundle: mach-o, but wrong architecture - /Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi_c.bundle

터미널에서 ~/ios/ 이동 후 pod install 실행 시 역시나 에러 발생

changho@177802-RedmiBook-Air ios % pod install
Analyzing dependencies
/Library/Ruby/Gems/2.6.0/gems/ffi-1.15.4/lib/ffi/library.rb:275: [BUG] Bus Error at 0x00000001022f4000
ruby 2.6.3p62 (2019-04-16 revision 67580) [universal.arm64e-darwin20]

-- Crash Report log information --------------------------------------------
   See Crash Report log file under the one of following:                    
     * ~/Library/Logs/DiagnosticReports                                     
     * /Library/Logs/DiagnosticReports                                      
   for more details.                                                        
Don't forget to include the above Crash Report log file in bug reports.     

인텔칩이 아닌 m1칩 관련 문제

다음 명령어로 gem 설치

sudo arch -x86_64 gem install ffi
arch -x86_64 pod install 

조치 후 에러 없이 정상작동함.