MCPcopy Create free account
hub / github.com/Acode-Foundation/Acode / enableLegacyJni

Function enableLegacyJni

hooks/post-process.js:118–149  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

116
117
118function enableLegacyJni() {
119 const prefix = execSync('npm prefix').toString().trim();
120 const gradleFile = path.join(prefix, 'platforms/android/app/build.gradle');
121
122 if (!fs.existsSync(gradleFile)){
123 console.warn('[Cordova Hook] ⚠️ build.gradle not found');
124 return
125 };
126
127 let content = fs.readFileSync(gradleFile, 'utf-8');
128 // Check for correct block to avoid duplicate insertion
129 if (content.includes('useLegacyPackaging = true')){
130 console.log('[Cordova Hook] ✅ Legacy JNI packaging already enabled, skipping');
131 return
132 };
133
134 // Inject under android block with correct Groovy syntax
135 content = content.replace(/android\s*{/, match => {
136 return (
137 match +
138 `
139 packagingOptions {
140 jniLibs {
141 useLegacyPackaging = true
142 }
143 }`
144 );
145 });
146
147 fs.writeFileSync(gradleFile, content, 'utf-8');
148 console.log('[Cordova Hook] ✅ Enabled legacy JNI packaging');
149}
150
151function enableStaticContext() {
152 try {

Callers 1

post-process.jsFile · 0.85

Calls 2

logMethod · 0.80
toStringMethod · 0.45

Tested by

no test coverage detected