Java 运行应用程序时渐变生成警告,无法运行应用程序
我对android非常陌生,无法理解此错误。同步gradle文件时,android studio将毫无错误地退出,但当我尝试构建并运行应用程序时,它会发出两个警告,如下所示:Java 运行应用程序时渐变生成警告,无法运行应用程序,java,android,android-gradle-plugin,apache-httpclient-4.x,build.gradle,Java,Android,Android Gradle Plugin,Apache Httpclient 4.x,Build.gradle,我对android非常陌生,无法理解此错误。同步gradle文件时,android studio将毫无错误地退出,但当我尝试构建并运行应用程序时,它会发出两个警告,如下所示: Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources] Warning:Dependency org.apache.httpcomponents:httpclient:4.0.1 is ignor
Information:Gradle tasks [:app:generateDebugSources, :app:generateDebugAndroidTestSources]
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.
In case of problem, please repackage it with jarjar to change the class packages
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.
In case of problem, please repackage it with jarjar to change the class packages......
我的gradle文件如下:
apply plugin: 'com.android.application'
repositories {
maven {
url 'http://google-api-client-libraries.appspot.com/mavenrepo'
}
mavenCentral()
mavenLocal()
}
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "in.cornerstores.cornerfresh"
minSdkVersion 14
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.google.android.gms:play-services:7.0.0'
compile 'com.android.support:support-v4:22.0.0'
compile 'com.android.support:recyclerview-v7:21.0.3'
compile 'com.facebook.android:facebook-android-sdk:4.0.0'
compile([group: 'com.google.api-client', name: 'google-api-client-android', version: '1.20.0'])
compile([group: 'com.appspot.corner_fresh', name: 'fresh_api', version: 'v1-1.20.0-SNAPSHOT'])
compile('com.google.api-client:google-api-client:1.18.0-rc') {
// Exclude artifacts that the Android SDK/Runtime provides.
exclude group: 'xpp3', module: 'shared'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
exclude group: 'junit', module: 'junit'
exclude group: 'com.google.android', module: 'android'
}
// Add the Android extensions for the Google API client library.
// This will automatically include play services as long as you have download that library
// from the Android SDK manager.
// Add the Android extensions for the Google API client library.
compile('com.google.api-client:google-api-client-android:1.18.0-rc') {
// Exclude play services, since we're not using this yet.
exclude(group: 'com.google.android.gms:play-services', module: 'google-play-services')
}
// END Google APIs
// The following client libraries make HTTP/JSON on Android easier.
// Android extensions for Google HTTP Client.
compile('com.google.http-client:google-http-client-android:1.18.0-rc') {
exclude(group: 'com.google.android', module: 'android')
}
// This is used by the Google HTTP client library.
compile 'com.google.guava:guava:18.0'
compile files('libs/fresh_api-v1-1.20.0-SNAPSHOT.jar')
}
我尝试了在stackoverflow上能找到的一切,但它仍然显示错误。找不到任何正确的答案。请提出解决方案。由于这个原因,我被困在我的项目中。谢谢您可以尝试删除该行:
编译文件树(dir:'libs',include:['*.jar'])即使这个问题已经很老了,它仍然没有解决,我花了一段时间在类似的配置中苦苦寻找原因 您排除了库中的重复导入,但导入了两次Google API 排除零件需要在中
compile('com.google.api-client:google-api-client:1.18.0-rc') {
// Exclude artifacts that the Android SDK/Runtime provides.
exclude group: 'xpp3', module: 'shared'
exclude group: 'org.apache.httpcomponents', module: 'httpclient'
exclude group: 'junit', module: 'junit'
exclude group: 'com.google.android', module: 'android'
}
在您的示例中,您再次通过以下方式包含API:
compile([group: 'com.google.api-client', name: 'google-api-client-android', version: '1.20.0'])
没有导致重复导入的排除部分。在我的情况下,我不得不这样排除两次。。我不认为这太复杂,但可能会让人困惑。我认为最好解决这些警告,因为它们可能会以奇怪的形式回来
compile ('com.google.apis:google-api-services-urlshortener:v1-rev47-1.22.0'){
exclude module: 'httpclient' //by artifact name
exclude group: 'org.apache.httpcomponents' //by group
exclude group: 'org.apache.httpcomponents', module: 'httpclient' //by both name and group
}
compile ('com.google.api-client:google-api-client-android:1.21.0') {
exclude module: 'httpclient' //by artifact name
exclude group: 'org.apache.httpcomponents' //by group
exclude group: 'org.apache.httpcomponents', module: 'httpclient' //by both name and group
}
这些是警告,不是错误。@JaredBurrows,但由于它的存在,它无法编译,我也找不到任何解决方案。您添加的上一个依赖项是什么导致它停止工作的?@JaredBurrows
编译文件('libs/fresh_api-v1-1.20.0-SNAPSHOT.jar')
??这就是我正在导入的云端点api。有什么建议吗?我甚至不知道图书馆是什么。您应该尝试只使用渐变依赖项。