SoFunction
Updated on 2025-03-11

Android studio 2.3.3 upgrade to 3.1.2 pit (small notes)

Configuration Error: Could not find :gradle:2.2.1.

The solution is a bit like a Maven repository: Enter

D:\software\android\android-studio-ide-145.3276617-windows\android-studio\gradle\m2repository\com\android\tools\build\gradle

Put files in the project

dependencies { classpath ':gradle:2.2.1'}

Change to

dependencies { classpath ':gradle:3.1.2'}

flavors must now belong to a named flavor dimension.

Add a line of code under the module to solve it:

android{ ... flavorDimensions "versionCode" ...}

3. Upgrading to Android Studio 3.1, an error occurred when rebuilding the project, the main error is:

The SourceSet 'instrumentTest' is not recognized by the Android Gradle Plugin. Perhaps you misspelled something?
instrumentTest has been abandoned and the new Gradle plugin is no longer supported. instrumentTest needs to be modified to androidTest.

After modification, the sourceSets related content is similar:

android { buildToolsVersion "27.0.3" compileSdkVersion 24 sourceSets { main { '' = ['src'] = ['src'] = ['src'] = ['res'] = ['assets'] = ['libs'] } ('tests') }}

4. AAPT2 error is reported when compiling AAPT2

Report an error

Error:: .aapt2.Aapt2Exception: AAPT2 error: check logs for details
Solution: Close APPT2 compilation in

android.enableAapt2=false

Note: If it is eclipse to the project on as, there may be no files, please create it manually in the project root directory.

5. After upgrading Android Studio 3.1

After turning all compiles into implementation, neither clean nor rebuild found any errors, but the following error occurred when running:

Causes and solutions

Reason: According to the requirements of Android Stadio 3.1, the gradle version needs to be upgraded to 4.4 and above, but the gradle 4.4 and above require the replacement of the compile that depends on the API to implement. The dependency declared by the implementation cannot be passed outside the module, that is, the module other than the module cannot be referenced to the API declared by the implementation.

That is: module A implementation libA, and moduleB implementation module A, then module B boots the API in libA, otherwise it will be reported when building.
Solution: Just replace compile with api, that is, if there is an external reference, it will be replaced with: api, and the rest will be replaced with: implementation.

Example:

dependencies { api fileTree(dir: 'libs', include: ['*.jar']) testImplementation 'junit:junit:4.12' api ':support-v4:26.1.0' api ':appcompat-v7:26.1.0' api ':gson:2.8.2' api 'com.:ormlite-core:4.48' api 'com.:ormlite-android:4.48'

ps: Solution:

Android 6.0 (api 23) no longer supports HttpClient. Just add useLibrary '' to it, as shown in the figure:

Error:(633, 16) Error: Symbol not found Symbol: Method sqrt(float) Location: Class FloatMath

Solution

The reason is that Android 6.0 does not support() anymore, and there are two main ways to solve it.

Method 1:

Compile with SDK version below 23. Set compileSdkVersion in the file (including project and module) to below 23.

Method 2:

The error above is reported, that is, replace the FloatMath class with the Math class, ();

Method 3:

(float) Replacement

The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.