【发布时间】:2016-07-24 04:20:29
【问题描述】:
我正在尝试构建一个由单独的库项目组成的应用程序。
我试图让项目尽可能简单。项目内容无所谓!
重要的是项目之间的依赖关系!
结果应该是MainProject会打印出Something Another String!
我已经尝试了从 .JAR 文件到 .AAR 文件的所有文件,但我得到的最好的是
红色的依赖关系。我将StringExtender.aar 文件添加到StringReturner,然后将StringReturner.aar 文件添加到MainProject。
当我这样做时,我得到以下异常:
java.lang.NoClassDefFoundError: 解析失败:Lcom/example/erik/stringextender/StringExtender;
设置这样一个简单的概念证明的正确方法是什么?我似乎找不到与具有依赖关系的库项目相关的任何内容。都是1级深!
欢迎任何帮助!
编辑显示 GRADLE 构建文件StringReturner:
apply plugin: 'com.android.library'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile project(':StringExtender-lib-debug')
}
主项目:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "com.example.erik.erikpoc10"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.2.1'
compile 'com.android.support:design:23.2.1'
compile project(':StringReturnerLib-debug')
}
【问题讨论】:
-
@MsYvetteǝʇʇǝʌʎsW 完成!
标签: android android-studio dependencies android-gradle-plugin