问题
The app is running fine on virtual device AVD nexus5. But when I am trying to test my corova android app I am getting error. I am using Android Studio 1.3. I have create the app using cordova CLI and then imported in Android Studio. Also my device -Mi4i is running Android 5.0 (Does this makes any difference?)
Compile SDK version: API 22 (5.1, Lollipop) Build Tools version: 22.0.1
The errors in logcat are:
a) E/SysUtils﹕ ApplicationContext is null in ApplicationStatus
b) E/libEGL﹕ validate_display:255 error 3008 (EGL_BAD_DISPLAY)
When inspected using chrome developer tools, this error is shown:
Failed to load resource: net::ERR_ADDRESS_UNREACHABLE
http://10.0.2.2/s/state?callback=jQuery213013105976837687194_1442380968984&_=1442380968985
回答1:
Now, I am able to test/run my app in the device connected with USB.
I am writing the important points!
First of all, make sure you are connected with the mobile with 'Connected as Camera (PTP)' option and not 'Media Device(MTP)'.
Also, I uninstalled my app that I got installed earlier from the mobile!
Next I changed the 'versions' info of my application from 'Android Studio'.
Here's how I did it:
1) Open 'app' in Android Studio
2) Open 'Project Structure' dialog box (File menu -> project structure)
Fig. 1
Next on Properties Tab
Changed ‘Compile Sdk Version’ to API 21
Changed ‘Build Tools Version’ to 21.1.2
Source Compatibility to 1.7
Target Compatibility to 1.7
Select Min Sdk Version to API15 ( Though as of now, Min Sdk version is API14)
Select 'Target Sdk Version' to API 21
And lastly, Changed the server Url (accessed in app) from ‘http://10.0.2.2’ to ‘http://54.xx.xx.xx’ i.e. url of remote server!
When trying to access ‘http://10.0.2.2’ I was getting error “net::ERR_NAME_NOT_RESOLVED”.
But on remote server my app was running without errors! Make sure you are connected with internet.
来源:https://stackoverflow.com/questions/32601116/not-able-to-test-cordova-android-app-in-device-attached-via-usb