我有以下库项目结构,其中 sdk
是我汇编成aar
文件以进行分发的项目
└─ ProjectRoot
├─ sdk
│ ├─ build.gradle
│ ├─ libs/
│ └─ src/
│
├─ submoduleRoot
│ ├─ settings.gradle
│ └─ projectA
│ ├─ src/
│ └─ build.gradle
│
├─ settings.gradle
└─ build.gradle
当我汇编*.aar
文件并在Android应用程序项目中引用它时,我看到以下运行时异常。
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/company/engine/MyClass
App正在抱怨的MyClass
在ProjectRoot/submoduleRoot/projectA/src/MyClass
ProjectRoot / settings.gradle
include ':sdk'
include ':projectA'
project(':projectA').projectDir = new File('submoduleRoot/projectA')
ProjectRoot / SDK /的build.gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.3.1'
}
}
apply plugin: 'maven'
apply plugin: 'com.android.library'
repositories {
mavenCentral()
}
android {
compileSdkVersion 22
buildToolsVersion '25.0.2'
defaultConfig {
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
debuggable false
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
develop {
debuggable true
minifyEnabled false
}
}
sourceSets {
sourceSets.androidTest.java.srcDirs = ["src/test/java"]
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':manticore')
...
}
如果有什么我应该做的不同,请你告诉我吗?