@@ -86,6 +86,10 @@ public class AndroidGradleBuilder extends Executor {
86
86
private String gradle8DistributionUrl = "https://services.gradle.org/distributions/gradle-8.1-bin.zip" ;
87
87
public boolean PREFER_MANAGED_GRADLE =true ;
88
88
89
+ private boolean rootCheck = false ;
90
+
91
+ private boolean fridaDetection = false ;
92
+
89
93
private boolean useGradle8 = true ;
90
94
91
95
// Flag to indicate whether we should strip kotlin from user classes
@@ -491,6 +495,8 @@ public boolean build(File sourceZip, final BuildRequest request) throws BuildExc
491
495
boolean facebookSupported = request .getArg ("facebook.appId" , null ) != null ;
492
496
newFirebaseMessaging = request .getArg ("android.newFirebaseMessaging" , "true" ).equals ("true" );
493
497
useGradle8 = request .getArg ("android.useGradle8" , "" +(useGradle8 || newFirebaseMessaging || facebookSupported )).equals ("true" );
498
+ rootCheck = request .getArg ("android.rootCheck" , "false" ).equals ("true" );
499
+ fridaDetection = request .getArg ("android.fridaDetection" , "false" ).equals ("true" );
494
500
extendAppCompatActivity = request .getArg ("android.extendAppCompatActivity" , "false" ).equals ("true" );
495
501
// When using gradle 8 we need to strip kotlin files from user classes otherwise we get duplicate class errors
496
502
stripKotlinFromUserClasses = useGradle8 ;
@@ -1316,11 +1322,11 @@ public void usesClassMethod(String cls, String method) {
1316
1322
1317
1323
debug ("-----USING PLAY SERVICES VERSION " +playServicesVersion +"----" );
1318
1324
1325
+ String compile = "compile" ;
1326
+ if (useAndroidX || useArrImplementation ) {
1327
+ compile = "implementation" ;
1328
+ }
1319
1329
if (useFCM ) {
1320
- String compile = "compile" ;
1321
- if (useAndroidX || useArrImplementation ) {
1322
- compile = "implementation" ;
1323
- }
1324
1330
if (!googleServicesJson .exists ()) {
1325
1331
error ("google-services.json not found. When using FCM for push notifications (i.e. android.messagingService=fcm), you must include valid google-services.json file. Use the Firebase console to add Firebase messaging to your app. https://console.firebase.google.com/u/0/ Then download the google-services.json file and place it in the native/android directory of your project. If you still want to use GCM (which no longer works) define the build hint android.messagingService=gcm" , new RuntimeException ());
1326
1332
return false ;
@@ -2532,6 +2538,30 @@ public void usesClassMethod(String cls, String method) {
2532
2538
2533
2539
}
2534
2540
2541
+ String rootCheckCall = "" ;
2542
+ if (rootCheck ) {
2543
+ if (!request .getArg ("gradleDependencies" , "" ).contains ("com.scottyab:rootbeer-lib" )) {
2544
+ String rootbeerVersion = request .getArg ("android.rootbeerVersion" , "0.1.0" );
2545
+ request .putArgument (
2546
+ "gradleDependencies" ,
2547
+ request .getArg ("gradleDependencies" , "" ) +
2548
+ "\n " +compile +" \" com.scottyab:rootbeer-lib:" + rootbeerVersion + "\" \n "
2549
+ );
2550
+ }
2551
+
2552
+ rootCheckCall = " com.scottyab.rootbeer.RootBeer rootBeer = new com.scottyab.rootbeer.RootBeer(this);\n "
2553
+ + " if (rootBeer.isRooted()) {\n "
2554
+ + " android.util.Log.e(\" Codename One\" , \" Device is rooted. Exiting app.\" );\n "
2555
+ + " System.exit(0);\n "
2556
+ + " }\n " ;
2557
+ }
2558
+
2559
+ String fridaDetectionCall = "" ;
2560
+ if (fridaDetection ) {
2561
+ fridaDetectionCall = " com.codename1.impl.android.FridaDetectionUtil.runFridaDetection(this);\n " ;
2562
+ }
2563
+
2564
+
2535
2565
String waitingForPermissionsRequest =
2536
2566
" if (isWaitingForPermissionResult()) {\n " +
2537
2567
" setWaitingForPermissionResult(false);\n " +
@@ -2588,6 +2618,8 @@ public void usesClassMethod(String cls, String method) {
2588
2618
+ " }\n \n "
2589
2619
+ " public void onCreate(Bundle savedInstanceState) {\n "
2590
2620
+ " super.onCreate(savedInstanceState);\n "
2621
+ + fridaDetectionCall
2622
+ + rootCheckCall
2591
2623
+ facebookHashCode
2592
2624
+ facebookSupport
2593
2625
+ streamMode
@@ -2638,7 +2670,6 @@ public void usesClassMethod(String cls, String method) {
2638
2670
throw new BuildException ("Failed to generate stub source code" , ex );
2639
2671
}
2640
2672
2641
-
2642
2673
String fcmRegisterPushCode = "" ;
2643
2674
if (useFCM ) {
2644
2675
if (newFirebaseMessaging ) {
@@ -3319,10 +3350,6 @@ public void usesClassMethod(String cls, String method) {
3319
3350
request .putArgument ("var.android.playServicesVersion" , playServicesVersion );
3320
3351
String additionalDependencies = request .getArg ("gradleDependencies" , "" );
3321
3352
if (facebookSupported ) {
3322
- String compile = "compile" ;
3323
- if (useAndroidX || useArrImplementation ) {
3324
- compile = "implementation" ;
3325
- }
3326
3353
minSDK = maxInt ("15" , minSDK );
3327
3354
3328
3355
if (request .getArg ("android.excludeBolts" , "false" ).equals ("true" )) {
@@ -3335,10 +3362,7 @@ public void usesClassMethod(String cls, String method) {
3335
3362
facebookSdkVersion + "'\n " ;
3336
3363
}
3337
3364
}
3338
- String compile = "compile" ;
3339
- if (useAndroidX || useArrImplementation ) {
3340
- compile = "implementation" ;
3341
- }
3365
+
3342
3366
if (legacyGplayServicesMode ) {
3343
3367
additionalDependencies += " " +compile +" 'com.google.android.gms:play-services:6.5.87'\n " ;
3344
3368
} else {
0 commit comments