需要帮助,我是Android Studio的初学者。

huangapple 未分类评论55阅读模式
英文:

Need Help, I am a beginner on Android Studio

问题

我得到了继续进行Android Studio项目的任务,但是当我发布APK时出现了这样的错误。

../../build.gradle:commons-logging定义了与Android现在提供的类冲突的类。解决方案包括查找更新版本或没有相同问题的替代库(例如,对于httpclient,请使用HttpUrlConnection或者okhttp),或者使用类似jarjar的方式重新封装库。

../../build.gradle:httpclient定义了与Android现在提供的类冲突的类。解决方案包括查找更新版本或没有相同问题的替代库(例如,对于httpclient,请使用HttpUrlConnection或者okhttp),或者使用类似jar的方式重新封装库。

这是我在build.gradle中的依赖项:

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.google.code.gson:gson:2.4'
    compile 'org.apache.httpcomponents:httpcore:4.2.4'
    compile 'org.apache.httpcomponents:httpmime:4.3'
    compile 'com.android.support:appcompat-v7:28.0.0'
    compile 'com.android.support:support-compat:28.0.0'
    compile 'com.android.support:design:28.0.0'
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+'
    compile 'com.android.support:support-v4:28.0.0'
    compile 'com.google.code.gson:gson:2.4'
    compile 'com.google.zxing:core:3.2.1'
    compile 'com.google.android.gms:play-services-maps:11.0.4'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:cardview-v7:28.0.0'
    compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
    compile 'me.dm7.barcodescanner:zxing:1.9'
    compile 'com.google.firebase:firebase-messaging:11.0.4'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

但是我不知道问题出在哪里...

英文:

I got the assignment to continue the Android Studio project, but when I will Release the APK there is an error like this.

../../build.gradle: commons-logging defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jarjar.

../../build.gradle: httpclient defines classes that conflict with classes now provided by Android. Solutions include finding newer versions or alternative libraries that don't have the same problem (for example, for httpclient use HttpUrlConnection or okhttp instead), or repackaging the library using something like jar.

This in my dependencies at build.gradle

 dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
        exclude group: 'com.android.support', module: 'support-annotations'
    })
    compile 'com.google.code.gson:gson:2.4'
    compile 'org.apache.httpcomponents:httpcore:4.2.4'
    compile 'org.apache.httpcomponents:httpmime:4.3'
    compile 'com.android.support:appcompat-v7:28.0.0'
    compile 'com.android.support:support-compat:28.0.0'
    compile 'com.android.support:design:28.0.0'
    compile 'pl.droidsonroids.gif:android-gif-drawable:1.1.+'
    compile 'com.android.support:support-v4:28.0.0'
    compile 'com.google.code.gson:gson:2.4'
    compile 'com.google.zxing:core:3.2.1'
    compile 'com.google.android.gms:play-services-maps:11.0.4'
    compile 'com.squareup.picasso:picasso:2.5.2'
    compile 'com.android.support:cardview-v7:28.0.0'
    compile 'com.journeyapps:zxing-android-embedded:3.2.0@aar'
    compile 'me.dm7.barcodescanner:zxing:1.9'
    compile 'com.google.firebase:firebase-messaging:11.0.4'
    testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'

but i don't know where the problem..

答案1

得分: 0

将以下内容添加到位于应用程序模块中的 build.gradle 文件中:

configurations {
    all {
        exclude module: 'httpclient'
    }
}

希望能够正常工作!

谢谢!祝编码愉快!

英文:

Add this in build.gradle locate in app module

configurations {
    all {
        exclude module: 'httpclient'
    }
}

Hope it will work

Thankew! Happy coding!

huangapple
  • 本文由 发表于 2020年5月5日 13:24:22
  • 转载请务必保留本文链接:https://java.coder-hub.com/61606291.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定