我正在使用带有expo-cli的react-native来构建应用程序,并且正在使用以下命令来构建apk:
expo build:android
但是我得到了错误:
Error: ENOENT: no such file or directory, open 'C:\Users\Ahmed Hassan\Desktop\app-name\assets\sounds\alert.mp3'
关于我要使用以下代码在组件中导入的资产:
import { Audio } from 'expo-av';
async function sound() {
const soundObject = new Audio.Sound();
try {
await soundObject.loadAsync(require('../assets/sounds/alert.mp3'));
await soundObject.playAsync();
} catch (error) {
console.log(error);
}
}