Skip to content

fix: don't use deprecated package field in AndroidManifest on AGP >= 7.3 #420

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 12, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -64,14 +64,28 @@ def getExtOrIntegerDefault(name) {
return rootProject.ext.has(name) ? rootProject.ext.get(name) : (project.properties["<%- project.name -%>_" + name]).toInteger()
}

def isAGPVersionGreaterThan(version) {
def agpVersion = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger()
return agpVersion > version
def supportsNamespace() {
def parsed = com.android.Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')
def major = parsed[0].toInteger()
def minor = parsed[1].toInteger()

// Namespace support was added in 7.3.0
if (major == 7 && minor >= 3) {
return true
}

return major >= 8
}

android {
if (isAGPVersionGreaterThan(7)) {
if (supportsNamespace()) {
namespace "com.<%- project.package -%>"
} else {
sourceSets {
main {
manifest.srcFile "src/main/AndroidManifestDeprecated.xml"
}
}
}

<% if (project.cpp || (project.view && (project.arch === "new" || project.arch === "mixed"))) { -%>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.<%- project.package -%>">

<manifest xmlns:android="http://schemas.android.com/apk/res/android">
</manifest>
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.<%- project.package -%>">
</manifest>