Unknown error merging manifestもっとわかりやすいメッセージを表示してほしいよね。
2013年1月3日木曜日
Androidで「Unknown error merging manifest」
AndroidでライブラリプロジェクトのAndroidManifest.xmlをメインプロジェクトに自動でマージさせるにはproject.propertiesにmanifestmerger.enabled=trueを加えるだけで良い。
しかし、メインプロジェクトのandroid:targetSdkVersionがライブラリプロジェクトより低いと以下のようなエラーメッセージが表示される。
2013年1月2日水曜日
GradleでSlim3 + JPPのビルドスクリプトを書いてみた
Android(アプリ)も新しいビルドシステムとしてGradleを採用したこともあって、流行りに流行りまくっているGradleを試してみた。とりあえず会社でよく使うSlim3 + JsonPullParserのビルドスクリプトを書いてみた。
実はこれ、javacのバグによってエラーメッセージが誤って報告されるので気持ち悪い。
もっと良い方法があったら誰か教えて(´・ω・`)
参考資料)
Gradleでaptを処理する場合はAntタスクを使うらしい。そんでもってSlim3はJava1.5のaptでJPPはJava1.6のaptを使う必要があるらしいので、これまためんどい。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
apply plugin: "java" | |
sourceCompatibility = 1.6 | |
targetCompatibility = 1.6 | |
buildDir = "target" | |
def slim3Version = "1.0.+" | |
def appengineVersion = "1.7.+" | |
def jppVersion = "1.5.+" | |
repositories { | |
mavenCentral() | |
maven { | |
url "https://www.seasar.org/maven/maven2" | |
} | |
} | |
configurations { | |
providedCompile // <scope>provided</scope> | |
aptCompile5 // 1.5 | |
aptCompile6 // 1.6 | |
} | |
sourceSets { | |
apt_generated | |
main.compileClasspath += configurations.providedCompile | |
test.compileClasspath += configurations.providedCompile | |
test.runtimeClasspath += configurations.providedCompile | |
} | |
dependencies { | |
compile("org.slim3:slim3:${slim3Version}") { | |
exclude group: "com.google.appengine", module: "appengine-api-1.0-sdk" | |
exclude group: "com.google.appengine", module: "appengine-api-labs" | |
} | |
compile "com.google.appengine:appengine-api-1.0-sdk:${appengineVersion}" | |
compile "com.google.appengine:appengine-api-labs:${appengineVersion}" | |
compile "net.vvakame:jsonpullparser-core:${jppVersion}" | |
providedCompile "javax.servlet:servlet-api:2.5" | |
aptCompile5("org.slim3:slim3-gen:${slim3Version}") { | |
exclude group: "org.apache.ant", module: "ant" | |
} | |
aptCompile6 "net.vvakame:jsonpullparser-apt:${jppVersion}" | |
testCompile "junit:junit:4.7" | |
testCompile "com.google.appengine:appengine-api-stubs:${appengineVersion}" | |
testCompile "com.google.appengine:appengine-testing:${appengineVersion}" | |
} | |
task clean(overwrite: true) { | |
ant.delete(dir: buildDir) | |
} | |
task compileAptJava(overwrite: true, dependsOn: clean) { | |
// 生成コードを出力するディレクトリを予め作成 | |
// sourceSets.apt_generated.output.resourcesDir.mkdir() // なぜか出来ない | |
ant.mkdir(dir: sourceSets.apt_generated.output.resourcesDir) | |
// apt 1.5 | |
ant.path(id: "aptFactoryPath", location: configurations.aptCompile5.asPath) | |
ant.apt( | |
compile: false, | |
includeAntRuntime: false, | |
srcdir: "src/main/java", | |
factorypathref: "aptFactoryPath", | |
classpath: configurations.compile.asPath, | |
preprocessdir: sourceSets.apt_generated.output.resourcesDir, | |
encoding: "UTF-8" | |
) { | |
sourceSets.main.java.srcDirs.each { | |
src(path: it) | |
} | |
} | |
// apt 1.6 | |
ant.javac( | |
includeAntRuntime: false, | |
classpath: configurations.compile.asPath, | |
srcdir: "src/main/java", | |
encoding: "UTF-8" | |
) { | |
compilerarg(line: "-proc:only") | |
compilerarg(line: "-processorpath ${configurations.aptCompile6.asPath}") | |
compilerarg(line: "-s ${sourceSets.apt_generated.output.resourcesDir}") | |
} | |
// 自動生成コードが入ったディレクトリをソースディレクトリとして追加する | |
sourceSets.main.java.srcDirs += sourceSets.apt_generated.output.resourcesDir | |
} | |
// compileJavaタスクの前にcompileAptJavaタスクを実行させる | |
compileJava.dependsOn compileAptJava |
もっと良い方法があったら誰か教えて(´・ω・`)
参考資料)
登録:
投稿 (Atom)