我在最新的Android Studio上创建了一个全新的Android项目。我做的第一件事就是添加'Realm'通过将以下内容添加到gradle文件中来库到项目:
compile 'io.realm:realm-android:0.80.3'
如果我尝试编译,我会收到以下错误:
Note: C:\....\MainActivity.java uses or overrides a deprecated API.
原点2: C:\ Users \ Usmaan.gradle \ _caches \ modules-2 \ files-2.1 \ io.realm \ realm-android \ 0.80.3 \ 7979d05ba7b919c53766bf98e31aaf0e9feb0590 \ realm-android-0.80.3.jar错误:在打包APK期间重复文件 C:... \ app \ build \ outputs \ apk \ app-debug-unaligned.apk存档中的路径: META-INF / services / javax.annotation.processing.Processor原点1: C:\ Users \用户Usmaan.gradle \缓存\模块-2 \文件-2.1 \ com.jakewharton \ butterknife \ 6.1.0 \ 63735f48b82bcd24cdd33821342428252eb1ca5a \ butterknife-6.1.0.jar 你可以忽略build.gradle中的那些文件:android {
的执行失败
packagingOptions { 排除' META-INF / services / javax.annotation.processing.Processor' }错误:任务':app:packageDebug'。在APK META-INF / services / javax.annotation.processing.Processor文件1中复制的重复文件: C:\ Users \用户Usmaan.gradle \缓存\模块-2 \文件-2.1 \ com.jakewharton \ butterknife \ 6.1.0 \ 63735f48b82bcd24cdd33821342428252eb1ca5a \ butterknife-6.1.0.jar 文件2: C:\ Users \ Usmaan.gradle \ _caches \ modules-2 \ files-2.1 \ io.realm \ realm-android \ 0.80.3 \ 7979d05ba7b919c53766bf98e31aaf0e9feb0590 \ realm-android-0.80.3.jar}
有什么想法吗?
答案 0 :(得分:8)
看起来你也在使用Butterknife?您是否尝试将以下内容添加到build.gradle:
android {
...
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
答案 1 :(得分:4)
将此添加到build.gradle中的android
插件可能会解决这些问题:
packagingOptions {
// Exclude file to avoid
// Error: Duplicate files during packaging of APK
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/LICENSE'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/notice.txt'
exclude 'META-INF/ASL2.0'
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
答案 2 :(得分:0)
在build {gradle上添加这些在ButterKnife I / O页面中指定。
android{
....
packagingOptions {
exclude 'META-INF/services/javax.annotation.processing.Processor'
}
}
lintOptions {
disable 'InvalidPackage'
}
答案 3 :(得分:0)
我的问题是从这里来的:
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK, android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI);
photoPickerIntent.setType("image/*");
Lint
提醒我,设置type
将清除构造函数中的URI
,必须将其替换。我将其更改为:
Intent photoPickerIntent = new Intent(Intent.ACTION_PICK);
photoPickerIntent.setDataAndType(android.provider.MediaStore.Images.Media.EXTERNAL_CONTENT_URI, "image/*");
警告消失了。