@@ -323,15 +323,33 @@ protected void load(boolean forceNew) {
323
323
if (manifestFile .exists ()) {
324
324
try {
325
325
xml = new XML (manifestFile );
326
-
326
+
327
327
XML app = xml .getChild ("application" );
328
328
String icon = app .getString ("android:icon" );
329
329
if (icon .equals ("@drawable/icon" )) {
330
330
// Manifest file generated with older version of the mode, replace icon and save
331
331
app .setString ("android:icon" , "@mipmap/ic_launcher" );
332
332
if (!forceNew ) save ();
333
- }
334
-
333
+ }
334
+
335
+ XML activity = app .getChild ("activity" );
336
+ XML service = app .getChild ("service" );
337
+ if (activity .getString ("android:name" ).equals (".MainActivity" )) {
338
+ addExportedAttrib (activity );
339
+ if (!forceNew ) save ();
340
+ }
341
+ if (service .getString ("android:name" ).equals (".MainService" )) {
342
+ addExportedAttrib (service );
343
+ if (!forceNew ) save ();
344
+ }
345
+
346
+ XML usesSDK = xml .getChild ("uses-sdk" );
347
+ if (usesSDK != null ) {
348
+ // Manifest file generated with older version of the mode, uses-sdk is no longer needed in manifest
349
+ xml .removeChild (usesSDK );
350
+ if (!forceNew ) save ();
351
+ }
352
+
335
353
} catch (Exception e ) {
336
354
e .printStackTrace ();
337
355
System .err .println ("Problem reading AndroidManifest.xml, creating a new version" );
@@ -394,6 +412,13 @@ protected void load(boolean forceNew) {
394
412
}
395
413
}
396
414
415
+ protected void addExportedAttrib (XML child ) {
416
+ if (!child .hasAttribute ("android:exported" )) {
417
+ // Manifest file generated with older version of the mode, missing android:exported attributed
418
+ child .setString ("android:exported" , "true" );
419
+ }
420
+ }
421
+
397
422
protected void save () {
398
423
save (getManifestFile ());
399
424
}
0 commit comments