fix: Set correct namespace in build.gradle (#2104)

* fix: set correct namespace in build.gradle

* chore: refactor Android project for compatibility with multiple Gradle versions

---------

Co-authored-by: Marc Rousavy <me@mrousavy.com>
This commit is contained in:
Adolfo E. García 2023-10-31 08:13:12 -06:00 committed by GitHub
parent cc65ec26a9
commit 8f986a45ea
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 18 additions and 3 deletions

View File

@ -1,4 +1,8 @@
import java.nio.file.Paths import java.nio.file.Paths
import com.android.Version
def agpVersion = Version.ANDROID_GRADLE_PLUGIN_VERSION.tokenize('.')[0].toInteger()
def androidManifestPath = agpVersion >= 7 ? 'src/main/AndroidManifest.xml' : 'src/hasNamespace/AndroidManifest.xml'
buildscript { buildscript {
def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["VisionCamera_kotlinVersion"] def kotlin_version = rootProject.ext.has("kotlinVersion") ? rootProject.ext.get("kotlinVersion") : project.properties["VisionCamera_kotlinVersion"]
@ -73,7 +77,9 @@ repositories {
} }
android { android {
namespace "com.mrousavy.camera" if (agpVersion >= 7) {
namespace "com.mrousavy.camera"
}
// Used to override the NDK path/version on internal CI or by allowing // Used to override the NDK path/version on internal CI or by allowing
// users to customize the NDK path/version from their root project (e.g. for M1 support) // users to customize the NDK path/version from their root project (e.g. for M1 support)
@ -107,6 +113,12 @@ android {
} }
} }
sourceSets {
main {
manifest.srcFile androidManifestPath
}
}
compileOptions { compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8 sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8 targetCompatibility JavaVersion.VERSION_1_8

View File

@ -0,0 +1,4 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.mrousavy.camera">
</manifest>

View File

@ -1,4 +1,3 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android" <manifest xmlns:android="http://schemas.android.com/apk/res/android">
package="com.mrousavy.camera">
</manifest> </manifest>