这是我的build.gradle(app)文件,当我尝试同步时,出现8个警告,当我尝试运行此应用程序时,几乎没有警告,并且出现错误,说有Duplicate file Exception
。
我正在尝试在我的Android应用程序中实现Google云数据存储
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.0.2"
defaultConfig {
applicationId "com.appspot.myapp"
minSdkVersion 15
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
configurations.all {
resolutionStrategy.force 'com.google.code.findbugs:jsr305:1.3.9'
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES.txt'
exclude 'META-INF/LICENSE.txt'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/notice.txt'
exclude 'META-INF/license.txt'
exclude 'META-INF/dependencies.txt'
exclude 'META-INF/LGPL2.1'
}
}
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'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
testCompile 'junit:junit:4.12'
compile group: 'com.google.cloud', name: 'google-cloud-datastore', version: '+'
}
点击立即同步后,我收到以下警告:
Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar, :app:prepareDebugUnitTestDependencies]
Warning:WARNING: Dependency org.json:json:20160810 is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.json:json:20160810 is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.json:json:20160810 is ignored for release as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for release as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.json:json:20160810 is ignored for release as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for release as it may be conflicting with the internal version provided by Android.
Information:BUILD SUCCESSFUL
Information:Total time: 1.791 secs
Information:0 errors
Information:8 warnings
Information:See complete output in console
这是我在尝试运行应用程序时看到的错误:
Information:Gradle tasks [:app:assembleDebug]
Warning:WARNING: Dependency org.json:json:20160810 is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.json:json:20160810 is ignored for debug as it may be conflicting with the internal version provided by Android.
Warning:WARNING: Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignored for debug as it may be conflicting with the internal version provided by Android.
Error:Execution failed for task ':app:transformResourcesWithMergeJavaResForDebug'.
> com.android.build.api.transform.TransformException: com.android.builder.packaging.DuplicateFileException: Duplicate files copied in APK com/google/cloud/project.properties
File1: C:\Users\mbhar\.gradle\caches\modules-2\files-2.1\com.google.cloud\google-cloud-core\1.0.0-rc2\aadb514fb6e48585c5fb1b2bbca1a84db38bdd6f\google-cloud-core-1.0.0-rc2.jar
File2: C:\Users\mbhar\.gradle\caches\modules-2\files-2.1\com.google.cloud\google-cloud-core-http\1.0.0-rc2\fe5de264bf8a3357d69f0643d31eca582cee119c\google-cloud-core-http-1.0.0-rc2.jar
Information:BUILD FAILED
Information:Total time: 1.487 secs
Information:1 error
Information:4 warnings
Information:See complete output in console
答案 0 :(得分:2)
排除那些重复项应该消除该错误
compile('com.google.cloud:google-cloud-datastore:1.0.0-rc2') {
exclude group: 'org.json'
exclude group: 'org.apache.httpcomponents'
}
但从Android 6开始,Android已弃用SDK中的Apache HTTP组件。
所以,我认为你应该setup Endpoints因为
Google Cloud Endpoints [提供]自动Java对象编组/解组到JSON,生成可以从Android应用程序调用的强类型客户端库,内置身份验证支持等。
我认为该链接部署了一个Java后端,但我已经将它与Python App Engine应用程序一起使用,只是不记得它是如何工作的。