본문 바로가기

EXPERIENCE/Android

[Android] Namespace not specified. Please specify a namespace in the module's build.gradle file like so... 오류

728x90
728x90
SMALL

 

 

 

 

아래 GoolePlay 앱 타겟 API 준수 요구사항 수정을 위한 과정에서 만난 첫번째 오류를 잘 넘기고....

 

 

 

[Flutter/Dart] Deprecated imperative apply of Flutter's Gradle plugins 오류

귀하의 앱 2개가 Google Play의 대상 API 수준 요구사항의 영향을 받습니다앱 2개가 이전 버전의 Android를 타겟팅하는 것으로 확인되었습니다. 사용자에게 안전하고 보안이 유지되는 환경을 제공하기

s-o-h-a.tistory.com

 

 

 

 

두번째로 만난 오류는 바로 이것이다.

Android Gradle Plugin (AGP) 업데이트 후 발생했던거 같은데.. 

 

Namespace not specified. Please specify a namespace in the module's build.gradle file like so:
android {
     namespace 'com.example.namespace'
}
If the package attribute is specified in the source AndroidManifest.xml, it can be migrated automatically to the namespace value in the build .gradle file using the AGP Upgrade Assistant; please refer to https://developer.android.com/studio/build/agp-upgrade-assistant for more information.

 

 

 


이전에는 다운그레이드로 해결
했으나

다른 이슈로 현재는 무조건 상위 버전을 사용해야하기에 다른 방책을 찾아보았다.

 

 

 

 

 

 

728x90

 

 

 

 

 

열심히 StackOverflow를 뒤져보니 다양한 해결방법이 존재했다.

그런데 그 부분으로 인해 다른 오류가 발생하는 경우가 생겨,

내가 해결한 방법은 아래와 같다.

 

 

 

 

 

1. app/build.gradle 수정

plugins {
    id "com.android.application"
    id "kotlin-android"
    id "dev.flutter.flutter-gradle-plugin"
}

def localProperties = new Properties()
def localPropertiesFile = rootProject.file('local.properties')
if (localPropertiesFile.exists()) {
    localPropertiesFile.withReader('UTF-8') { reader ->
        localProperties.load(reader)
    }
}

android {
    namespace 'com.company.appname'

// 생략
}

flutter {
    source '../..'
}

 

app/build.gradle 파일 > android > namespace 작성

위 코드 중 android { namespace ~ } 부분을 추가 한다. 

 


2. 사용 중인 Package/build.gradle 수정

사용 중인 Package Or Plugin

group 'com.mr.flutter.plugin.filepicker'
version '1.0-SNAPSHOT'

buildscript {
    repositories {
        google()
        mavenCentral()
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:7.4.2'
    }
}

rootProject.allprojects {
    repositories {
        google()
        mavenCentral()
    }
}

apply plugin: 'com.android.library'

android {
    namespace 'com.mr.flutter.plugin.filepicker'
    
    //생략
}
사용 중인 패키지/build.gradle 파일 > android >namespace 작성

위 코드 중 android { namespace ~ } 부분을 추가 한다.

 

 

 

모든 사용 중인 Package의 build.gradle 수정

 

 

 

모두 수정해야한다는게 매우.. 귀찮지만...

나는 이 방법이 다른 오류없이 적용하기 좋은 방법이었다 :)

 

추후 각 패키지들이 namespace를 작성한 상위 버전을 내준다면,

해당 오류는 사라지지 않을까..   

 

 

++) 이 외의 방법들

  • android/build.gradle 수정
  subprojects {
    afterEvaluate { project ->
        if (project.hasProperty('android')) {
            project.android {
                if (namespace == null) {
                    namespace project.group
                }
            }
        }
    }
}
android/build.gradle > subprojects 수정

해당 부분으로 해결되었었으나 다른 부분이랑 겹칠 경우 오류가 생겨서 사용하지 못 했던듯!  

 

 

 

 

728x90
728x90
LIST