2016-10-18 7 views
5

私はアンドロイドスタジオにアプリケーションコードを持っています。これをライブラリプロジェクトに変換して、他のアプリケーションのライブラリとして使うことができます。
エラー:私はアンドロイドスタジオ2.2.1およびJDK 1.8を使用していますandroid library projectのjackOptionsの使い方

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' 

} 


JDK 1.8がjackOptions

それは言うを必要とし、次のようにライブラリプロジェクトの
build.gradleがある図書館プロジェクトはジャックを有効にすることはできません。 Jackはデフォルト設定で有効になっています。 もし私がjackOptionsを無効にすると、私のライブラリはjdk 1.8のために動作していません。それはjackOptionsが必要で、次のエラーが出るということです。 Olivier M.

app:generateDebugSources 
app:mockableAndroidJar 
app:prepareDebugUnitTestDependencies 
app:generateDebugAndroidTestSources 
myapplication:generateDebugSources 
myapplication:generateDebugAndroidTestSources 
myapplication:mockableAndroidJar 
myapplication:prepareDebugUnitTestDependencies 

答えて

0

おかげで、あなたはここでの作業の回避策があります:Is there way to use Java 8 features with Android library project?

インポート一部です:

// Java8 not fully supported in library projects yet, https://code.google.com/p/android/issues/detail?id=211386 
// this is a temporary workaround to get at least lambdas compiling 
gradle.projectsEvaluated { 
    tasks.withType(JavaCompile) { 
     options.compilerArgs << "-Xbootclasspath/a:" + System.properties.get("java.home") + "/lib/rt.jar" 
    } 
} 
+0

モジュールまたはプロジェクト内。 ? – jenuine

1

は、設定のエントリを重複。あなたのbuild.gradleから次の行を削除してください:

jackOptions { 
     enabled true 
} 
関連する問題