New Android Studio Versions
Last updated
Last updated
Newer Android Studio users may need to use updated versions for Android Gradle Plugin (AGP) and Gradle.
You can change the AGP version in the build.gradle file (buildscript —> dependencies —> classpath) by replacing with the current version number. Then, change the Gradle version under Project Structure.
The current minimum supported version is 8.6 for Android Studio Jellyfish | 2023.3.1 with AGP 8.4.1.
After syncing and building, you may run into other errors.
Namespace is required for . If the namespace is missing, it can be added under android in the build.gradle file for Module: app. Simply type namespace followed by the same string used by the applicationId under defaultConfig. This is also the same as the package name in the AndroidManifest.xml file under manifests. If the applicationId differs from the package name, use the package name.
Some demos may not have an app folder, or the app folder is empty. This is due to the demo being converted from eclipse. In these cases, the two build.gradle files are combined into one file. Similarly, add the namespace under android in the build.gradle file, but it should be for Project: name instead of Module: app.
If the demo uses aidl, add the following lines of code within android {} (also in build.gradle) as some new versions have :
You can add android.nonFinalResIds=false to gradle.properties or change the switch-case function to if-else statements in the file where the error occurs (generally MainActivity.java).
gradle.properties
Simply copy the following line to the bottom of the file.
Replacement with if-else
Mouse over the switch keyword and Android Studio should give you the option to replace. Alternatively, Ctrl + 1 or Alt + Enter will also bring up the option. The edited function should look like this:
Copy the following line under dependencies in build.gradle.
If you receive the following error:
In the AndroidManifest.xml file, copy the following line into the activity element where the error occurs.
An example AndroidManifest.xml file is below.
If the demo uses buttons with a switch-case function, you may get an error message "constant expression required" for a line such as case R.id.example. This is due to AGP 8.0.0 having default resources that are for optimized build speed.
You can also manually change the import statements following . For example:
Alternatively, you can copy these statements below into gradle.properties, but following the mapping is recommended as the flag can lead to slower build times.
Some configurations have been deprecated since and removed since . These include compile, runtime, testCompile, and testRuntime and should be replaced with implementation, runtimeOnly, testImplementation, and testRuntimeOnly respectively in the build.gradle file.
Manifest merger failed : android:exported needs to be explicitly specified for element <activity#example element>. Apps targeting Android 12 and higher are required to specify an explicit value for android:exported when the corresponding component has an intent filter defined. See for details.