File tree Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Expand file tree Collapse file tree 1 file changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -159,7 +159,22 @@ export const getAndroidCurrentBundleID = () => {
159
159
const selector = 'manifest' ;
160
160
const element = getElementFromXml ( { filepath, selector } ) ;
161
161
162
- return element . attr ( 'package' ) ;
162
+ // parse AndroidManifest.xml
163
+ const bundleIDFromManifest = element . attr ( 'package' ) ;
164
+ if ( bundleIDFromManifest ) {
165
+ return bundleIDFromManifest ;
166
+ }
167
+
168
+ // parse android/app/build.gradle
169
+ const gradleFile = path . join ( APP_PATH , 'android' , 'app' , 'build.gradle' ) ;
170
+ const gradleFileContent = fs . readFileSync ( gradleFile , 'utf8' ) ;
171
+ const bundleIDFromGradle = gradleFileContent . match ( / a p p l i c a t i o n I d \s + [ ' " ] ( .+ ) [ ' " ] / ) [ 1 ] ;
172
+
173
+ if ( bundleIDFromGradle ) {
174
+ return bundleIDFromGradle ;
175
+ }
176
+
177
+ throw new Error ( `Unable to get bundleID from manifest or gradle file for project ${ APP_PATH } ` ) ;
163
178
} ;
164
179
165
180
/**
You can’t perform that action at this time.
0 commit comments