简体   繁体   中英

Android Studio integration with MobileFirst

I have several problems running the native android example (Hello World) from IBM MobileFirst Studio (Eclipse Kepler) with an integration with Android Studio.

I followed all the steps in the documentation including all prerequisites here . When I run the application via the context menu: Right click on the application Run As > Android Studio Project . MobileFirst launches Android Studio, but the application remains with the following errors and warnings in AndroidStudio configuration:

  1. Warning: AndroidStudio asks me to migrate to Gradle. I ignore this migration, because I have found that the compilation and deployment Gradle is quite delayed.
  2. I select my project and pressed F4, in the Project > Project SDK option, the SDK is invalid, I select one valid.
  3. In the Modules > Modules SDK option, the SDK is invalid, I select one favorite, same as above.
  4. In the Libraries option, there are 3 libraries not found, so I remove the references.
  5. In SDK option I select only the API 10.

At this point the application compiles and deploys the emulator correctly. When running, the IBM splash screen appears and closes immediately without entering the application.

The following appears on the logcat:

02-20 09:43:00.135      582-582/com.HelloWorld I/CordovaLog﹕ Changing log level to DEBUG(3)
02-20 09:43:00.165      582-582/com.HelloWorld I/dalvikvm﹕ Failed resolving Lcom/worklight/wlclient/api/WLClient$ActivityListener; interface 16 'Landroid/app/Application$ActivityLifecycleCallbacks;'
02-20 09:43:00.165      582-582/com.HelloWorld W/dalvikvm﹕ Link of class 'Lcom/worklight/wlclient/api/WLClient$ActivityListener;' failed
02-20 09:43:00.176      582-582/com.HelloWorld I/dalvikvm﹕ Failed resolving Lcom/worklight/wlclient/api/WLClient$ActivityListener; interface 16 'Landroid/app/Application$ActivityLifecycleCallbacks;'
02-20 09:43:00.176      582-582/com.HelloWorld W/dalvikvm﹕ Link of class 'Lcom/worklight/wlclient/api/WLClient$ActivityListener;' failed
02-20 09:43:00.176      582-582/com.HelloWorld E/dalvikvm﹕ Could not find class 'com.worklight.wlclient.api.WLClient$ActivityListener', referenced from method com.worklight.wlclient.api.WLClient.<init>
02-20 09:43:00.176      582-582/com.HelloWorld W/dalvikvm﹕ VFY: unable to resolve new-instance 1728 (Lcom/worklight/wlclient/api/WLClient$ActivityListener;) in Lcom/worklight/wlclient/api/WLClient;
02-20 09:43:00.176      582-582/com.HelloWorld D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x003d
02-20 09:43:00.195      582-582/com.HelloWorld D/dalvikvm﹕ VFY: dead code 0x003f-0048 in Lcom/worklight/wlclient/api/WLClient;.<init> (Landroid/content/Context;)V
02-20 09:43:00.205      582-582/com.HelloWorld I/dalvikvm﹕ Failed resolving Lcom/worklight/wlclient/api/WLClient$ActivityListener; interface 16 'Landroid/app/Application$ActivityLifecycleCallbacks;'
02-20 09:43:00.205      582-582/com.HelloWorld W/dalvikvm﹕ Link of class 'Lcom/worklight/wlclient/api/WLClient$ActivityListener;' failed
02-20 09:43:00.205      582-582/com.HelloWorld I/dalvikvm﹕ Failed resolving Lcom/worklight/wlclient/api/WLClient$ActivityListener; interface 16 'Landroid/app/Application$ActivityLifecycleCallbacks;'
02-20 09:43:00.205      582-582/com.HelloWorld W/dalvikvm﹕ Link of class 'Lcom/worklight/wlclient/api/WLClient$ActivityListener;' failed
02-20 09:43:00.215      582-582/com.HelloWorld I/dalvikvm﹕ Could not find method com.worklight.wlclient.api.WLClient$ActivityListener.isAppInBackground, referenced from method com.worklight.wlclient.api.WLClient.isApplicationSentToBackground
02-20 09:43:00.215      582-582/com.HelloWorld W/dalvikvm﹕ VFY: unable to resolve virtual method 12490: Lcom/worklight/wlclient/api/WLClient$ActivityListener;.isAppInBackground ()Z
02-20 09:43:00.215      582-582/com.HelloWorld D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x000c
02-20 09:43:00.215      582-582/com.HelloWorld D/dalvikvm﹕ VFY: dead code 0x000f-000f in Lcom/worklight/wlclient/api/WLClient;.isApplicationSentToBackground (Landroid/content/Context;)Z
02-20 09:43:00.365      582-592/com.HelloWorld W/WLClient﹕ WLClient.createInstance in WLClient.java:208 :: You should pass a context that is assignable from the Activity class. WLClient instance may be used to start an activity.
02-20 09:43:00.955      582-582/com.HelloWorld I/dalvikvm﹕ Failed resolving Lcom/worklight/androidgap/WLSplashScreen$ActivityListener; interface 16 'Landroid/app/Application$ActivityLifecycleCallbacks;'
02-20 09:43:00.955      582-582/com.HelloWorld W/dalvikvm﹕ Link of class 'Lcom/worklight/androidgap/WLSplashScreen$ActivityListener;' failed
02-20 09:43:00.955      582-582/com.HelloWorld E/dalvikvm﹕ Could not find class 'com.worklight.androidgap.WLSplashScreen$ActivityListener', referenced from method com.worklight.androidgap.WLSplashScreen.displaySplashDialog
02-20 09:43:00.955      582-582/com.HelloWorld W/dalvikvm﹕ VFY: unable to resolve new-instance 1261 (Lcom/worklight/androidgap/WLSplashScreen$ActivityListener;) in Lcom/worklight/androidgap/WLSplashScreen;
02-20 09:43:00.955      582-582/com.HelloWorld D/dalvikvm﹕ VFY: replacing opcode 0x22 at 0x0064
02-20 09:43:00.955      582-582/com.HelloWorld D/dalvikvm﹕ VFY: dead code 0x0066-006f in Lcom/worklight/androidgap/WLSplashScreen;.displaySplashDialog (Landroid/app/Activity;I)V
02-20 09:43:00.975      582-592/com.HelloWorld D/wl.splashscreen﹕ WLSplashScreen.show in WLSplashScreen.java:64 :: Showing Splash Screen
02-20 09:43:01.035      582-582/com.HelloWorld D/dalvikvm﹕ GC_EXTERNAL_ALLOC freed 735K, 55% free 2796K/6151K, external 2002K/2137K, paused 60ms
02-20 09:43:01.105      582-582/com.HelloWorld D/CordovaActivity﹕ Resuming the App
02-20 09:43:01.855      582-592/com.HelloWorld D/prepackagedAssetManager﹕ PrepackagedAssetsManager.copyPrepackagedAssetsToLocalStorage in PrepackagedAssetsManager.java:68 :: New installation/upgrade detected, copying resources and saving new checksum
02-20 09:43:02.195      582-592/com.HelloWorld D/wl﹕ WL.doPrepareAssetsWork in WL.java:287 :: no need to check web resource integrity
02-20 09:43:02.205      582-582/com.HelloWorld D/CordovaActivity﹕ CordovaActivity.init()
02-20 09:43:02.215      582-582/com.HelloWorld I/dalvikvm﹕ Could not find method android.webkit.WebView.<init>, referenced from method org.apache.cordova.CordovaWebView.<init>
02-20 09:43:02.215      582-582/com.HelloWorld W/dalvikvm﹕ VFY: unable to resolve direct method 551: Landroid/webkit/WebView;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;IZ)V
02-20 09:43:02.215      582-582/com.HelloWorld D/dalvikvm﹕ VFY: replacing opcode 0x70 at 0x0000
02-20 09:43:02.215      582-582/com.HelloWorld D/dalvikvm﹕ VFY: dead code 0x0003-0011 in Lorg/apache/cordova/CordovaWebView;.<init> (Landroid/content/Context;Landroid/util/AttributeSet;IZ)V
02-20 09:43:02.215      582-582/com.HelloWorld I/dalvikvm﹕ Could not find method android.webkit.WebView.setWebContentsDebuggingEnabled, referenced from method org.apache.cordova.CordovaWebView.enableRemoteDebugging
02-20 09:43:02.215      582-582/com.HelloWorld W/dalvikvm﹕ VFY: unable to resolve static method 569: Landroid/webkit/WebView;.setWebContentsDebuggingEnabled (Z)V
02-20 09:43:02.215      582-582/com.HelloWorld D/dalvikvm﹕ VFY: replacing opcode 0x71 at 0x0001
02-20 09:43:02.295      582-582/com.HelloWorld I/dalvikvm﹕ Could not find method android.content.Intent.setSelector, referenced from method org.apache.cordova.CordovaUriHelper.shouldOverrideUrlLoading
02-20 09:43:02.295      582-582/com.HelloWorld W/dalvikvm﹕ VFY: unable to resolve virtual method 186: Landroid/content/Intent;.setSelector (Landroid/content/Intent;)V
02-20 09:43:02.305      582-582/com.HelloWorld D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x005a
02-20 09:43:02.345      582-582/com.HelloWorld D/CordovaWebView﹕ CordovaWebView is running on device made by: unknown
02-20 09:43:02.375      582-582/com.HelloWorld I/CordovaWebView﹕ Disabled addJavascriptInterface() bridge since Android version is old.
02-20 09:43:02.375      582-582/com.HelloWorld D/CordovaActivity﹕ CordovaActivity.createViews()
02-20 09:43:02.385      582-582/com.HelloWorld D/CordovaWebView﹕ >>> loadUrl(file:///android_asset/www/skinLoader.html)
02-20 09:43:02.385      582-582/com.HelloWorld D/PluginManager﹕ init()
02-20 09:43:02.385      582-582/com.HelloWorld I/dalvikvm﹕ Could not find method android.webkit.CookieManager.setAcceptThirdPartyCookies, referenced from method com.worklight.androidgap.plugin.WLInitializationPlugin.initialize
02-20 09:43:02.385      582-582/com.HelloWorld W/dalvikvm﹕ VFY: unable to resolve virtual method 505: Landroid/webkit/CookieManager;.setAcceptThirdPartyCookies (Landroid/webkit/WebView;Z)V
02-20 09:43:02.385      582-582/com.HelloWorld D/dalvikvm﹕ VFY: replacing opcode 0x6e at 0x001a
02-20 09:43:02.405      582-582/com.HelloWorld D/CordovaWebView﹕ >>> loadUrlNow()
02-20 09:43:02.415      582-582/com.HelloWorld D/SoftKeyboardDetect﹕ Ignore this event
02-20 09:43:02.575      582-582/com.HelloWorld D/CordovaWebViewClient﹕ onPageStarted(file:///android_asset/www/skinLoader.html)
02-20 09:43:02.609      582-582/com.HelloWorld D/CordovaActivity﹕ onMessage(onPageStarted,file:///android_asset/www/skinLoader.html)
02-20 09:43:03.065      582-582/com.HelloWorld D/JsMessageQueue﹕ Set native->JS mode to OnlineEventsBridgeMode
02-20 09:43:03.105      582-582/com.HelloWorld D/CordovaWebViewClient﹕ onPageFinished(file:///android_asset/www/skinLoader.html)
02-20 09:43:03.105      582-582/com.HelloWorld D/CordovaActivity﹕ onMessage(onPageFinished,file:///android_asset/www/skinLoader.html)
02-20 09:43:03.465      582-584/com.HelloWorld D/dalvikvm﹕ GC_CONCURRENT freed 762K, 51% free 3311K/6727K, external 2660K/2812K, paused 3ms+4ms
02-20 09:43:03.485      582-583/com.HelloWorld D/webviewglue﹕ nativeDestroy view: 0x2b5580
02-20 09:43:03.495      582-594/com.HelloWorld D/dalvikvm﹕ GREF has increased to 201
02-20 09:43:04.295      582-582/com.HelloWorld V/StatusBar﹕ StatusBar: initialization
02-20 09:43:04.295      582-582/com.HelloWorld V/StatusBar﹕ Executing action: _ready
02-20 09:43:04.295      582-582/com.HelloWorld W/CordovaPlugin﹕ Attempted to send a second callback for ID: StatusBar792861772
    Result was: "Invalid action"
02-20 09:43:04.325      582-582/com.HelloWorld D/CordovaActivity﹕ onMessage(spinner,stop)
02-20 09:43:04.715      582-582/com.HelloWorld D/CordovaNetworkManager﹕ Connection Type: 3g
02-20 09:43:04.715      582-582/com.HelloWorld D/CordovaNetworkManager﹕ Connection Extra Info: internet
02-20 09:43:04.745      582-582/com.HelloWorld D/CordovaNetworkManager﹕ Connection Type: 3g
02-20 09:43:04.745      582-582/com.HelloWorld D/CordovaNetworkManager﹕ Connection Extra Info: internet
02-20 09:43:04.745      582-582/com.HelloWorld D/CordovaActivity﹕ onMessage(networkconnection,3g)
02-20 09:43:04.805      582-582/com.HelloWorld D/CordovaWebViewClient﹕ onPageStarted(file:///android_asset/www/default/index.html)
02-20 09:43:04.805      582-582/com.HelloWorld D/JsMessageQueue﹕ Set native->JS mode to null
02-20 09:43:04.805      582-582/com.HelloWorld D/CordovaActivity﹕ onMessage(onPageStarted,file:///android_asset/www/default/index.html)
02-20 09:43:04.835      582-600/com.HelloWorld D/szipinf﹕ Initializing inflate state
02-20 09:43:04.845      582-600/com.HelloWorld D/szipinf﹕ Initializing zlib to inflate
02-20 09:43:04.885      582-600/com.HelloWorld D/szipinf﹕ Initializing inflate state
02-20 09:43:04.885      582-600/com.HelloWorld D/szipinf﹕ Initializing zlib to inflate
02-20 09:43:05.065      582-584/com.HelloWorld D/dalvikvm﹕ GC_CONCURRENT freed 609K, 46% free 3905K/7175K, external 2283K/2812K, paused 3ms+17ms
02-20 09:43:05.125      582-582/com.HelloWorld D/CordovaActivity﹕ onMessage(spinner,stop)
02-20 09:43:05.215      582-582/com.HelloWorld D/JsMessageQueue﹕ Set native->JS mode to OnlineEventsBridgeMode
02-20 09:43:09.196      582-582/com.HelloWorld D/CordovaWebViewClient﹕ onPageFinished(file:///android_asset/www/default/index.html)
02-20 09:43:09.196      582-582/com.HelloWorld D/CordovaActivity﹕ onMessage(onPageFinished,file:///android_asset/www/default/index.html)
02-20 09:43:09.826      582-582/com.HelloWorld V/StatusBar﹕ Executing action: _ready
02-20 09:43:09.826      582-582/com.HelloWorld W/CordovaPlugin﹕ Attempted to send a second callback for ID: StatusBar12635921
    Result was: "Invalid action"
02-20 09:43:09.836      582-582/com.HelloWorld D/CordovaActivity﹕ onMessage(spinner,stop)
02-20 09:43:09.866      582-582/com.HelloWorld D/CordovaNetworkManager﹕ Connection Type: 3g
02-20 09:43:09.866      582-582/com.HelloWorld D/CordovaNetworkManager﹕ Connection Extra Info: internet
02-20 09:43:10.206      582-592/com.HelloWorld D/NONE﹕ ondeviceready event dispatched
02-20 09:43:10.316      582-582/com.HelloWorld W/PluginManager﹕ THREAD WARNING: exec() call to Globalization.getLocaleName blocked the main thread for 80ms. Plugin should use CordovaInterface.getThreadPool().
02-20 09:43:10.366      582-582/com.HelloWorld W/PluginManager﹕ THREAD WARNING: exec() call to Globalization.getNumberPattern blocked the main thread for 46ms. Plugin should use CordovaInterface.getThreadPool().
02-20 09:43:10.416      582-592/com.HelloWorld D/NONE﹕ wlclient init started
02-20 09:43:10.515      582-582/com.HelloWorld W/PluginManager﹕ THREAD WARNING: exec() call to LoggerPlugin.log blocked the main thread for 22ms. Plugin should use CordovaInterface.getThreadPool().
02-20 09:43:10.526      582-592/com.HelloWorld D/NONE﹕ Read cookies: null
02-20 09:43:10.546      582-592/com.HelloWorld D/NONE﹕ CookieMgr read cookies: {}
02-20 09:43:10.606      582-594/com.HelloWorld W/dalvikvm﹕ JNI WARNING: jarray 0x406abb20 points to non-array object (Ljava/lang/String;)
02-20 09:43:10.606      582-594/com.HelloWorld I/dalvikvm﹕ "WebViewCoreThread" prio=5 tid=11 NATIVE
02-20 09:43:10.616      582-594/com.HelloWorld I/dalvikvm﹕ | group="main" sCount=0 dsCount=0 obj=0x40589878 self=0x2c5620
02-20 09:43:10.616      582-594/com.HelloWorld I/dalvikvm﹕ | sysTid=594 nice=0 sched=0/0 cgrp=default handle=2917456
02-20 09:43:10.616      582-594/com.HelloWorld I/dalvikvm﹕ | schedstat=( 6162204949 1843580323 915 )
02-20 09:43:10.616      582-594/com.HelloWorld I/dalvikvm﹕ at android.webkit.JWebCoreJavaBridge.setNetworkOnLine(Native Method)
02-20 09:43:10.616      582-594/com.HelloWorld I/dalvikvm﹕ at android.webkit.JWebCoreJavaBridge.setNetworkOnLine(Native Method)
02-20 09:43:10.616      582-594/com.HelloWorld I/dalvikvm﹕ at android.webkit.WebViewCore$EventHub$1.handleMessage(WebViewCore.java:1099)
02-20 09:43:10.616      582-594/com.HelloWorld I/dalvikvm﹕ at android.os.Handler.dispatchMessage(Handler.java:99)
02-20 09:43:10.616      582-594/com.HelloWorld I/dalvikvm﹕ at android.os.Looper.loop(Looper.java:123)
02-20 09:43:10.616      582-594/com.HelloWorld I/dalvikvm﹕ at android.webkit.WebViewCore$WebCoreThread.run(WebViewCore.java:629)
02-20 09:43:10.616      582-594/com.HelloWorld I/dalvikvm﹕ at java.lang.Thread.run(Thread.java:1019)
02-20 09:43:10.616      582-594/com.HelloWorld I/dalvikvm﹕ [ 02-20 09:43:10.616   582:0x252 E/dalvikvm ]
    VM aborting

Another problem is that when I return to launch the application from MobileFirst, AndroidStudio opens and asks me reload modified files (from MobileFirst) externally, apparently not synchronized and changes to the settings disappear.

Anyone know how to solve these problems?

I should clarify that for AndroidStudio be executed, I had to install a Fix Pack MobileFirst.

Sorry for my English.

Thanks for your opinions and help.

Gradle is not supported by Worklight projects for Android at this time.

For the rest of the issues, I got it to work by:

  1. Specifying an SDK
  2. In app-name.iml, remove the scope from the following line:

     <orderEntry type="library" name="libs" level="project" /> 

Looks like something has changed recently in Android Studio because projects used to work out of the box with it (except for Gradle, which is not supported at this time).

Try the above.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM