31 lines
976 B
JavaScript
31 lines
976 B
JavaScript
const { withDangerousMod } = require('@expo/config-plugins');
|
|
const fs = require('fs');
|
|
const path = require('path');
|
|
|
|
const withProguardRules = (config) => {
|
|
return withDangerousMod(config, [
|
|
'android',
|
|
async (config) => {
|
|
const proguardPath = path.join(config.modRequest.platformProjectRoot, 'app', 'proguard-rules.pro');
|
|
const customRules = `
|
|
# Keep ausbc and UVCCamera classes for JNI
|
|
-keep class com.serenegiant.usb.** { *; }
|
|
-keepclassmembers class com.serenegiant.usb.** { *; }
|
|
-keep class com.jiangdg.ausbc.** { *; }
|
|
-keepclassmembers class com.jiangdg.ausbc.** { *; }
|
|
`;
|
|
if (fs.existsSync(proguardPath)) {
|
|
let content = fs.readFileSync(proguardPath, 'utf8');
|
|
if (!content.includes('com.serenegiant.usb')) {
|
|
fs.appendFileSync(proguardPath, customRules);
|
|
}
|
|
} else {
|
|
fs.writeFileSync(proguardPath, customRules);
|
|
}
|
|
return config;
|
|
},
|
|
]);
|
|
};
|
|
|
|
module.exports = withProguardRules;
|