Skip to content

Commit

Permalink
Remove Google Play settings on the Android build platform
Browse files Browse the repository at this point in the history
  • Loading branch information
qiuguohua committed Dec 17, 2024
1 parent 405fca8 commit 896fc71
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 80 deletions.
79 changes: 0 additions & 79 deletions scripts/native-pack-tool/source/platforms/android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export interface IAndroidParams {
ndkPath: string;
javaHome: string;
javaPath: string;
androidInstant: boolean,
maxAspectRatio: string;
remoteUrl?: string;
apiLevel: number;
Expand Down Expand Up @@ -125,21 +124,6 @@ export class AndroidPackTool extends NativePackTool {
}


// compile android-instant
if (options.androidInstant) {
buildMode = `instantapp:assemble${outputMode}`;
await cchelper.runCmd(gradle, [buildMode], false, projDir);
}

// compile google app bundle
if (options.appBundle) {
if (options.androidInstant) {
buildMode = `bundle${outputMode}`;
} else {
buildMode = `${this.params.projectName}:bundle${outputMode}`;
}
await cchelper.runCmd(gradle, [buildMode], false, projDir);
}
return await this.copyToDist();
}

Expand Down Expand Up @@ -274,28 +258,6 @@ export class AndroidPackTool extends NativePackTool {
}

};
const fnUpdateCategory = (data: any) => {
if (!this.params.platformParams.androidInstant) {
console.log('android instant not configured');
return;
}
const url = this.params.platformParams.remoteUrl;
if (!url) {
return;
}
const urlInfo = URL.parse(url);
if (!urlInfo.host) {
throw new Error(`parse url ${url} fail`);
}
const intentFilter: any = data.manifest.application[0].activity[0]['intent-filter'][0];
if (intentFilter) {
intentFilter.data ||= [];
intentFilter.data = intentFilter.data.concat([
{ $: { 'android:host': urlInfo.host, 'android:pathPattern': urlInfo.path, 'android:scheme': 'https' } },
{ $: { 'android:scheme': 'http' } }
]);
}
}

if (fs.existsSync(manifestPath)) {
const app = await fnParseXml(manifestPath);
Expand All @@ -309,7 +271,6 @@ export class AndroidPackTool extends NativePackTool {
await fnUpdateOrientation(instant.data);
await fnUpdateResizeableActivity(instant.data);
await fnUpdateMaxAspectRation(instant.data);
await fnUpdateCategory(instant.data);
await instant.save();
}
}
Expand Down Expand Up @@ -355,7 +316,6 @@ export class AndroidPackTool extends NativePackTool {
content = content.replace(/PROP_COMPILE_SDK_VERSION=.*/, `PROP_COMPILE_SDK_VERSION=${Math.max(apiLevel, compileSDKVersion, 27)}`);
content = content.replace(/PROP_MIN_SDK_VERSION=.*/, `PROP_MIN_SDK_VERSION=${Math.min(apiLevel, minimalSDKVersion)}`);
content = content.replace(/PROP_APP_NAME=.*/, `PROP_APP_NAME=${this.params.projectName}`);
content = content.replace(/PROP_ENABLE_INSTANT_APP=.*/, `PROP_ENABLE_INSTANT_APP=${options.androidInstant ? "true" : "false"}`);
content = content.replace(/PROP_ENABLE_INPUTSDK=.*/, `PROP_ENABLE_INPUTSDK=${options.inputSDK ? "true" : "false"}`);
content = content.replace(/PROP_IS_DEBUG=.*/, `PROP_IS_DEBUG=${this.params.debug ? "true" : "false"}`);

Expand Down Expand Up @@ -391,37 +351,6 @@ export class AndroidPackTool extends NativePackTool {
}
}

/**
* Deprecated, only be compatible with historical packaging tools
*/
protected async configAndroidInstant() {
if (!this.params.platformParams.androidInstant) {
console.log('android instant not configured');
return;
}
const url = this.params.platformParams.remoteUrl;
if (!url) {
return;
}
const manifestPath = cchelper.join(this.paths.platformTemplateDirInPrj, 'instantapp/AndroidManifest.xml');
if (!fs.existsSync(manifestPath)) {
throw new Error(`${manifestPath} not found`);
}
const urlInfo = URL.parse(url);
if (!urlInfo.host) {
throw new Error(`parse url ${url} fail`);
}
let manifest = fs.readFileSync(manifestPath, 'utf8');
manifest = manifest.replace(/<category\s*android:name="android.intent.category.DEFAULT"\s*\/>/, (str) => {
let newStr = '<category android:name="android.intent.category.DEFAULT" />';
newStr += `\n <data android:host="${urlInfo.host}" android:pathPattern="${urlInfo.path}" android:scheme="https"/>`
+ `\n <data android:scheme="http"/>`;
return newStr;
});

fs.writeFileSync(manifestPath, manifest, 'utf8');
}

private async generateAppNameValues() {
const valuesPath = cchelper.join(this.paths.platformTemplateDirInPrj, 'res/values/strings.xml');
const matchCnt = fs.readFileSync(valuesPath, 'utf8').toString().split('\n').map(x => x.trim()).filter(x => /name=\"app_name\"/.test(x)).length;
Expand Down Expand Up @@ -452,14 +381,6 @@ export class AndroidPackTool extends NativePackTool {
throw new Error(`apk not found at ${apkPath}`);
}
fs.copyFileSync(apkPath, ps.join(destDir, apkName));
if (options.androidInstant) {
apkName = `instantapp-${suffix}.apk`;
apkPath = ps.join(this.paths.nativePrjDir, `build/instantapp/outputs/apk/${suffix}/${apkName}`);
if (!fs.existsSync(apkPath)) {
throw new Error(`instant apk not found at ${apkPath}`);
}
fs.copyFileSync(apkPath, ps.join(destDir, apkName));
}

if (options.appBundle) {
apkName = `${this.params.projectName}-${suffix}.aab`;
Expand Down
2 changes: 1 addition & 1 deletion templates/android/build/gradle.properties
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,7 @@ PROP_BUILD_TOOLS_VERSION=34.0.0
PROP_APP_NAME=Cocos Game

# Instant App
PROP_ENABLE_INSTANT_APP=true
PROP_ENABLE_INSTANT_APP=false

# InputSDK
PROP_ENABLE_INPUTSDK=false
Expand Down

0 comments on commit 896fc71

Please sign in to comment.