[解決済み】Android Gradleプラグイン0.7.0:"APKのパッケージング中にファイルが重複してしまう"
2022-03-26 07:25:56
質問
Android Gradleプラグイン0.7.0を使用し、以下を実行します。
build.gradle
:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.7.0'
}
}
apply plugin: 'android'
repositories {
maven { url "https://android-rome-feed-reader.googlecode.com/svn/maven2/releases" }
maven { url "http://dl.bintray.com/populov/maven" }
mavenCentral()
}
android {
compileSdkVersion 19
buildToolsVersion '18.1.1'
defaultConfig {
minSdkVersion 9
targetSdkVersion 19
}
buildTypes {
release {
runProguard true
proguardFile getDefaultProguardFile('proguard-android-optimize.txt')
}
}
productFlavors {
defaultFlavor {
proguardFile 'proguard-rules.txt'
}
}
sourceSets {
instrumentTest.setRoot('src/instrumentTest')
}
}
configurations {
apt
}
ext.androidAnnotationsVersion = '2.7.1';
dependencies {
compile 'com.android.support:support-v4:18.0.0'
compile 'com.viewpagerindicator:library:2.4.1@aar'
compile 'com.google.code.android-rome-feed-reader:android-rome-feed-reader:1.0.0-r2'
compile 'org.jdom:jdom:1.1.1-android-fork'
apt "com.googlecode.androidannotations:androidannotations:${androidAnnotationsVersion}"
compile "com.googlecode.androidannotations:androidannotations-api:${androidAnnotationsVersion}"
compile 'com.google.code.gson:gson:2.2.4'
compile 'com.j256.ormlite:ormlite-android:4.47'
compile 'com.j256.ormlite:ormlite-core:4.47'
compile 'org.springframework.android:spring-android-core:1.0.1.RELEASE'
compile 'org.springframework.android:spring-android-rest-template:1.0.1.RELEASE'
compile 'com.prolificinteractive:actionbarsherlock:4.3.1@aar'
compile 'com.google.code.geocoder-java:geocoder-java:0.15'
compile files('libs/CWAC-Pager.jar')
}
android.applicationVariants.all { variant ->
aptOutput = file("${project.buildDir}/source/apt_generated/${variant.dirName}")
println "****************************"
println "variant: ${variant.name}"
println "manifest: ${variant.processResources.manifestFile}"
println "aptOutput: ${aptOutput}"
println "****************************"
variant.javaCompile.doFirst {
println "*** compile doFirst ${variant.name}"
aptOutput.mkdirs()
variant.javaCompile.options.compilerArgs += [
'-processorpath', configurations.apt.getAsPath(),
'-AandroidManifestFile=' + variant.processResources.manifestFile,
'-s', aptOutput
]
}
}
エラーが発生する
Duplicate files copied in APK META-INF/LICENSE.txt
:
WARNING: Dependency commons-logging:commons-logging:1.0.4 is ignored for defaultFlavorDebug as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
WARNING: Dependency commons-logging:commons-logging:1.0.4 is ignored for defaultFlavorRelease as it may be conflicting with the internal version provided by Android.
In case of problem, please repackage it with jarjar to change the class packages
Creating properties on demand (a.k.a. dynamic properties) has been deprecated and is scheduled to be removed in Gradle 2.0. Please read http://gradle.org/docs/current/dsl/org.gradle.api.plugins.ExtraPropertiesExtension.html for information on the replacement for dynamic properties.
Deprecated dynamic property: "aptOutput" on "com.android.build.gradle.internal.api.ApplicationVariantImpl_Decorated@5705013c", value: "/Users/david/Developer...".
****************************
variant: defaultFlavorDebug
manifest: /Users/david/Developer/.../build/manifests/defaultFlavor/debug/AndroidManifest.xml
aptOutput: /Users/david/Developer/.../build/source/apt_generated/defaultFlavor/debug
****************************
Deprecated dynamic property "aptOutput" created in multiple locations.
****************************
variant: defaultFlavorRelease
manifest: /Users/david/Developer/.../build/manifests/defaultFlavor/release/AndroidManifest.xml
aptOutput: /Users/david/Developer/.../build/source/apt_generated/defaultFlavor/release
****************************
:TravelGuard:compileDefaultFlavorDebugNdk UP-TO-DATE
:TravelGuard:preBuild UP-TO-DATE
:TravelGuard:preDefaultFlavorDebugBuild UP-TO-DATE
:TravelGuard:preDefaultFlavorReleaseBuild UP-TO-DATE
:TravelGuard:prepareComProlificinteractiveActionbarsherlock431Library UP-TO-DATE
:TravelGuard:prepareComViewpagerindicatorLibrary241Library UP-TO-DATE
:TravelGuard:prepareDefaultFlavorDebugDependencies
:TravelGuard:compileDefaultFlavorDebugAidl UP-TO-DATE
:TravelGuard:compileDefaultFlavorDebugRenderscript UP-TO-DATE
:TravelGuard:generateDefaultFlavorDebugBuildConfig UP-TO-DATE
:TravelGuard:mergeDefaultFlavorDebugAssets UP-TO-DATE
:TravelGuard:mergeDefaultFlavorDebugResources UP-TO-DATE
:TravelGuard:processDefaultFlavorDebugManifest UP-TO-DATE
:TravelGuard:processDefaultFlavorDebugResources UP-TO-DATE
:TravelGuard:generateDefaultFlavorDebugSources UP-TO-DATE
:TravelGuard:compileDefaultFlavorDebugJava
*** compile doFirst defaultFlavorDebug
/Users/david/Developer/.../src/main/java/com/travelguard/service/TravelGuardService.java:53: cannot find symbol
symbol : class TravelGuardPrefs_
location: class com.travelguard.service.TravelGuardService
TravelGuardPrefs_ travelGuardPrefs;
^
/Users/david/Developer/.../src/main/java/com/travelguard/ui/CategoriesActivity.java:14: cannot find symbol
symbol : class AssistanceFragment_
location: package com.travelguard.ui.fragments
import com.travelguard.ui.fragments.AssistanceFragment_;
^
/Users/david/Developer/.../src/main/java/com/travelguard/ui/CategoriesActivity.java:16: cannot find symbol
symbol : class CategoryFragment_
location: package com.travelguard.ui.fragments
import com.travelguard.ui.fragments.CategoryFragment_;
^
/Users/david/Developer/.../src/main/java/com/travelguard/ui/CategoriesActivity.java:17: cannot find symbol
symbol : class ContactFragment_
location: package com.travelguard.ui.fragments
import com.travelguard.ui.fragments.ContactFragment_;
^
/Users/david/Developer/.../src/main/java/com/travelguard/ui/CountriesActivity.java:25: cannot find symbol
symbol : class TravelGuardPrefs_
location: package com.travelguard.service
import com.travelguard.service.TravelGuardPrefs_;
^
/Users/david/Developer/.../src/main/java/com/travelguard/ui/CountriesActivity.java:44: cannot find symbol
symbol : class TravelGuardPrefs_
location: class com.travelguard.ui.CountriesActivity
TravelGuardPrefs_ travelGuardPrefs;
^
/Users/david/Developer/.../src/main/java/com/travelguard/ui/InstructionsActivity.java:18: cannot find symbol
symbol : class AssistanceFragment_
location: package com.travelguard.ui.fragments
import com.travelguard.ui.fragments.AssistanceFragment_;
^
/Users/david/Developer/.../src/main/java/com/travelguard/ui/InstructionsActivity.java:19: cannot find symbol
symbol : class ContactFragment_
location: package com.travelguard.ui.fragments
import com.travelguard.ui.fragments.ContactFragment_;
^
/Users/david/Developer/.../src/main/java/com/travelguard/ui/InstructionsActivity.java:21: cannot find symbol
symbol : class InstructionsFragment_
location: package com.travelguard.ui.fragments
import com.travelguard.ui.fragments.InstructionsFragment_;
^
/Users/david/Developer/.../src/main/java/com/travelguard/ui/MainActivity.java:36: cannot find symbol
symbol : class TravelGuardPrefs_
location: package com.travelguard.service
import com.travelguard.service.TravelGuardPrefs_;
^
/Users/david/Developer/.../src/main/java/com/travelguard/ui/MainActivity.java:40: cannot find symbol
symbol : class AssistanceFragment_
location: package com.travelguard.ui.fragments
import com.travelguard.ui.fragments.AssistanceFragment_;
^
/Users/david/Developer/.../src/main/java/com/travelguard/ui/MainActivity.java:41: cannot find symbol
symbol : class ContactFragment_
location: package com.travelguard.ui.fragments
import com.travelguard.ui.fragments.ContactFragment_;
^
/Users/david/Developer/.../src/main/java/com/travelguard/ui/MainActivity.java:55: cannot find symbol
symbol : class TravelGuardPrefs_
location: class com.travelguard.ui.MainActivity
TravelGuardPrefs_ travelGuardPrefs;
^
/Users/david/Developer/.../src/main/java/com/travelguard/ui/TermsActivity.java:17: cannot find symbol
symbol : class TravelGuardPrefs_
location: package com.travelguard.service
import com.travelguard.service.TravelGuardPrefs_;
^
/Users/david/Developer/.../src/main/java/com/travelguard/ui/TermsActivity.java:23: cannot find symbol
symbol : class TravelGuardPrefs_
location: class com.travelguard.ui.TermsActivity
TravelGuardPrefs_ travelGuardPrefs;
^
Note: Starting AndroidAnnotations annotation processing
Note: AndroidManifest.xml file found: /Users/david/Developer/.../build/manifests/defaultFlavor/debug/AndroidManifest.xml
Note: Number of files generated by AndroidAnnotations: 22
Note: Generating source file: com.travelguard.service.SmartTravellerService_
Note: Generating source file: com.travelguard.service.SmartTravellerWebservice_
Note: Generating source file: com.travelguard.service.TravelGuardPrefs_
Note: Generating source file: com.travelguard.service.TravelGuardService_
Note: Generating source file: com.travelguard.service.TravelGuardWebservice_
Note: Generating source file: com.travelguard.ui.AdviceActivity_
Note: Generating source file: com.travelguard.ui.CategoriesActivity_
Note: Generating source file: com.travelguard.ui.ContactDetailActivity_
Note: Generating source file: com.travelguard.ui.ContactListActivity_
Note: Generating source file: com.travelguard.ui.ContactTravelGuardActivity_
Note: Generating source file: com.travelguard.ui.CountriesActivity_
Note: Generating source file: com.travelguard.ui.InformationActivity_
Note: Generating source file: com.travelguard.ui.InstructionsActivity_
Note: Generating source file: com.travelguard.ui.MainActivity_
Note: Generating source file: com.travelguard.ui.TermsActivity_
Note: Generating source file: com.travelguard.ui.TravelGuardActivity_
Note: Generating source file: com.travelguard.ui.fragments.AdviceDetailFragment_
Note: Generating source file: com.travelguard.ui.fragments.AdviceFragment_
Note: Generating source file: com.travelguard.ui.fragments.AssistanceFragment_
Note: Generating source file: com.travelguard.ui.fragments.CategoryFragment_
Note: Generating source file: com.travelguard.ui.fragments.ContactFragment_
Note: Generating source file: com.travelguard.ui.fragments.InstructionsFragment_
Note: Time measurements: [Whole Processing = 913 ms], [Generate Sources = 358 ms], [Extract Manifest = 163 ms], [Process Annotations = 158 ms], [Extract Annotations = 120 ms], [Validate Annotations = 82 ms], [Find R Classes = 28 ms],
Note: Time measurements: [Whole Processing = 0 ms],
Note: Time measurements: [Whole Processing = 0 ms],
warning: The following options were not recognized by any processor: '[androidManifestFile]'
Note: /Users/david/Developer/.../src/main/java/com/travelguard/ui/ContactDetailActivity.java uses or overrides a deprecated API.
Note: Recompile with -Xlint:deprecation for details.
Note: /Users/david/Developer/.../src/main/java/com/travelguard/service/SmartTravellerService.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
:TravelGuard:preDexDefaultFlavorDebug UP-TO-DATE
:TravelGuard:dexDefaultFlavorDebug
:TravelGuard:processDefaultFlavorDebugJavaRes UP-TO-DATE
:TravelGuard:validateDebugSigning
:TravelGuard:packageDefaultFlavorDebug
Error: duplicate files during packaging of APK /Users/david/Developer/.../build/apk/TravelGuard-defaultFlavor-debug-unaligned.apk
Path in archive: META-INF/LICENSE.txt
Origin 1: /Users/david/.gradle/caches/modules-2/files-2.1/commons-httpclient/commons-httpclient/3.1/964cd74171f427720480efdec40a7c7f6e58426a/commons-httpclient-3.1.jar
Origin 2: /Users/david/.gradle/caches/modules-2/files-2.1/commons-codec/commons-codec/1.2/397f4731a9f9b6eb1907e224911c77ea3aa27a8b/commons-codec-1.2.jar
:TravelGuard:packageDefaultFlavorDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':TravelGuard:packageDefaultFlavorDebug'.
> Duplicate files copied in APK META-INF/LICENSE.txt
File 1: /Users/david/.gradle/caches/modules-2/files-2.1/commons-httpclient/commons-httpclient/3.1/964cd74171f427720480efdec40a7c7f6e58426a/commons-httpclient-3.1.jar
File 2: /Users/david/.gradle/caches/modules-2/files-2.1/commons-httpclient/commons-httpclient/3.1/964cd74171f427720480efdec40a7c7f6e58426a/commons-httpclient-3.1.jar
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.
BUILD FAILED
Total time: 21.957 secs
今朝、Android Studioをアップデートする前は、正常に動作していました。何か思い当たることはありますか?
EDIT: 以下のようなコマンドを実行することで、一時的に修正することができました。
zip -d spring-android-core-1.0.1.RELEASE.jar META-INF/notice.txt
重複したエラーがすべてなくなるまで。
解決方法は?
Android Studioバージョン0.8.14現在
追加する必要があります。
android {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude '...'
}
}
をあなたの
build.gradle
ファイルを作成します。
履歴を見る
このバグのコメント14によると https://issuetracker.google.com/issues/36982149#comment14 これは Android Gradle プラグインの v0.7.0 のバグであり、0.7.1 でまもなく修正される予定です。
そのバグの中から、0.7.1向けの追加についてのメモです。
これを修正した0.7.1がリリースされています。
ファイルを除外するDSLは
android {
packagingOptions {
exclude 'META-INF/LICENSE.txt'
}
}
exclude文はいくつでも追加可能です。値はアーカイブのパスです。ワイルドカードやグロブはまだサポートしていません。
ファイル名 "LICENSE.txt" と "NOTICE.txt" は大文字と小文字が区別されます。試しに "license.txt" と "notice.txt" を使ってみてください。
関連
-
[解決済み】まだ警告が出る:設定 'compile' は時代遅れで 'implementation' に置き換わった。
-
[解決済み】コンテンツには、id属性が「android.R.id.list」であるListViewが必要です。
-
[解決済み】シンボル 'AppCompatActivity' を解決できない。
-
[解決済み] 設定 ':classpath' の依存関係をすべて解決できなかった。
-
[解決済み] Xlint:deprecationを使用して再コンパイルする方法
-
[解決済み] Android StudioのGradleとは?
-
[解決済み] エラーメッセージ "Android Gradle plugin requires Java 11 to run. 現在、Java 1.8を使用しています"
-
[解決済み] Gradle for Androidを使用して、外部のaarパッケージを手動でインクルードする方法
-
[解決済み】Gradleを使用してリリース署名付きapkファイルを作成する方法は?
-
[解決済み] エラー :: APKのパッケージング時にファイルが重複しています。
最新
-
nginxです。[emerg] 0.0.0.0:80 への bind() に失敗しました (98: アドレスは既に使用中です)
-
htmlページでギリシャ文字を使うには
-
ピュアhtml+cssでの要素読み込み効果
-
純粋なhtml + cssで五輪を実現するサンプルコード
-
ナビゲーションバー・ドロップダウンメニューのHTML+CSSサンプルコード
-
タイピング効果を実現するピュアhtml+css
-
htmlの選択ボックスのプレースホルダー作成に関する質問
-
html css3 伸縮しない 画像表示効果
-
トップナビゲーションバーメニュー作成用HTML+CSS
-
html+css 実装 サイバーパンク風ボタン
おすすめ
-
[解決済み】Android TextView : "setTextで表示されたテキストを連結しない" について
-
[解決済み】Android Studioでパラメータ化されたユニットテストを実行すると、指定されたインクルードに対するテストが見つからないエラーが発生する
-
[解決済み] シンボル 'context' を解決できない
-
[解決済み】シンボル 'AppCompatActivity' を解決できない。
-
[解決済み】新しいAVDを作成すると、CPU/ABIフィールドに「システムイメージがインストールされていません」と表示される。
-
[解決済み】getCheckedRadioButtonId()が無駄なintを返す?
-
[解決済み] Looper.prepare()を呼び出していないスレッドではハンドラを作成できない
-
[解決済み] Gradle DSL メソッドが見つかりません:'compile()'
-
[解決済み] Android Fragment onAttach() 非推奨
-
[解決済み] エラー :: APKのパッケージング時にファイルが重複しています。