@@ -19,6 +19,7 @@ import { XmlFile } from '../xml';
1919import { PropertiesFile } from '../properties' ;
2020import { PlatformProject } from '../platform-project' ;
2121import { readSource } from '../read-src' ;
22+ import { Logger } from '../logger' ;
2223
2324export class AndroidProject extends PlatformProject {
2425 private manifest : XmlFile ;
@@ -83,14 +84,14 @@ export class AndroidProject extends PlatformProject {
8384 getXmlFile ( path : string ) {
8485 return this . getProjectFile (
8586 path ,
86- ( filename : string ) => new XmlFile ( filename , this . project . vfs ) ,
87+ ( filename : string ) => new XmlFile ( filename , this . project . vfs )
8788 ) ;
8889 }
8990
9091 getPropertiesFile ( path : string ) {
9192 return this . getProjectFile (
9293 path ,
93- ( filename : string ) => new PropertiesFile ( filename , this . project . vfs ) ,
94+ ( filename : string ) => new PropertiesFile ( filename , this . project . vfs )
9495 ) ;
9596 }
9697
@@ -118,6 +119,8 @@ export class AndroidProject extends PlatformProject {
118119 ?. getAttribute ( 'package' ) ;
119120 const oldPackageParts = oldPackageName ?. split ( '.' ) ?? [ ] ;
120121
122+ Logger . v ( 'android' , 'setPackageName' , 'setting Android package name to' , packageName , 'from' , oldPackageName ) ;
123+
121124 if ( packageName === oldPackageName ) {
122125 return ;
123126 }
@@ -131,9 +134,11 @@ export class AndroidProject extends PlatformProject {
131134
132135 this . manifest . getDocumentElement ( ) ?. setAttribute ( 'package' , packageName ) ;
133136 await this . appBuildGradle ?. setApplicationId ( packageName ) ;
137+ Logger . v ( 'android' , 'setPackageName' , `set manifest package attribute and applicationId to ${ packageName } ` ) ;
134138 this . manifest . setAttrs ( 'manifest/application/activity' , {
135139 'android:name' : `${ packageName } .MainActivity` ,
136140 } ) ;
141+ Logger . v ( 'android' , 'setPackageName' , `set <activity android:name="${ packageName } .MainActivity"` ) ;
137142
138143 if ( ! this . getAppRoot ( ) ) {
139144 return ;
@@ -143,11 +148,14 @@ export class AndroidProject extends PlatformProject {
143148
144149 const destDir = join ( sourceDir , ...newPackageParts ) ;
145150
146- // TODO: Don't hard code this
147151 const mainActivityName = this . getMainActivityFilename ( ) ;
148152
153+ Logger . v ( 'android' , 'setPackageName' , `Got main activity name ${ mainActivityName } ` ) ;
154+
149155 let activityFile = join ( sourceDir , ...oldPackageParts , mainActivityName ) ;
150156
157+ Logger . v ( 'android' , 'setPackageName' , `Looking for old activity file at ${ activityFile } ` ) ;
158+
151159 // Make the new directory tree and any missing parents
152160 await mkdirp ( destDir ) ;
153161 // Move the old activity file over
@@ -157,6 +165,8 @@ export class AndroidProject extends PlatformProject {
157165 // from the deepest
158166 let sourceDirLeaf = join ( sourceDir , ...oldPackageParts ) ;
159167
168+ Logger . v ( 'android' , 'setPackageName' , `removing old source dirs for old package (${ sourceDirLeaf } )` ) ;
169+
160170 for ( const _ of oldPackageParts ) {
161171 try {
162172 await rmdir ( sourceDirLeaf ) ;
@@ -169,6 +179,7 @@ export class AndroidProject extends PlatformProject {
169179 // Rename the package in the main source file
170180 activityFile = join ( sourceDir , ...newPackageParts , this . getMainActivityFilename ( ) ) ;
171181 if ( await pathExists ( activityFile ) ) {
182+ Logger . v ( 'android' , 'setPackageName' , `renaming package in source for activity file ${ activityFile } ` ) ;
172183 const activitySource = await readFile ( activityFile , {
173184 encoding : 'utf-8' ,
174185 } ) ;
@@ -253,6 +264,8 @@ export class AndroidProject extends PlatformProject {
253264
254265 const dir = join ( root , resDir ) ;
255266
267+ Logger . v ( `android` , 'addResource' , `add res file ${ file } to ${ resDir } ` ) ;
268+
256269 if ( ! ( await pathExists ( dir ) ) ) {
257270 await mkdir ( dir ) ;
258271 }
@@ -266,6 +279,8 @@ export class AndroidProject extends PlatformProject {
266279 }
267280 const destPath = join ( this . project . config . android . path , dest ) ;
268281
282+ Logger . v ( `android` , `copyFile` , `copying ${ src } to ${ destPath } ` ) ;
283+
269284 if ( / ^ ( h t t p s ? : \/ \/ ) / . test ( src ) ) {
270285 const res = await fetch ( src ) ;
271286 return writeFile ( destPath , Buffer . from ( await res . arrayBuffer ( ) ) ) ;
@@ -291,6 +306,8 @@ export class AndroidProject extends PlatformProject {
291306 await mkdir ( dir ) ;
292307 }
293308
309+ Logger . v ( `android` , `copyToResources` , `copying ${ file } to Android resources at ${ join ( dir , file ) } ` ) ;
310+
294311 const sourceData = await readSource ( source ) ;
295312 return writeFile ( join ( dir , file ) , sourceData ) ;
296313 }
0 commit comments