Skip to content

Commit

Permalink
Remove deprecated package attribute from AndroidManifest.xml.
Browse files Browse the repository at this point in the history
  • Loading branch information
tritao committed Apr 29, 2024
1 parent 340b825 commit 7aff648
Showing 1 changed file with 28 additions and 1 deletion.
29 changes: 28 additions & 1 deletion android_studio/android_studio.lua
Original file line number Diff line number Diff line change
Expand Up @@ -197,6 +197,26 @@ function get_dir(file)
return string.match(file, ".*/")
end

-- Extract version number from "com.android.tools.build:gradle:7.3.0"
local function parse_version(str)
local version = string.match(str, "(%d+%.%d+%.%d+)")
if not version then
return nil -- Version not found
end

local major, minor, patch = version:match("(%d+)%.(%d+)%.(%d+)")
if not major or not minor or not patch then
return nil -- Invalid version format
end

return {
major = tonumber(major),
minor = tonumber(minor),
patch = tonumber(patch)
}
end


function m.generate_manifest(prj)
-- look for a manifest in project files
for cfg in project.eachconfig(prj) do
Expand All @@ -215,7 +235,14 @@ function m.generate_manifest(prj)
-- auto generate stub android manifest
p.w('<?xml version="1.0" encoding="utf-8"?>')
p.push('<manifest xmlns:android="http://schemas.android.com/apk/res/android"')
p.x('package="lib.%s"', prj.name)
-- Setting the namespace via the package attribute in the source AndroidManifest.xml is no longer supported.
-- This behaviour was introduced in com.android.tools.build:gradle:7.3.0.
if prj.gradleversion then
local version = parse_version(prj.gradleversion)
if version.major < 7 or (version.major == 7 and version.minor <= 2) then
p.x('package="lib.%s"', prj.name)
end
end
p.w('android:versionCode="1"')
p.w('android:versionName="1.0" >')
p.pop('<application/>')
Expand Down

0 comments on commit 7aff648

Please sign in to comment.