2

我想使用 API 19+ 的库,但我的项目是 API 9+。我收到以下错误:

    uses-sdk:minSdkVersion 9 cannot be smaller than version 19 declared in library [*library*] *path to manifest*\AndroidManifest.xml
Suggestion: use tools:overrideLibrary="*library package*" to force usage

我想要做的是让应用程序可用于 API 9+,但在加载使用库的应用程序的 Activity 之前检查用户的 Android 版本,并且只让应用程序的该部分可用于 19+。我想使用 Gradle 而不是手动导入库。但由于它甚至不会编译,我不知道我该怎么做。

我已经尝试过 tools:overrideLibrary 并且它也不起作用。它卡在 :app:transformClassesWithDexForStandardDebug 然后失败。

这是 Gradle 控制台输出:

UNEXPECTED TOP-LEVEL EXCEPTION:
com.android.dex.DexException: Multiple dex files define Lorg/apache/http/ConnectionClosedException;
at com.android.dx.merge.DexMerger.readSortableTypes(DexMerger.java:579)
at com.android.dx.merge.DexMerger.getSortedTypes(DexMerger.java:535)
at com.android.dx.merge.DexMerger.mergeClassDefs(DexMerger.java:517)
at com.android.dx.merge.DexMerger.mergeDexes(DexMerger.java:164)
at com.android.dx.merge.DexMerger.merge(DexMerger.java:188)
at com.android.dx.command.dexer.Main.mergeLibraryDexBuffers(Main.java:504)
at com.android.dx.command.dexer.Main.runMonoDex(Main.java:334)
at com.android.dx.command.dexer.Main.run(Main.java:277)
at com.android.dx.command.dexer.Main.main(Main.java:245)
at com.android.dx.command.Main.main(Main.java:106)



 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:transformClassesWithDexForStandardDebug'.
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Program Files\Java\jdk1.8.0_45\bin\java.exe'' finished with non-zero exit value 2

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED
4

0 回答 0