Adding a Maven Project to an Android Studio App as a Dependency

前端 未结 1 1952
忘了有多久
忘了有多久 2021-01-18 21:55

I am currently developing an Android App using Android Studio 1.2 .
I want to use an external Java Project as a Dependency in my Android App. This Java Project is a Mave

1条回答
  •  野的像风
    2021-01-18 22:37

    I found the answer. You need to have Maven installed. Then you build the external project with maven. (you can use e.g. eclipse)

    After that, the whole project can be found in your 'local maven repository'. The location is /{USER}/.m2/repository on a Windows machine.

    Follow the structure to the project, you've just built.

    Convert this path to a name space path:

    /{USER}/.m2/repositoryorg/tuda/cdc/pp/classes/1.0
    

    is converted to

    org.tuda.cdc.pp:classes-plain:1.0
    

    Pay attention to the double points at the end.

    Now add the maevnLocal() thing to you project's grandle file:

    allprojects {
        repositories {
            jcenter()
            mavenLocal()
        } 
    }
    

    And then add the following to your app's grandle file under dependencies:

    compile 'org.tuda.cdc.pp:classes-plain:1.0'
    

    Then you need to rebuild / sync the project with the changes of the grandle file. After that you are good to go.

    0 讨论(0)
提交回复
热议问题