How to import android project as library and NOT compile it as apk (Android studio 1.0)

Vic Zhou

I tried to import a project(projLib) as dependency for another project(projAPK).

projAPK gradle has this :

dependencies {
    compile project(':libs:NewsAPI')
    compile project(':projLib')
}

but when i sync the gradle it gives this error:

Error:Dependency Android_2015:projLib:unspecified on project projAPK resolves to an APK archive which is not supported as a compilation dependency. File: /Users/myname/Documents/Development/Android_2015/libs/projAPK/build/outputs/apk/projLib-release-unsigned.apk

so I guess there are two solution to this:

  1. somehow make gradle think that projLib is a library that shouldn't be compiled to apk
  2. somehow make gradle NOT compile the projLib explicitly

The problem is, I couldn't find how to do any of that. Would be awesome if you guys can help :)

Scott Barta

In projLib's build.gradle file, you'll see a statement like this:

apply plugin: 'com.android.application'

which tells Gradle to build it as an application, generating an APK. If you change it to this:

apply plugin: 'com.android.library'

it will build as a library, generating an AAR, and it should work.

If you also need projLib to generate a separate APK, then you'll have to do some refactoring to pull the common code that you need out into a third library module, and have both APKs depend on it.

Libraries aren't allowed to set an applicationId, so if you see an error message to that effect, remove it from the library's build script.

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Dev

How to add Google Play APK Expansion Library to android studio project?

From Dev

How to import eclipse library project from github to android studio project?

From Dev

How to import a library project in Android Studio, without making a copy?

From Dev

How to import the Kryonet library to a libGdx project on Android Studio

From Dev

How to import the Kryonet library to a libGdx project on Android Studio

From Dev

Import module or project as Library on Android Studio

From Dev

Import module or project as Library on Android Studio

From Dev

How to Import A Project Into Android Studio ?

From Dev

Can't import library project into Android Studio project

From Dev

Linphone Android how to import the library project?

From Dev

Linphone Android how to import the library project?

From Dev

How to import external library into android project?

From Dev

How can I import a new module (android library project) using Android studio 0.3.0

From Dev

How can I import a new module (android library project) using Android studio 0.3.0

From Dev

How to import colorPickerDialog library in android studio

From Dev

How to import external library in android studio?

From Dev

how to import library and modules to android studio properly

From Dev

how to import your library to android studio?

From Dev

How to import Stanford CoreNLP library to Android Studio

From Java

How to import set of icons into Android Studio project

From Dev

How to import a maven module to an Android Studio project

From Dev

How to import project in Android Studio via terminal?

From Dev

How to import existing java project into android studio?

From Dev

How to import project in Android Studio via terminal?

From Dev

How to import sample app to Android Studio Project

From Dev

How to import eclipse project into android studio?

From Dev

How to import github project to my android studio

From Dev

How to link a Library project in Android Studio

From Dev

How to use a library project in android studio

From Dev

How to add a project as a library in Android Studio?

Related Related

  1. 1

    How to add Google Play APK Expansion Library to android studio project?

  2. 2

    How to import eclipse library project from github to android studio project?

  3. 3

    How to import a library project in Android Studio, without making a copy?

  4. 4

    How to import the Kryonet library to a libGdx project on Android Studio

  5. 5

    How to import the Kryonet library to a libGdx project on Android Studio

  6. 6

    Import module or project as Library on Android Studio

  7. 7

    Import module or project as Library on Android Studio

  8. 8

    How to Import A Project Into Android Studio ?

  9. 9

    Can't import library project into Android Studio project

  10. 10

    Linphone Android how to import the library project?

  11. 11

    Linphone Android how to import the library project?

  12. 12

    How to import external library into android project?

  13. 13

    How can I import a new module (android library project) using Android studio 0.3.0

  14. 14

    How can I import a new module (android library project) using Android studio 0.3.0

  15. 15

    How to import colorPickerDialog library in android studio

  16. 16

    How to import external library in android studio?

  17. 17

    how to import library and modules to android studio properly

  18. 18

    how to import your library to android studio?

  19. 19

    How to import Stanford CoreNLP library to Android Studio

  20. 20

    How to import set of icons into Android Studio project

  21. 21

    How to import a maven module to an Android Studio project

  22. 22

    How to import project in Android Studio via terminal?

  23. 23

    How to import existing java project into android studio?

  24. 24

    How to import project in Android Studio via terminal?

  25. 25

    How to import sample app to Android Studio Project

  26. 26

    How to import eclipse project into android studio?

  27. 27

    How to import github project to my android studio

  28. 28

    How to link a Library project in Android Studio

  29. 29

    How to use a library project in android studio

  30. 30

    How to add a project as a library in Android Studio?

HotTag

Archive