I've created an external library that I was hoping to make open source. I import it as a module without issue.
I have to resolve this issue after import:

Adding the dependency is what I want to do. I don't want to move it to :app.
When I add the dependency, the issue goes away. The import references the correct file. On build I get this issue:

I figure the solution has to be with referencing the java file in the build.gradle file for the external library but I couldnt find any good examples or even proof that this would resolve the issue.
library is the module name.
Thanks in advance.
Edit: build.gradle for the app
apply plugin: 'com.android.application'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc3"
defaultConfig {
applicationId "com.weaverprojects.toundertest1"
minSdkVersion 21
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.google.android.gms:play-services-gcm:7.5.0'
}
build.gradle for library
apply plugin: 'com.android.library'
android {
compileSdkVersion 22
buildToolsVersion "23.0.0 rc3"
defaultConfig {
minSdkVersion 19
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
//compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.1'
compile 'com.google.android.gms:play-services-gcm:7.5.0'
}
Settings.gradle
include ':app', ':library'
Assuming that your library exists as it's own project, and it'd path relative to the top level folder for your main project is ../mylibs/library/ I think your settings.gradle should change as follows:
project(':library').projectDir = new File('../mylibs/library/');
and the following needs to go inside the dependencies section of your main/app/build.gradle file (which I think is the first code dump in your question).
compile project(':library')
BTW, please consider renaming :library to something else (this is not the source of the problem but the name can be confusing when you look at it some months later)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With