From 4cece3a76a8cd5f798c96d9f2f5cd6946d34c587 Mon Sep 17 00:00:00 2001 From: Ankur Jain Date: Mon, 6 May 2024 11:14:05 -0700 Subject: [PATCH] Check unsupported abis. --- packages/cli/src/config/PublishDetails.ts | 31 ++++++++++++++++++++ packages/core/src/validate/CoreValidation.ts | 2 -- 2 files changed, 31 insertions(+), 2 deletions(-) diff --git a/packages/cli/src/config/PublishDetails.ts b/packages/cli/src/config/PublishDetails.ts index 027c00e..43e820d 100644 --- a/packages/cli/src/config/PublishDetails.ts +++ b/packages/cli/src/config/PublishDetails.ts @@ -325,6 +325,8 @@ const getAndroidDetails = async ( ); } + checkAbis(apkPath); + return { android_package: appPackage?.[1] ?? "", min_sdk: parseInt(minSdk?.[1] ?? "0", 10), @@ -343,6 +345,35 @@ const getAndroidDetails = async ( } }; +const checkAbis = async (apkPath: string) => { + try { + const { stdout } = await runExec(`zipinfo -s ${apkPath} | grep \.so$`); + const amV7libs = [...stdout.matchAll(/lib\/armeabi-v7a\/(.*)/g)].flatMap(permission => permission[1]); + const x86libs = [...stdout.matchAll(/lib\/x86\/(.*)/g)].flatMap(permission => permission[1]); + const x8664libs = [...stdout.matchAll(/lib\/x86_64\/(.*)/g)].flatMap(permission => permission[1]); + if (amV7libs.length > 0 || x86libs.length > 0 || x8664libs.length > 0) { + + const messages = [ + `Solana dApp Store only supports arm64-v8a abi.`, + `Your apk file contains following unsupported abis`, + ... amV7libs.length > 0 ? [`\narmeabi-v7a:\n` + amV7libs] : [], + ... x86libs.length > 0 ? [`\nx86:\n` + x86libs] : [], + ... x8664libs.length > 0 ? [`\nx86_64:\n` + x8664libs] : [], + `\n\nAlthough your app might work, these library files are unused and increase the size of apk file making the user experience worse while installing/updating your app.`, + `\n\nSee https://developer.android.com/games/optimize/64-bit#build-with-64-bit for how to optimize your app.`, + ].join('\n') + + showMessage( + `Unsupported files found in apk`, + messages, + `warning` + ) + } + } catch (e) { + // Ignore this error. + } +} + export const extractCertFingerprint = async (aaptDir: string, apkPath: string): Promise => { const { stdout } = await runExec(`${aaptDir}/apksigner verify --print-certs -v "${apkPath}"`); diff --git a/packages/core/src/validate/CoreValidation.ts b/packages/core/src/validate/CoreValidation.ts index 4412e80..f592803 100644 --- a/packages/core/src/validate/CoreValidation.ts +++ b/packages/core/src/validate/CoreValidation.ts @@ -1,11 +1,9 @@ -import fs from "fs"; import Ajv from "ajv"; import type { AppMetadata, MetaplexFileReleaseJsonMetadata, PublisherMetadata, - ReleaseJsonMetadata } from "../types.js"; // eslint-disable-next-line require-extensions/require-extensions