我有一个在Android Studio中的应用程序代码,我想将其转换为库项目,以便我可以在其他应用程序中使用它作为库。
库项目的build.gradle如下所示:
apply plugin: 'com.android.library'
apply plugin: 'com.google.gms.google-services'
android {
compileSdkVersion 24
buildToolsVersion "24.0.3"
defaultConfig {
//applicationId "com.example"
minSdkVersion 16
targetSdkVersion 24
versionCode 1
versionName "1.0"
jackOptions {
enabled true
}
multiDexEnabled true
}
dexOptions {
javaMaxHeapSize "4g"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
testCompile 'junit:junit:4.12'
/* support libraries*/
compile 'com.android.support:appcompat-v7:23.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:recyclerview-v7:23.1.0'
compile 'com.android.support:support-v4:23.1.0'
compile 'com.android.support:support-annotations:23.1.0'
/* google play services libraries*/
compile 'com.google.android.gms:play-services-location:9.0.0'
}
我正在使用Android Studio 2.2.1和JDK 1.8,
JDK 1.8需要jackOptions。
错误消息如下:
错误:库项目不能启用Jack。 Jack在默认配置中已启用。 如果我禁用jackOptions,则我的库无法正常工作,因为由于JDK 1.8,它说jackOptions是必需的,并出现以下错误。
app:generateDebugSources
app:mockableAndroidJar
app:prepareDebugUnitTestDependencies
app:generateDebugAndroidTestSources
myapplication:generateDebugSources
myapplication:generateDebugAndroidTestSources
myapplication:mockableAndroidJar
myapplication:prepareDebugUnitTestDependencies