Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

debug phoneGap android app running on genymotion/Virtual Box emulator #188

Closed
kadia8161 opened this issue Sep 3, 2016 · 12 comments
Closed

Comments

@kadia8161
Copy link

kadia8161 commented Sep 3, 2016

I have Created a project in phoneGap and running it on Oracle Virtual box Android Emulator(downloaded using genymotion).
I need to know how can i debug project using vs-cdoe
I have added extension for cordvoa tools in vs code

@MSLaguana
Copy link
Member

@kadia8161 if you run adb devices, do you see the emulator show up? If not, can you follow the instructions at https://www.genymotion.com/faq/#adb-other-workstation-connection to connect adb to the emulator?

Once adb can connect to the emulator, from there you should be able to treat it as a device in vscode. You can verify this by trying to run cordova run android and see if the app installs and runs on the emulator. You do not run cordova emulate android since that will attempt to launch the google android emulator rather than using the genymotion emulator.

@mbraude
Copy link

mbraude commented Sep 7, 2016

Hi @kadia8161, thanks for reaching out to us. Please let us know if there is anything else we can do to help you.

@mbraude mbraude closed this as completed Sep 7, 2016
@kadia8161
Copy link
Author

sorry for late replay
thanks to @MSLaguana for guidance.
i go through that link provided by you i am still facing problem connecting VirtualBox device using adb connect but that is not concern with this so first i will solve it and then try to connect device from vscode.

@mbraude i will let you know if i have any other issue.

@kadia8161
Copy link
Author

hi @MSLaguana , @mbraude
hi have solved adb connect error now i can see my virtual device in adb device list but i have two issues.
when i debug using following options

  1. Simulate Android on browser
    I get this in debug console ..

Launching for android (This may take a while)...
Attaching to app
Failed to load resource: net::ERR_EMPTY_RESPONSE

  1. Run android on device ( for my virtual device running on VM VirtualBox)
    i get following error

No scripts found for hook "before_run".
No scripts found for hook "before_prepare".
Checking config.xml for saved platforms that haven't been added to the project
Checking for any plugins added to the project that have not been installed in android platform
No differences found between plugins added to project and installed in android platform. Continuing...
Generating platform-specific config.xml from defaults for android at d:\Mobile Development\Android Project\HelloWorld\HelloWorld\platforms\android\res\xml\config.xml
Merging project's config.xml into platform-specific android config.xml
Merging and updating files from [www, platforms\android\platform_www] to platforms\android\assets\www
Wrote out android application name "HelloWorld" to d:\Mobile Development\Android Project\HelloWorld\HelloWorld\platforms\android\res\values\strings.xml
android-versionCode not found in config.xml. Generating a code based on version in config.xml (1.0.0): 10000

Ln 4, Col 10Spaces: 4UTF-8LFJSON
00
Open launch.jsonClose
Error[cordova-debug-adapter] Error: 'cordova run android --device --verbose' failed with exit code 1

Note : I am able to run same app using phoneGap windows application on virtual device

can you help me out...

@MSLaguana
Copy link
Member

For your first issue there, that ERR_EMPTY_RESPONSE is happening inside your app. Do you make XMLHttpRequests? when simulating in a browser (which does not require an emulator at all, by the way) we proxy XHR to get around CORS issues, but it may create other issues on corporate networks it seems. You can try specifying "corsproxy": false, in the launch.json entry.

For the second issue, what happens if you try to run cordova run android --device in your project?

@kadia8161
Copy link
Author

@MSLaguana
it is a very basic HelloWorld kind project
in my config file have some cordova plugins included
which i commented i have attached config if you it can help you.
for

  1. Simulate Android on browser
    running first time after commenting cordova plugins i still get same error

Launching for android (This may take a while)...
Attaching to app
Failed to load resource: net::ERR_EMPTY_RESPONSE
( i can see chrome trying to load page)

but on second time run there is no effect in chrome and i get this message

Launching for android (This may take a while)...
An error occurred while attaching to the debugger. Can't reinitialize projectRoot
Can't reinitialize projectRoot

and for cordova run android from command prompt
i get following error

D:\Mobile Development\Android Project\HelloWorld\HelloWorld>cordova build android
ANDROID_HOME=D:\Mobile Development\android-sdk-windows
JAVA_HOME=C:\Program Files\Java\jdk1.7.0_79
org.gradle.api.UncheckedIOException: java.util.zip.ZipException: zip file is emp
ty
at org.gradle.api.internal.classpath.DefaultModuleRegistry.loadModulePro
perties(DefaultModuleRegistry.java:186)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.loadModule(De
faultModuleRegistry.java:88)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.getModule(Def
aultModuleRegistry.java:77)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.module(Defaul
tModuleRegistry.java:121)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.loadModule(De
faultModuleRegistry.java:89)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.getModule(Def
aultModuleRegistry.java:77)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.module(Defaul
tModuleRegistry.java:121)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.loadModule(De
faultModuleRegistry.java:89)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.getModule(Def
aultModuleRegistry.java:77)
at org.gradle.api.internal.DefaultClassPathProvider.findClassPath(Defaul
tClassPathProvider.java:33)
at org.gradle.api.internal.DefaultClassPathRegistry.getClassPath(Default
ClassPathRegistry.java:34)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBoots
trap.java:48)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.j
ava:36)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.
java:57)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAcces
sorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:606)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.ja
va:33)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:130)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:48)
Caused by: java.util.zip.ZipException: zip file is empty
at java.util.zip.ZipFile.open(Native Method)
at java.util.zip.ZipFile.(ZipFile.java:215)
at java.util.zip.ZipFile.(ZipFile.java:145)
at java.util.zip.ZipFile.(ZipFile.java:159)
at org.gradle.api.internal.classpath.DefaultModuleRegistry.loadModulePro
perties(DefaultModuleRegistry.java:174)
... 20 more

i have installed gradle and other required files
i am not sure what problem is because i can run same project from phoneGap windows client in virtual android device using phoneGap Developer App

i have one more doubt regarding cordova
while building app from command prompt using
cordova build android command it downloaded many files related gradle and others i think it downloaded to temp location so if i clear temp files do i need to download again all files or can i choose download location for reuse ?

config.txt

@MSLaguana
Copy link
Member

Regarding your issue with building android, according to http://stackoverflow.com/questions/30692085/cannot-build-project-using-cordova it may be due to a corrupt gradle download.

For your first issue, I believe it may possibly be caused by having the inappbrowser plugin installed twice. You have both cordova-plugin-inappbrowser and org.apache.cordova.inappbrowser referenced in your config.xml, and there is an issue in the version of cordova-simulate we use that I think you are hitting.

Your project should only use one version of the plugin, so I suggest removing the outdated org.apache.cordova.inappbrowser instance, make sure it is uninstalled from the project, and then see if that works for you.

@MSLaguana MSLaguana reopened this Sep 13, 2016
@kadia8161
Copy link
Author

@MSLaguana
as per your suggestion i have looked and i found there were actually two reference for crodova one was from gap (added by phonegap) and other was added when i tried to build using Cordova build android.
i took a fresh project using cordova add and it is able to run on browser using "simulate Android on browser"

But i have one more doubt when i use cordvoa build android or try to Run android on device it give me error (probably because of corrupted gradle files)
but same project runs perfectly on Simulate Android on browser.
any reason for that ? does it not use any gradle reference during browser run ?

and yes i have downloaded separately gradle all zip file from its site how can i use it with vscode so vs code will reference it instead of previous one ?

@MSLaguana
Copy link
Member

When you simulate your project in the browser, it does not use any of the native implementation, just the html, css, and javascript in your project. We provide a fake "native" implementation of plugins so you can test things out, but we don't actually build the native project.

Did you try the suggested fix in the stack overflow question? Deleting / replacing the gradle zip in your user directory?

@kadia8161
Copy link
Author

kadia8161 commented Sep 18, 2016

in my project it uses gradle-2.13 while i have downloaded higher version of gradle Version 3.0 (while downloading i thought it would be better to use latest version) so right now i am looking for way to change version of gradle it use during build and how can i set to use gradle from different path (set manually) rather than using from C:\Users

If you have any idea or you can provide some reference link regarding this it will helpful.

I think there should be option to set path ,version and other details for other libraries we used during cordova build so we can specify manually also.

I will update as soon as i sort out this gradle error.

@MSLaguana
Copy link
Member

I haven't done this myself, but it looks like http://stackoverflow.com/questions/30413485/install-gradle-for-using-in-cordova-build-android has instructions for using a specific version of gradle.

We don't explicitly reference/require gradle anywhere in our extension, so I'm inclined to leave things with cordova configuration like the above. If you strongly disagree, we can discuss possible changes.

@vladimir-kotikov
Copy link

This looks pretty old. @kadia8161, I'm going to close this but feel free to reopen if you're still experiencing any problems w/ debugging

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants