티스토리 뷰

반응형

안녕하세요. 오틸라 입니다.
 
 
약 3년전 만들었던 프로젝트를 신규로 빌드해보기 위해 열었습니다.
 
이때가 아마 flutter 1.0 이었을겁니다.
3.0으로 업글하기 위해 초 어려울것으로 예상됩니다.
 

 
일단 열자마자 에러가 막 납니다.
 
가장 먼저 하는건, 
pubspec.yaml에서 pub get을 해보는 겁니다.
 

sdk버전이 걸리네요.
 

 
이거를, 
 

이렇게 바꿔주고 다시 pub get하면,
 

카카오 라이브러리 0.4.2가 에러입니다.
현재 카카오 라이브러리는

1.4.3 입니다. ㅎㅎ
이거 버전업하고 다시 pub get
 
이런식으로 라이브러리가 에러나면 최신버전으로 하나씩 바꿔줍니다.
 
만약 이전에 참조했던 라이브러리중에 최신화가 되지 않아 업데이트가 종료된 라이브러리가 있다면 버리기도 해야 합니다.
 
 
버려질 라이브러리가 하나 등장했네요.
 

flutter_icons: ^1.0.0+1

아이콘관련인거 같은데, 이건 이제 없어진거 같습니다.
과감히 버립니다!
 

loading: ^1.0.2

로딩중 띄우려던 거 같은데 이것도 버립니다.

 
외부 라이브러리는 모두 최신화 하였고, 이제 내 프로젝트 소스에 문제인 null-safety입니다.
 
2.0 이전에 null을 허용하다가 이제는 완전히 금지되었죠.
내 프로젝트 뿐만 아니라, 참조하고 있던 프로젝트 역시 null-safety버전으로 변경된 것들로 업데이트 해줘야 합니다.
 
 

반응형

 

 
pubspec.yaml의 pub get은 된거 같습니다.
이제 내 프로젝트쪽을 하나씩 보겠습니다.
 
 
먼저 생성자쪽이 달라졌네요
 

QNAWidget({
  Key key,
  @required this.img,
  @required this.entry,
}) : super(key: key);

위를 아래와 같이 바꿉니다.
 

QNAWidget({
  Key? key,
  required this.img,
  required this.entry,
}) : super(key: key);

 
 
 
material에서 없어진 스타일이 좀 있네요.

Theme.of(context).textTheme.display4;

이 테마가 어느 위젯에 쓰여진건지는 아직 모르기 때문에 일단 존재하는 다른 스타일로 아무거나 바꿔서 에러를 없앱니다.
 
 
 

List items = List();

리스트를 선언하는 방법은 아래와 같이 변경

List items = [];

 
null로 선언되는 변수는 late 추가

 
그외, 각종 null로 선언되는 변수처리나, 필요없는 구문들 다 없애버리고,
최종 빌드시
 

 
AndroidManifest.xml 방식이 옛날방식이라 변경하라고 합니다.

<application
    android:name="io.flutter.app.FlutterApplication"

위 부분을 아래와 같이 변경

<application
    android:name="${applicationName}"

 
 
build.gradle 파일에
 

targetSdkVersion 28

위 부분을 33으로 변경

targetSdkVersion 33

 
 

Warning: Mapping new ns 
http://schemas.android.com/repository/android/common/02 to old ns 
http://schemas.android.com/repository/android/common/01Warning: Mapping new ns 
http://schemas.android.com/repository/android/generic/02 to old ns 
http://schemas.android.com/repository/android/generic/01Warning: Mapping new ns 
http://schemas.android.com/sdk/android/repo/addon2/02 to old ns 
http://schemas.android.com/sdk/android/repo/addon2/01Warning: Mapping new ns 
http://schemas.android.com/sdk/android/repo/addon2/03 to old ns 
http://schemas.android.com/sdk/android/repo/addon2/01Warning: Mapping new ns 
http://schemas.android.com/sdk/android/repo/repository2/02 to old ns 
http://schemas.android.com/sdk/android/repo/repository2/01Warning: Mapping new ns 
http://schemas.android.com/sdk/android/repo/repository2/03 to old ns 
http://schemas.android.com/sdk/android/repo/repository2/01Warning: Mapping new ns 
http://schemas.android.com/sdk/android/repo/sys-img2/03 to old ns 
http://schemas.android.com/sdk/android/repo/sys-img2/01Warning: Mapping new ns 
http://schemas.android.com/sdk/android/repo/sys-img2/02 to old ns 
http://schemas.android.com/sdk/android/repo/sys-img2/01

 
이런 에러들이 나오는건 gradle 버전이 낮아서 그렇습니다.
gradle버전 7.2.2로 업!
 

dependencies {
    classpath 'com.android.tools.build:gradle:7.2.2'
    classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
}

 
 

android:exported needs to be explicitly specified for element <activity#kr.co.otilla.MainActivity>. Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported` when the corresponding component has an intent filter defined. See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

요 에러는 AndroidManifest에서 export 방식이 변경되기 전이라 발생했습니다.

<activity
    android:name=".MainActivity"
    android:launchMode="singleTop"
    android:exported="true"

export true를 추가!!
 
 

he class is loaded from C:/Users/otillainteractive/.gradle/caches/transforms-3/ec19f90ae186829d7e1bae3bd59e64bd/transformed/jetified-kotlin-stdlib-1.7.0.jar!/kotlin/Unit.class
e: C:\Users\otillainteractive\AppData\Local\Pub\Cache\hosted\pub.dev\fluttertoast-8.2.2\android\src\main\kotlin\io\github\ponnamkarthik\toast\fluttertoast\MethodCallHandlerImpl.kt: (111, 24): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.1.15.
The class is loaded from C:/Users/otillainteractive/.gradle/caches/transforms-3/ec19f90ae186829d7e1bae3bd59e64bd/transformed/jetified-kotlin-stdlib-1.7.0.jar!/kotlin/Unit.class
e: C:\Users\otillainteractive\AppData\Local\Pub\Cache\hosted\pub.dev\fluttertoast-8.2.2\android\src\main\kotlin\io\github\ponnamkarthik\toast\fluttertoast\MethodCallHandlerImpl.kt: (115, 29): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.1.15.
The class is loaded from C:/Users/otillainteractive/.gradle/caches/transforms-3/ec19f90ae186829d7e1bae3bd59e64bd/transformed/jetified-kotlin-stdlib-1.7.0.jar!/kotlin/Unit.class
e: C:\Users\otillainteractive\AppData\Local\Pub\Cache\hosted\pub.dev\fluttertoast-8.2.2\android\src\main\kotlin\io\github\ponnamkarthik\toast\fluttertoast\MethodCallHandlerImpl.kt: (116, 21): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.1.15.
The class is loaded from C:/Users/otillainteractive/.gradle/caches/transforms-3/ec19f90ae186829d7e1bae3bd59e64bd/transformed/jetified-kotlin-stdlib-1.7.0.jar!/kotlin/Unit.class
e: C:\Users\otillainteractive\AppData\Local\Pub\Cache\hosted\pub.dev\fluttertoast-8.2.2\android\src\main\kotlin\io\github\ponnamkarthik\toast\fluttertoast\MethodCallHandlerImpl.kt: (118, 24): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.1.15.
The class is loaded from C:/Users/otillainteractive/.gradle/caches/transforms-3/ec19f90ae186829d7e1bae3bd59e64bd/transformed/jetified-kotlin-stdlib-1.7.0.jar!/kotlin/Unit.class
e: C:\Users\otillainteractive\AppData\Local\Pub\Cache\hosted\pub.dev\fluttertoast-8.2.2\android\src\main\kotlin\io\github\ponnamkarthik\toast\fluttertoast\MethodCallHandlerImpl.kt: (120, 28): Class 'kotlin.Unit' was compiled with an incompatible version of Kotlin. The binary version of its metadata is 1.7.1, expected version is 1.1.15.
The class is loaded from C:/Users/otillainteractive/.gradle/caches/transforms-3/ec19f90ae186829d7e1bae3bd59e64bd/transformed/jetified-kotlin-stdlib-1.7.0.jar!/kotlin/Unit.class

FAILURE: Build failed with an exception.

 
위 에러들은 kotlin버전이 낮아서 그렇습니다.
 
kotlin버전업!!!
 

buildscript {
    ext.kotlin_version = '1.6.10'
    repositories {
        google()
        jcenter()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.2.2'
        classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
    }
}

 
 
 
 
 

 
이렇게 3년전 프로젝트를 빌드하는데 꼬박 2시간은 걸린듯 합니다.
후우....오래된 프로젝트는 이래서 열기 무섭네요 ^^;
 
 
 
 
이상 오틸라였습니다.
건강하세요~

반응형
댓글