I am trying to create an Android application that uses the Android library I created. The structure of the project is as follows:
/mainProject
|- /myLibrary
|- build.gradle
|- (Java Sources and files)
|- /app
|- build.gradle
|- (Java Sources and files)
|- settings.gradle
|- build.gradle
The main project /settings.gradle contains:
include ':app', ':myLibrary'
The main project /build.gradle contains:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
}
}
allprojects {
repositories {
jcenter()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
The main project /myLibrary/build.gradle is as follows:
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:1.3.0'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
apply plugin: 'com.android.library'
android {
compileSdkVersion 21
buildToolsVersion "23.0.1"
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
debug{
buildConfigField "String", "LIBRARY_ENDPOINT", "\"https://dev-library.company.com/\""
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
buildConfigField "String", "LIBRARY_ENDPOINT", "\"https://library.company.com/\""
}
}
}
repositories {
jcenter()
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.+'
compile 'com.github.satyan:sugar:1.3'
testCompile 'junit:junit:4.12'
compile 'commons-io:commons-io:2.4'
androidTestCompile 'junit:junit:4.12'
}
The mainProject / app / build.gradle file contains:
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.company.app"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
debug {
applicationIdSuffix ".debug"
buildConfigField "String", "APP_ENDPOINT", "\"https://dev-app.company.com/\""
}
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
buildConfigField "String", "APP_ENDPOINT", "\"https://app.company.com/\""
}
}
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:21.+'
compile 'com.google.android.gms:play-services-location:8.1.0'
compile 'commons-io:commons-io:2.4'
compile 'com.joanzapata.pdfview:android-pdfview:1.0.4@aar'
compile 'com.github.clans:fab:1.6.1'
compile 'joda-time:joda-time:2.8.2'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.squareup.picasso:picasso:2.5.2'
compile project(':myLibrary')
}
I initially received errors in the IDE, but adding the final line of the compilation project cleared them, so the IDE does not detect errors at all. However, when I run the gradle construct, I see:
:app:compileDebugJavaWithJavac
/AndroidStudioProjects/mainProject/app/src/main/java/com/company/app/MainActivity.java:17: error: cannot find symbol
import com.company.mylibrary.LibraryClass;
^
symbol: class LibraryClass
location: package com.company.mylibrary
/AndroidStudioProjects/mainProject/app/src/main/java/com/company/app/MainActivity.java:29: error: cannot find symbol
LibraryClass.setup("562e7d58628ee16894db98df", getApplicationContext());
^
symbol: variable LibraryClass
location: class MainActivity
2 errors
FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:compileDebugJavaWithJavac'.
> Compilation failed; see the compiler error output for details.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 8.143 secs
, IDE , , gradle, myLibrary . , , , .
- , ?