I have a library module (AndEngine) inside my libs/AndEngine folder. The code from that compiles fine.
In my root settings.gradle file I have this :
include ':app:libs:AndEngine'
include ':app'
And then in my app's build.gradle file I have this in dependencies:
compile project('libs:AndEngine')
INside my app's code, all of the imports and even autocompletion works without any errors at all. Inside Android Studio, all of the packages are found. But when I go to compile, I get about a hundred of these errors:
error: package org.andengine.entity.primitive does not exist
import org.andengine.entity.primitive.Rectangle;
I am coming from the ADK with eclipse, so I am new to android studio. If anyone has any answers to this problem I would be very appreciative!
Change this line.
compile project('libs:AndEngine')
in
compile project(':app:libs:AndEngine')
In any case it is not a good idea to put a library module inside the app module. I suggest you using this structure:
root
settings.gradle
app
build.gradle
libs
AndEngine
build.gradle
Then in your settings.gradle
include ':libs:AndEngine'
include ':app'
And in your app/build.gradle
compile project(':libs:AndEngine')
来源:https://stackoverflow.com/questions/28796114/why-do-packages-from-library-module-does-not-exist-upon-compilation-even-when-a