Search code examples
javaandroideclipsegitbalanced-payments

Android balanced-api import error


I've been having issues importing the balanced-api for Android into eclipse. I cloned the project from their git repo: https://github.com/balanced/balanced-android

However every time I attempt to import the project I receive the following error:

"Cannot nest 'balanced-android/src/main/java' inside 'balanced-android/src'. To enable the nesting exclude 'main/' from 'balanced-android/src'

I'm also not to sure what this error really means, so perhaps if someone could explain it that might prove helpful.

Screenshot: Balanced-api Android import error

I have tried on several occasions with no success. Of course I have also tried restarting eclipse, recloning the project but still with no success.

Thanks


Solution

  • Since ADT functions differently and Android development environments and project structures vary, I can provide you with some tips on how I've imported balanced-android into an application using ADT, however, your mileage may vary.

    • Go to Help -> Install New Software...
    • Select "Juno - http://download.eclipse.org/releases/juno" for the "Work with" field
    • Expand "General Purpose tools"
    • Select "m2e - Maven Integration for Eclipse"
    • Accept the license and install. Restart ADT.
    • File -> Import -> Maven -> Existing Maven Projects
    • Navigate to balanced-android/balanced-android (NOTE the nested directory. The balanced-android library project is named "balanced-android" and is contained in the parent balanced-android project folder)
    • Make sure pom.xml com.balancedpayments.android....jar is selected. Click Finish.
    • Right click on your project and select Properties
    • Go to Android -> Library -> Add. Select balanced-android. Click Ok.

    If you encounter dex errors, yo'll have to work with your dependencies to resolve the issue.

    My example project is also a maven project. If yours is not and you want to convert it to one, right click the project and select Maven -> Convert to maven project. You can then open pom.xml and add the following to satisfy dependencies:

    <dependencies>
        <dependency>
            <groupId>com.google.code.gson</groupId>
            <artifactId>gson</artifactId>
            <version>2.2.4</version>
            <scope>compile</scope>
        </dependency>
        <dependency>
            <groupId>org.apache.httpcomponents</groupId>
            <artifactId>httpclient</artifactId>
            <version>4.2.1</version>
            <scope>compile</scope>
        </dependency>
    </dependencies>
    

    If your project uses maven, you'll probably want your Java Build Path -> Default output folder to be /bin/classes. I ran into Android errors when this was set to /target/...

    Ref: https://docs.balancedpayments.com/1.1/guides/mobile/#balanced-android