Android studio2.3.3 Upgrade 3.1.2 Pit

Source: Internet
Author: User

Original: 80255141

1.grade configuration error:could not find com.android.tools.build:gradle:2.2.1. The workaround is a bit like the Maven repository: Enter the D:\software\android\ android-studio-ide-145.3276617-windows\android-studio\gradle\m2repository\com\android\tools\build\gradle  Change the Build.gradle file in the project to dependencies {classpath ' com.android.tools.build:gradle:2.2.1 '}  to dependencies { Classpath ' com.android.tools.build:gradle:3.1.2 '}2.all flavors must now belong to a named flavor Dimension. Add a line of code in the Build.gradle under module to resolve: android{... flavordimensions "Versioncode" ...} 3. Upgrade to Android Studio 3.1, rebuild project times wrong, the main error is: The Sourceset ' instrumenttest ' isn't recognized by the Android Gradle Plugin. Perhaps you misspelled something?instrumenttest has been deprecated, the new Gradle plugin has not been supported. Instrumenttest needs to be modified to androidtest. After the modification, sourcesets related content similar: android {buildtoolsversion "27.0.3" Compilesdkversion sourcesets {main {manifest.srcfile ' Android Oidmanifest.xml ' java.srcdirs = [' src '] aidl.srcdirs = [' src '] renderscript.srcdirs = [' src '] res.srcdirs = [' res '] assets . srcdirs = [' Assets '] JniLibS.srcdirs = [' Libs ']} androidtest.setroot (' tests ')}}4. AAPT2 Compile error AAPT2 error error Error:java.util.concurrent.ExecutionException:com.android.tools.aapt2.Aapt2Exception: AAPT2 Error:check logs For details resolution: Close APPT2 compilation in Gradle.properties
1 Android.enableaapt2=false
Note: If eclipse goes to the project on as, there may not be a gradle.properties file, manually create 5 in the project root directory. After upgrading Android Stadio 3.1, turn all compile into implementation after Neither clean nor rebuild found errors, except for the following error in run: Cause and resolution
    • Reason: According to Android Stadio 3.1 requirements, the Gradle version needs to be upgraded to 4.4 and above, but Gradle 4.4 and above requires the compile of the dependent API to be replaced with implementation. The dependency of the implementation declaration is not passed to the module, which means that the module outside the module has no way of referencing the API of the implementation declaration.
That is: module a implementation Liba, and Moduleb implementation module A, then module B boots the API in Liba, otherwise it will be reported at build time Org.gradle.api.int Ernal.tasks.compile.CompilationFailedException.
    • Workaround: Replace the compile with the API, that is, if there is an external reference, then replace: API, the rest is replaced by: implementation.
Example: Dependencies {API Filetree (dir: ' Libs ', include: [' *.jar ']) testimplementation ' junit:junit:4.12 ' API ' com.android.support:support-v4:26.1.0 ' API ' com.android.support:appcompat-v7:26.1.0 ' API ' Com.google.code.gson: gson:2.8.2 ' API ' com.j256.ormlite:ormlite-core:4.48 ' API ' com.j256.ormlite:ormlite-android:4.48 ' PS: Workaround: Android 6.0 (API 23) already does not support httpclient, add uselibrary ' org.apache.http.legacy ' to Build.gradle, error: (633, 16) Error: Symbol symbol not found: method sqrt (float) Location: Class Floatmath Solution The reason is Android6.0 does not support Floatmath.sin (), there are two main methods to solve. Method one: Compile with the SDK version under 231. Set the compilesdkversion of the Gradle.build file (including Project's Gradle.build and module Gradle.build) to below 23. Method Two: Place the above error, that is, replace the Floatmath class with the Math class, Math.sin (); method three:(float) math.sqrt Replace floatmath.sqrt

Android studio2.3.3 Upgrade 3.1.2 Pit

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.