@@ -13,7 +13,6 @@ import { Builder, parseString } from "xml2js";
13
13
import {
14
14
IRuntimeGradleVersions ,
15
15
INodePackageManager ,
16
- IAndroidToolsInfo ,
17
16
IWatchIgnoreListService ,
18
17
} from "../declarations" ;
19
18
import { IPlatformsDataService } from "../definitions/platform" ;
@@ -47,7 +46,6 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
47
46
private $fs : IFileSystem ,
48
47
private $childProcess : IChildProcess ,
49
48
private $hostInfo : IHostInfo ,
50
- private $androidToolsInfo : IAndroidToolsInfo ,
51
49
private $logger : ILogger ,
52
50
private $packageManager : INodePackageManager ,
53
51
private $projectData : IProjectData ,
@@ -423,6 +421,31 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
423
421
) ;
424
422
this . replaceFileContent ( buildGradlePath , "{{pluginName}}" , pluginName ) ;
425
423
this . replaceFileContent ( settingsGradlePath , "{{pluginName}}" , pluginName ) ;
424
+
425
+ // gets the package from the AndroidManifest to use as the namespace or fallback to the `org.nativescript.${shortPluginName}`
426
+ const shortPluginName = getShortPluginName ( pluginName ) ;
427
+
428
+ const manifestPath = path . join (
429
+ pluginTempDir ,
430
+ "src" ,
431
+ "main" ,
432
+ "AndroidManifest.xml"
433
+ ) ;
434
+ const manifestContent = this . $fs . readText ( manifestPath ) ;
435
+
436
+ let packageName = `org.nativescript.${ shortPluginName } ` ;
437
+ const xml = await this . getXml ( manifestContent ) ;
438
+ if ( xml [ "manifest" ] ) {
439
+ if ( xml [ "manifest" ] [ "$" ] [ "package" ] ) {
440
+ packageName = xml [ "manifest" ] [ "$" ] [ "package" ] ;
441
+ }
442
+ }
443
+
444
+ this . replaceFileContent (
445
+ buildGradlePath ,
446
+ "{{pluginNamespace}}" ,
447
+ packageName
448
+ ) ;
426
449
}
427
450
428
451
private async getRuntimeGradleVersions (
@@ -777,18 +800,6 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
777
800
private async buildPlugin (
778
801
pluginBuildSettings : IBuildAndroidPluginData
779
802
) : Promise < void > {
780
- if ( ! pluginBuildSettings . androidToolsInfo ) {
781
- this . $androidToolsInfo . validateInfo ( {
782
- showWarningsAsErrors : true ,
783
- validateTargetSdk : true ,
784
- projectDir : pluginBuildSettings . projectDir ,
785
- } ) ;
786
- pluginBuildSettings . androidToolsInfo =
787
- this . $androidToolsInfo . getToolsInfo ( {
788
- projectDir : pluginBuildSettings . projectDir ,
789
- } ) ;
790
- }
791
-
792
803
const gradlew =
793
804
pluginBuildSettings . gradlePath ??
794
805
( this . $hostInfo . isWindows ? "gradlew.bat" : "./gradlew" ) ;
@@ -798,8 +809,6 @@ export class AndroidPluginBuildService implements IAndroidPluginBuildService {
798
809
pluginBuildSettings . pluginDir ,
799
810
"assembleRelease" ,
800
811
`-PtempBuild=true` ,
801
- `-PcompileSdk=android-${ pluginBuildSettings . androidToolsInfo . compileSdkVersion } ` ,
802
- `-PbuildToolsVersion=${ pluginBuildSettings . androidToolsInfo . buildToolsVersion } ` ,
803
812
`-PappPath=${ this . $projectData . getAppDirectoryPath ( ) } ` ,
804
813
`-PappResourcesPath=${ this . $projectData . getAppResourcesDirectoryPath ( ) } ` ,
805
814
] ;
0 commit comments