Android Studio3.1.0 Upgrade Issue record

Source: Internet
Author: User

Each time you upgrade Android studio, the Gradle version will also be upgraded accordingly, my previous Android studio 3.0.1, Gradle is 4.1 after the upgrade: Android Studio 3.1.0, Gradle for 4.4.

When the upgrade is complete, first report a bunch of errors (each upgrade is-.) -)

The first mistake is as follows:
 the sourceset  ' instrumenttest '  is  not  recognized by  the Android Gradle Plugin. Perhaps you misspelled something? 

The translation comes from:

“SourceSet” 的‘instrumentTest‘ 没有被Android Gradle插件识别。也许你拼错吗?

Conjecture may gradle remove the ' instrumenttest ' keyword, search the Web, blog address as follows: http://www.it1352.com/139247.html

A new version of Gradle renamed it

That

 旧版本 - > 新版本



instrumentTest

Then see all of their module's gradle, found a place to use the instrumenttest , change it to androidtest , and then continue to synchronize Gradle, and then compile, this error is not reported.

The second error is as follows:
Configuration' Compile '  isObsolete andhave been replaced with' implementation '.
It'll be removed at the end of 2018

The translation comes from:

  config" compiled "is obsolete and replaced by" implementation. " It will be removed at the end of 2018. 

we know, At the beginning of Android Studio3.0 will compile changed to implementation keyword, at that time, the majority of the project compile changed to implementation, but still a part of the change, but still can use, but now? The error is directly to compile! This is not mandatory to allow the use of implementation ? In the wrong of the report is not removed until the end of 2018, this is not the end of it, it can not be used?

Or a good change, because it is our reliance on the library to use the compile, the equivalent of the library relies on a third-party library, directly to implementation is the equivalent of shielding the app to the library relies on the third-party libraries API access rights, And our app just used the library relies on the third-party libraries API, so directly to implementation is not, to let the app can access to the API can be changed, in fact, this is not a good solution, the best solution is , the library encapsulates a layer of app access to the library's third-party repository API, so that the app is not related to the library's third-party libraries, which reduces the coupling between the app and the third-party libraries that the library relies on, which also reflects the " Third-party library isolation "principle, if the future depends on the library changes, you just need to modify the library and the application of the app call method can be, do not move the code inside the app ~

A third error is as follows
Duplicate zip entry [com/c/a/a/a/a.class69.jar:com/ta/utdid2/b/a/a.class]

Translate here as follows:

  duplicate class, that is, the class is in the same package name and class names 

In general, will not write the package name and class name of the same class, I guess it must be a jar package heavy, carefully looked for, found that two libraries are used
Ali's Httpdns jar package, but is not the same version of the jar package, the old version of one of the library used provided compiled, so no conflict, now the new version is recommended to use the compileonly keyword , replace with compileonly keyword after the same mistake, hey yo! This is puzzled, compileonly meaning is not the compile-time dependency, matter the meaning of the package? What's the conflict? After a closer look, I found that one of the libraries had one more confusion Rule jar package (utdid4all-1.1.5.3_ Proguard.jar), while the other one does not, but the old version is no problem, I guess it may be compiled confusion after the discovery of two classes are the same, so the error ...

Solution One:

Two libraries are added Utdid4all-1.1.5.3_proguard.jar use the compileonly keyword compilation;

Solution Two:

Utdid4all-1.1.5.3_proguard.jarare not added to the two library;

Solution Three:

Add a Utdid4all-1.1.5.3_proguard.jar in the app to compile;

At this point, the above several errors are resolved ~

Summary

We should understand the differences between implementation, API, Compileonly and several other key words, see:

Write a picture description here

Finally, attach several reference links:

Https://docs.gradle.org/current/userguide/java_library_plugin.html#sec:java_library_configurations_graph

Https://stackoverflow.com/questions/44413952/gradle-implementation-vs-api-configuration

Android Studio3.1.0 Upgrade Issue record

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.