tanelih / phonegap-bluetooth-plugin

Bluetooth plugin for PhoneGap version 2.6.0+
MIT License
57 stars 50 forks source link

Build failed with error 653 & 698 #10

Closed H1439 closed 10 years ago

H1439 commented 10 years ago

Hi,

I am trying to build the example as provided here - https://gist.github.com/tanelih/7193921

I am using Cordova 3.2.0 cli version with target sdk 18. I have also my environment variables set correctly for Android SDK, Java_Home, Ant_Home. But, on building it, I am getting the following error -

e:\BTApp\BluetoothApp>cordova build android Generating config.xml from defaults for platform "android" Preparing android project Compiling app on platform "android" via command "cmd" /c e:\BTApp\BluetoothApp\platforms\android\cordova\buil d [Error: An error occurred while building the android project.Error executing "ant debug -f e:\BTApp\Bluetooth App\platforms\android\build.xml": BUILD FAILED E:\android\sdk\tools\ant\build.xml:653: The following error occurred while executing this line: E:\android\sdk\tools\ant\build.xml:698: null returned: 1

Total time: 2 seconds

]

Here, are the steps, I have followed during the process -

e:\BTApp>cordova create BluetoothApp

e:\BTApp>cd BluetoothApp

e:\BTApp\BluetoothApp>cordova plugin add ../phonegap-bluetooth-tanelih

e:\BTApp\BluetoothApp>cordova platform add android

e:\BTApp\BluetoothApp>cordova build android

Please help me out. Thanks.

tanelih commented 10 years ago

Hey,

I was unable to replicate your issue with the steps you provided. I am using Ubuntu 12.04 with cordova, openjdk-6 and ant installed via apt-get. I've also performed the steps you provided on Windows with success, so this seems like it might be a problem with your installation of the tools required.

After googling a bit, I found this issue describing how having Java installed under Program Files on Windows may cause issues because of spaces in the directory name. Maybe this issue is related to your problem?

Hope this helps!

H1439 commented 10 years ago

Hi,

Thank you for the response.

I have found that the project is getting build successfully without the plugin. I also have checked that I can build other projects with different plugins successfully. So, I don't think the issue is with java or any other tools installed location. But, I did referred to the issue you have mentioned and installed java in C:\java with no luck.

If you have been able to build it successfully, can you point me to some demo project or source utlizing the same plugin that I can build to establish communication between two android devices. Thanks.

tanelih commented 10 years ago

Hi,

That's really strange. It seems quite odd that something in the plugin would actually break the build process. It's probably some weird fringe case with the config.xml file since I can't reproduce your results. Can you get any more logging information about the failure of the build? I think there is a logging option in ant.

Just for reference, I'm using cordova 3.4.0 and openjdk-6 on Ubuntu, and if I remember correctly Java version 6 and PhoneGap 3.0.0 on Windows.

I'll take a look at this once I get to a working Windows computer (the one I have at work seems to be strictly for emails and other systems).

EDIT Just as a reference, here are the exact steps I used to build the app on my work machine:

  1. Install ant, openjdk, cordova
sudo apt-get install ant 
sudo apt-get install openjdk-6-jdk
npm install -g cordova
  1. Set paths for Android SDK, JAVA_HOME and ANT_HOME at .bash_profile
export PATH=${PATH}:/home/taneli/Android/sdk/platform-tools:/home/taneli/Android/sdk/tools
export JAVA_HOME=/usr/lib/jvm/java-6-openjdk
export ANT_HOME=/usr/share/ant
source .bash_profile
  1. Create the project, add platform, add plugin and build it
cordova create BluetoothApp
cd BluetoothApp
cordova add platform android
cordova plugin add https://github.com/tanelih/phonegap-bluetooth-plugin
cordova build android
H1439 commented 10 years ago

Hi,

Thank you for the step wise reference. Below is the build log of my project. On another note, I can build the project successfully using eclipse, but not from the cordova CLI.

Looks like your environment fully supports cordova-android development! exec: ant clean -f E:\BTApp\BluetoothApp\platforms\android\build.xml [ 'ant clean -f E:\BTApp\BluetoothApp\platforms\android\build.xml', null, 'Buildfile: E:\BTApp\BluetoothApp\platforms\android\build.xml\r\n\r\n-check-env:\r\n [checkenv] Andro id SDK Tools Revision 22.3.0\r\n [checkenv] Installed at E:\android\sdk\r\n\r\n-setup:\r\n [echo] Project Name: Hel loCordova\r\n [gettype] Project Type: Application\r\n\r\n-pre-clean:\r\n\r\nclean:\r\n [delete] Deleting directory E: \BTApp\BluetoothApp\platforms\android\bin\r\n [delete] Deleting directory E:\BTApp\BluetoothApp\platforms\android\gen\r\n[getlibpath] Library dependencies:\r\n[getlibpath] No Libraries\r\n [subant] No s ub-builds to iterate on\r\n\r\nBUILD SUCCESSFUL\r\nTotal time: 2 seconds\r\n', '' ] exec: ant debug -f E:\BTApp\BluetoothApp\platforms\android\build.xml [ 'ant debug -f E:\BTApp\BluetoothApp\platforms\android\build.xml', { [Error: Command failed: BUILD FAILED E:\android\sdk\tools\ant\build.xml:653: The following error occurred while executing this line: E:\android\sdk\tools\ant\build.xml:698: null returned: 1

Total time: 2 seconds ] killed: false, code: 1, signal: null }, 'Buildfile: E:\BTApp\BluetoothApp\platforms\android\build.xml\r\n\r\n-set-mode-check:\r\n\r\n-set-deb ug-files:\r\n\r\n-check-env:\r\n [checkenv] Android SDK Tools Revision 22.3.0\r\n [checkenv] Installed at E:\android\sd k\r\n\r\n-setup:\r\n [echo] Project Name: HelloCordova\r\n [gettype] Project Type: Application\r\n\r\n-set-debug-mo de:\r\n\r\n-debug-obfuscation-check:\r\n\r\n-pre-build:\r\n\r\n-build-setup:\r\n[getbuildtools] Using latest Build Tools : 19.0.0\r\n [echo] Resolving Build Target for HelloCordova...\r\n[gettarget] Project Target: Android 4.2.2\r\n[ge ttarget] API level: 17\r\n [echo] ----------\r\n [echo] Creating output directories if needed...\r\n [ mkdir] Created dir: E:\BTApp\BluetoothApp\platforms\android\bin\r\n [mkdir] Created dir: E:\BTApp\BluetoothApp\platforms\android\bin\res\r\n [mkdir] Created dir: E:\BTApp\BluetoothApp\ platforms\android\bin\rsObj\r\n [mkdir] Created dir: E:\BTApp\BluetoothApp\platforms\android\bin\ \rsLibs\r\n [mkdir] Created dir: E:\BTApp\BluetoothApp\platforms\android\gen\r\n [mkdir] Created dir: E:\BTApp\BluetoothApp\platforms\android\bin\classes\r\n [mkdir] Created dir: E:\BTApp\BluetoothApp\platforms\android\bin\dexedLibs\r\n [echo] ----------\r\n [echo] Resolving Dependencies f or HelloCordova...\r\n[dependency] Library dependencies:\r\n[dependency] No Libraries\r\n[dependency] \r\n[dependency] - -----------------\r\n [echo] ----------\r\n [echo] Building Libraries with \'debug\'...\r\n [subant] No sub-bu ilds to iterate on\r\n\r\n-code-gen:\r\n[mergemanifest] Merging AndroidManifest files into one.\r\n[mergemanifest] Manif est merger disabled. Using project manifest only.\r\n [echo] Handling aidl files...\r\n [aidl] No AIDL files to compile.\r\n [echo] ----------\r\n [echo] Handling RenderScript files...\r\n [echo] ----------\r\n [echo ] Handling Resources...\r\n [aapt] Generating resource IDs...\r\n [aapt] E:\BTApp\BluetoothApp\pl atforms\android\res\xml\config.xml:21: error: Error parsing XML: unbound prefix\r\n', '\r\nBUILD FAILED\r\nE:\android\sdk\tools\ant\build.xml:653: The following error occurred while executing this lin e:\r\nE:\android\sdk\tools\ant\build.xml:698: null returned: 1\r\n\r\nTotal time: 2 seconds\r\n' ] Error executing "ant debug -f E:\BTApp\BluetoothApp\platforms\android\build.xml": BUILD FAILED E:\android\sdk\tools\ant\build.xml:653: The following error occurred while executing this line: E:\android\sdk\tools\ant\build.xml:698: null returned: 1

Total time: 2 seconds

Also, I guess there is nothing wrong in my config.xml. Below is how it reads like -

<?xml version='1.0' encoding='utf-8'?>

BleApp A Bluetooth Communication app. ``` Bluetooth Team. ```
tanelih commented 10 years ago

Hi,

I did a fresh install of cordova on a Windows 7 machine. I didn't encounter any issues with building the project with or without the plugin installed.

I installed the tools & created the project the same way as I explained above, expect on Windows obviously. Below you will find the project configuration file and the generated configuration file for the android platform from my project.

./platforms/android/res/xml/config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <preference name="loglevel" value="DEBUG" />
    <feature name="App">
        <param name="android-package" value="org.apache.cordova.App" />
    </feature>
    <feature name="Bluetooth">
        <param name="android-package" value="org.apache.cordova.bluetooth.BluetoothPlugin" />
    </feature>
    <name>HelloCordova</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <access origin="*" />
</widget>

./config.xml

<?xml version='1.0' encoding='utf-8'?>
<widget id="io.cordova.hellocordova" version="0.0.1" xmlns="http://www.w3.org/ns/widgets" xmlns:cdv="http://cordova.apache.org/ns/1.0">
    <name>HelloCordova</name>
    <description>
        A sample Apache Cordova application that responds to the deviceready event.
    </description>
    <author email="dev@cordova.apache.org" href="http://cordova.io">
        Apache Cordova Team
    </author>
    <content src="index.html" />
    <access origin="*" />
</widget>

Looks like your project config.xml differs a bit, maybe that is causing the issue?

H1439 commented 10 years ago

Hi @tanelih,

Finally the issue is resolved. Thanks a lot for your references.

Yes, you are right the issue was with my config.xml file as I have mistakenly added the line - gap:plugin name="com.phonegap.plugins.barcodescanner"/ - in it.

Now, the project builds successfully in cordova CLI :+1:

heatbot commented 10 years ago

Hi @tanelih Quick question, your example works to send free HEX commands through serial Bluetooth, or only strings?

tanelih commented 10 years ago

Hi,

The plugin receives a String from the wrapping JavaScript code, which is then turned into a ByteArray that is actually sent to the Bluetooth connection. You can specify the encoding as second argument to write. In your case, can you send your hex values as a string and then decode them in the other end?

Br, Taneli