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에서 앱 시작을 해보면, 잘 실행되는 것을 볼 수가 있다.
0개의 댓글