diff --git a/.github/workflows/android-build.yml b/.github/workflows/android-build.yml index 7a35e87e..2795abae 100644 --- a/.github/workflows/android-build.yml +++ b/.github/workflows/android-build.yml @@ -73,10 +73,21 @@ jobs: exit 1 fi - - name: Check AndroidManifest.xml after prebuild - run: | - echo "AndroidManifest.xml contents after prebuild:" - cat android/app/src/main/AndroidManifest.xml + - name: Verify package name and version after prebuild + run: | + echo "AndroidManifest.xml package and URL:" + grep 'package=' android/app/src/main/AndroidManifest.xml + grep 'android:host=' android/app/src/main/AndroidManifest.xml + echo "build.gradle applicationId and version:" + grep 'applicationId' android/app/build.gradle + grep 'versionCode' android/app/build.gradle + grep 'versionName' android/app/build.gradle + echo "MainActivity.java package:" + grep 'package' android/app/src/main/java/app/shockwallet/my/MainActivity.java + echo "strings.xml app name:" + grep 'app_name' android/app/src/main/res/values/strings.xml + echo "capacitor.config.json package name:" + grep 'packageName' capacitor.config.json || echo "capacitor.config.json not found" - name: Build Android app run: | diff --git a/preBuild/preBuild.ts b/preBuild/preBuild.ts index aa3916f9..65bff98a 100644 --- a/preBuild/preBuild.ts +++ b/preBuild/preBuild.ts @@ -13,32 +13,22 @@ console.log('VITE_APP_URL:', process.env.VITE_APP_URL); console.log('VERSION:', process.env.VERSION); console.log('VERSION_CODE:', process.env.VERSION_CODE); +// Update AndroidManifest.xml const androidManifestPath = path.join(__dirname, '..', 'android', 'app', 'src', 'main', 'AndroidManifest.xml'); let androidManifest = fs.readFileSync(androidManifestPath, 'utf8'); -console.log('Before AndroidManifest.xml update:'); -console.log(androidManifest); - -// Replace the app URL -androidManifest = androidManifest.replace( - /[^<]+<\/string>/, + `${process.env.VITE_APP_NAME}` +); + +fs.writeFileSync(stringsXmlPath, stringsXml); +console.log('strings.xml updated successfully'); + +// Update capacitor.config.json or capacitor.config.ts +const capacitorConfigPath = path.join(__dirname, '..', 'capacitor.config.json'); +if (fs.existsSync(capacitorConfigPath)) { + let capacitorConfig = JSON.parse(fs.readFileSync(capacitorConfigPath, 'utf8')); + capacitorConfig.android = capacitorConfig.android || {}; + capacitorConfig.android.packageName = process.env.VITE_ANDROID_APPLICATION_ID; + fs.writeFileSync(capacitorConfigPath, JSON.stringify(capacitorConfig, null, 2)); + console.log('capacitor.config.json updated successfully'); +} else { + console.log('capacitor.config.json not found. Make sure to update it manually if needed.'); +} + console.log('Prebuild script completed'); \ No newline at end of file