@@ -181,45 +181,30 @@ public static Runtime initRuntime(Application app) {
181
181
} catch (IOException e ) {
182
182
e .printStackTrace ();
183
183
}
184
- }
185
-
186
- try {
187
- Class NativeScriptSyncService = Class .forName ("com.tns.NativeScriptSyncService" );
188
- Method isSyncEnabledMethod = NativeScriptSyncService .getMethod ("isSyncEnabled" , Context .class );
189
- Boolean isSyncEnabled = (Boolean )isSyncEnabledMethod .invoke (NativeScriptSyncService , app );
190
184
185
+ // if app is in debuggable mode run livesync service
191
186
// runtime needs to be initialized before the NativeScriptSyncService is enabled because it uses runtime.runScript(...)
192
- if (isSyncEnabled ) {
193
- Constructor syncServiceConstructor = NativeScriptSyncService .getConstructor (new Class [] {Runtime .class , Logger .class , Context .class });
194
- Object syncService = syncServiceConstructor .newInstance (runtime , logger , app );
187
+ try {
188
+ Class NativeScriptSyncService = Class .forName ("com.tns.NativeScriptSyncService" );
189
+
190
+ Constructor cons = NativeScriptSyncService .getConstructor (new Class [] {Runtime .class , Logger .class , Context .class });
191
+ Object syncService = cons .newInstance (runtime , logger , app );
195
192
196
193
Method syncMethod = NativeScriptSyncService .getMethod ("sync" );
197
194
syncMethod .invoke (syncService );
198
-
199
195
Method startServerMethod = NativeScriptSyncService .getMethod ("startServer" );
200
196
startServerMethod .invoke (syncService );
201
-
202
- // preserve this instance as strong reference
203
- // do not preserve in NativeScriptApplication field inorder to
204
- // make the code more portable
205
- // @@@
206
- // Runtime.getOrCreateJavaObjectID(syncService );
207
- } else {
208
- if ( logger . isEnabled ()) {
209
- logger . write ( "NativeScript LiveSync is not enabled." );
210
- }
197
+ } catch ( ClassNotFoundException e ) {
198
+ e . printStackTrace ();
199
+ } catch ( NoSuchMethodException e ) {
200
+ e . printStackTrace ();
201
+ } catch ( IllegalAccessException e ) {
202
+ e . printStackTrace ( );
203
+ } catch ( InvocationTargetException e ) {
204
+ e . printStackTrace ();
205
+ } catch ( InstantiationException e ) {
206
+ e . printStackTrace ();
211
207
}
212
-
213
- } catch (ClassNotFoundException e ) {
214
- e .printStackTrace ();
215
- } catch (NoSuchMethodException e ) {
216
- e .printStackTrace ();
217
- } catch (IllegalAccessException e ) {
218
- e .printStackTrace ();
219
- } catch (InvocationTargetException e ) {
220
- e .printStackTrace ();
221
- } catch (InstantiationException e ) {
222
- e .printStackTrace ();
223
208
}
224
209
225
210
runtime .runScript (new File (appDir , "internal/ts_helpers.js" ));
0 commit comments