Known Issues with Android Studio and the Android Gradle Plugin

Known issues with Android Studio

Error rendering Compose preview

java.lang.NoSuchFieldError: view_tree_saved_state_registry_owner As of Android Studio Chipmunk, if you see or  in the issues panel  , be sure to add  a dependency java.lang.ClassNotFoundException: androidx.savedstate.R$idto your module  androidx.lifecycle:lifecycle-viewmodel-savedstate . debugImplementation

If you see in the issues panel  , be sure to add  a dependency java.lang.NoSuchFieldError: view_tree_lifecycle_ownerto your module  androidx.lifecycle:lifecycle-runtime . debugImplementation

java.lang.NoClassDefFoundError: Could not initialize class androidx.customview.poolingcontainer.PoolingContainer If you see or  in the issues panel  , be sure to add  a dependency java.lang.NoClassDefFoundError: androidx/customview/poolingcontainer/PoolingContainerListenerto your module  androidx.customview:customview-poolingcontainer . debugImplementation

Error using different passwords for key and keystore

Starting with version 4.2, Android Studio will now run on JDK 11. This change results in a change in the underlying behavior related to signing keys.

When you go to  Build > Generate Signed Bundle / APK  and try to configure application signing for the app bundle or APK, if you enter different passwords for the key and keystore, the following error may result:

Key was created with errors:
Warning: Different store and Key passwords not supported for PKCS12 Key stores

To resolve this issue, enter the same password for the key and keystore.

Android Studio won't start after installing version 4.2

Studio will try to import the previous version of .vmoptions and clean it up to work with the garbage collector used by JDK 11. If this process fails, Android Studio may not start for users who have custom virtual machine options set in the .vmoptions file.

To resolve this issue, we recommend commenting out custom options (using the '#' character) in .vmoptions. The .vmoptions file is located in the following location:

Windows

C:\Users\YourUserName\AppData\[Local|Roaming]\Google\AndroidStudio4.2\studio64.exe.vmoptions

macOS

~/Library/Application Support/Google/AndroidStudio4.2/studio.vmoptions

Linux

~/.config/Google/AndroidStudio4.2/studio64.vmoptions

Apps using Database Inspector crash on Android 11 emulator

Apps using Database Inspector may crash when running on the Android 11 emulator; if a crash occurs, the following error will be displayed in Logcat:

 Fatal signal 11 (SIGSEGV), code 1 (SEGV_MAPERR)

To solve this problem, please upgrade the Android 11 emulator to version 9 or higher, as follows: Go to  Tools > SDK Manager in sequence , and in  the SDK Platforms  tab, check the box labeled  Show Package Details  , Then select Android 11 emulator revision 9 or later.

 Studio fails to start after upgrade

If Studio does not start after upgrading, it may be due to an invalid Android Studio configuration imported from an older version of Android Studio or an incompatible plugin. To resolve this issue, depending on the Android Studio version and operating system you are using, try deleting the following directories (or renaming the following directories as a backup), then start Android Studio again. This will reset Android Studio to its default state and remove any third-party plugins.

For Android Studio 4.1 and above:

  • Windows : %APPDATA%\Google\AndroidStudio<version>
    example:C:\Users\your_user_name\AppData\Roaming\Google\AndroidStudio4.1

  • macOS : ~/Library/Application Support/Google/AndroidStudio<version>
    Example:~/Library/Application Support/Google/AndroidStudio4.1

  • Linux : ~/.config/Google/AndroidStudio<version> and  ~/.local/share/Google/AndroidStudio<version>
    example: ~/.config/Google/AndroidStudio4.1 and ~/.local/share/Google/AndroidStudio4.1

For Android Studio 4.0 and below:

  • Windows : %HOMEPATH%\.AndroidStudio<version>\config
    example:C:\Users\your_user_name\.AndroidStudio3.6\config

  • macOS : ~/Library/Preferences/AndroidStudio<version>
    Example:~/Library/Preferences/AndroidStudio3.6

  • Linux : ~/.AndroidStudio<version>/config
    Example:~/.AndroidStudio3.6/config

PreviewX.YNote that the configuration directory is (and is not used for  <version> )  Android Studio Canary and Beta  X.Y. For example, Android Studio 4.1 Canary build uses  AndroidStudioPreview4.1 directories instead of  AndroidStudio4.1 directories, which are used for release candidates and stable releases.

Compilation issues in Kotlin multiplatform projects

Compilation errors may occur in Kotlin MPP code due to missing symbols. Upgrading the Kotlin plugin to version 1.4 should resolve the issue.

Keymap Conflicts on Linux

On Linux, some keyboard shortcuts conflict with default Linux keyboard shortcuts and with keyboard shortcuts for common window managers such as KDE and GNOME. These conflicting keyboard shortcuts may not work properly in Android Studio.

Interface text is smaller on ChromeOS

On ChromeOS, text may appear much smaller than in previous versions. To resolve this issue, do the following:

  1. Click  File > Settings in turn to open  the Settings  window
  2. Go to  Appearance & Behavior > Appearance .
  3. Select  Use custom font .
  4. Increase font size.
  5. In  the Settings  window, go to  Editor > Font .
  6. Increase font size.
  7. Click  OK .

code editing

This section describes known issues related to the code editor.

Keyboard Input Freezes - 'iBus' Problems on Linux

There are some known interaction issues between the iBus daemon on Linux and Android Studio. In some cases, the IDE stops responding to keyboard input or starts typing random characters. This bug is caused by incomplete synchronization between iBus and XLib + AWT and has been reported upstream to  JetBrains  and  iBus  developers. There are currently three workarounds for this issue:

  • Solution 1 : Force iBus into sync mode. Before starting Android Studio, run the following command on the command line:
    $ IBUS_ENABLE_SYNC_MODE=1 ibus-daemon -xrd
  • Solution 2 : Disable iBus input method in Android Studio. To disable iBus IME for Android Studio only, run the following command on the command line:
    $ XMODIFIERS= ./bin/studio.sh
    Doing so only disables the input method for Android Studio, it does not affect any other applications you may be running. ibus-daemon -rdNote that if you restart the iBus daemon (for example, by running ) while Android Studio is running  , this disables IME for all other applications and may cause Android Studio's JVM to crash with a segmentation fault.
  • Solution 3 : Check the shortcut key settings carefully to make sure that the Next input shortcut is not   set to Ctrl+Space, because this is also the code completion shortcut in Android Studio. The default shortcut in Ubuntu 14.04 (Trusty) is Super+Space, but it may have carried over from previous versions. To check shortcut key settings, run in the command line  ibus-setup to open the IBus Preferences window. Under  Keyboard Shortcuts  , check  Next input method . If it's already set to Ctrl+Space, change it to Super+Space or another shortcut of your choice.

project configuration

This section describes known issues related to project configuration and Gradle sync.

Gradle sync failed: Invalid pipeline

This issue is caused by the Gradle daemon trying to use IPv4 instead of IPv6.

  • Workaround 1: On Linux, put the following  in ~/.profile or  ~/.bash_profile :
    export _JAVA_OPTIONS="-Djava.net.preferIPv6Addresses=true"
  • Solution 2: In Android Studio's  vmoptions file-Djava.net.preferIPv4Addresses=true change the line to  -Djava.net.preferIPv6Addresses=true. See the Networking IPv6 User's Guide for details .

Gradle sync or SDK manager "peer not authenticated" error

The root cause of these errors is  $JAVA_HOME/jre/lib/certificates/cacerts a missing certificate in . To resolve this type of error, please follow these steps:

  • If you are using a web proxy, try connecting directly. If a direct connection works, then in order to connect through a proxy, you may need to  keytool add the proxy server's certificate to the cacerts file using .
  • Reinstall a supported and unmodified JDK. There is a known issue affecting Ubuntu users that produces empty  /etc/ssl/certs/java/cacerts. To resolve this issue, execute the following command at the command line:
    sudo /var/lib/dpkg/info/ca-certificates-java.postinst configure

deploy

This section describes known issues about deploying apps to connected devices.

[Mac OS only] Incremental updates cannot be performed due to a problem with Gradle file monitoring for projects saved /System/Volumes/Data under

Gradle issue 18149  affects Android Gradle plugin version 7.0 and later, because they require Gradle version 7.0 and later . Starting with Gradle 7.0, file monitoring is enabled by default. If you are using Mac OS and the project is saved /System/Volumes/Data under , the Gradle file watch feature will not track file changes properly. This makes any file changes invisible to the build system, so the APK cannot be updated. At this point, the incremental deployment code will do nothing because the local APK state is the same as on the device.

To fix this, you should move your project's directory to your user directory, ie  /Users/username under. The build system is then properly notified about file changes via Gradle file monitoring, and the incremental changes are successfully applied.

Android emulator HAXM on macOS High Sierra

The Android Emulator on macOS High Sierra (10.13) requires HAXM 6.2.1 or later for optimal macOS compatibility and stability. However, the process of installing kernel extensions such as HAXM on macOS 10.13 is more cumbersome. You need to manually allow installation of kernel extensions as follows:

  1. First, try  installing the latest version of HAXM through the SDK Manager .
  2. In MacOS, go to  System Preferences > Security and Privacy .
  3. If you see "System software from developer "Intel Corporation Apps" was blocked from loading", click  Allow :

 

Apply Changes

This section describes   known issues related to Apply Changes .

No new app name adopted

If you rename your app and then try to apply the change, the updated name may not appear. To fix this, click  the Run  icon   to redeploy the app and you should see the changes.

 

Issue in Android Runtime throwing error

If you're using a device running Android 8.0 or 8.1, you might see a "VERIFICATION_ERROR" message when trying to apply certain types of changes, especially if you're using Kotlin. This message is caused by an issue related to the Android Runtime, which has been resolved in Android 9.0 and higher. Although this issue causes Apply Changes to fail, you can still see the changes by clicking the  Run  icon   to re-run the app. However, it is still recommended that you upgrade your device to Android 9.0 or higher.

Debug and test

This section describes known issues related to debugging and testing your app.

JUnit test cannot find resource in classpath when run from Android Studio

If your Java modules use specific resource folders, those resources will not be found when running tests from the IDE. You can run tests with Gradle from the command line, or execute Gradle  check tasks from the IDE. See issue 64887 for details .

The problem occurs because, from IntelliJ 13 onwards, you can only use one folder as classpath. IntelliJ's build tools will copy all resources into the build folder, but Gradle will not.

  • Workaround 1: Run the Gradle  check task from the IDE instead of running the unit tests.
  • Workaround 2: Update the build script to manually copy the resources into the build folder. See comment 13 here for more details .

Running JUnit tests may compile code twice

When creating a new project, the system may create a template JUnit configuration in two "pre-publish" steps, Make and Gradle-aware Make. The system then propagates this configuration to all created JUnit run configurations.

  • To fix this for the current project, click  Run > Edit Configurations and change the default JUnit configuration to only include a Gradle-aware Make step.
  • To fix this for all future projects, click  File > Close Project . You should see the welcome screen. Then, click  Configure > Project Defaults > Run Configurations and change the JUnit configuration to include only the Gradle-aware Make step.

Some test run configurations are invalid

Not all available run configurations are available when right-clicking on a test method. Specifically, the following configurations do not work:

  • The Gradle run configuration (its icon is the Gradle logo) is invalid.
  • JUnit run configurations (which do not have a green Android icon) are not suitable for instrumented tests (such tests cannot be run on the local JVM).

Android Studio also remembers the run configuration created in a given context (for example, right-clicking on a specific class or method) and won't give you the option to run in a different configuration in the future. To fix this, click  Run > Edit Configurations and remove the incorrectly created configuration.

Add Java breakpoints when debugging native code

The Auto  and  Dual  debuggers may not immediately recognize new Java breakpoints you set when your application is paused at a breakpoint in native code . To avoid this problem, add a Java breakpoint before starting a debugging session or when pausing the application at a Java breakpoint. See issue 229949 for details .

Exit the native debugger

When using  the Auto  or  Dual  debugger to debug Java code and native code, if you step through the Java code to execute the native function (for example, the debugger pauses execution at a line of Java code that calls the native function, and you click the Step Into icon)  and  want  to To return to the Java code, click  the Resume Program  icon  (not  the Step Out  icon   or  the Step Over  icon  ). Your application process will still be suspended, so click  the Resume Program  icon  in the your-module-java  tab   to resume it.

Native debugger hangs when loading libraries

When using the native debugger for the first time after upgrading to Android Studio 4.2 and higher, the native debugger might stop responding when loading libraries from an Android device. This is a nasty problem that continues to occur even if you stop and restart the debugger. To resolve this issue, delete  $USER/.lldb/module-cache/ the LLDB cache.

Native debugger crashes with "Debugger process finished with exit code 127"

This error occurs on Linux-based platforms when starting the native debugger. This indicates that a library required by the native debugger is not installed on the local system. The names of missing libraries may have been output to  idea.log the file. If not, you can use the terminal to enter the Android Studio installation directory, and execute  bin/lldb/bin/LLDBFrontend --version the command line to find out which libraries are missing. Usually, the missing libraries are  ncurses5because some recent Linux distributions have been upgraded to  ncurses6.

Performance Analyzer

This section describes known issues with Performance Analyzer.

Native Memory Profiler: No profiling during app startup

The native memory profiler is currently not available during app startup. This option will be available in an upcoming release.

As a workaround, you can use  the Perfetto standalone command-line profiler to capture the startup profile.

Timeout errors in CPU Profiler

If you choose to sample Java methods or trace Java method configurations, you may encounter a "Failed to stop recording" error in the Android Studio CPU Profiler. These are common timeout errors, especially if you  idea.log see the following error messages in your files:

Wait for ART trace file timed out

Timeout errors tend to affect tracked methods more than sampled methods, and tend to affect longer records more than shorter records. As a temporary workaround, it may be helpful to try logging for a shorter period of time to see if the error goes away.

If you experience timeout issues with Profiler, please file a bugidea.log with the device make/model and  any relevant entries from and to Logcat in your submission  .

adb exception while performing debugging or profiling

When using Platform Tools 29.0.3, native debugging and the Android Studio profiler might not work correctly, and if you choose  Help > Show Log , you might  idea.log see "AdbCommandRejectedException" or "Failed to connect port" in the file. Upgrading Platform Tools to 29.0.4 or later resolves both issues.

To upgrade Platform Tools:

  1. Open the SDK Manager from Android Studio by clicking  Tools > SDK Manager or clicking the SDK Manager  icon   in the toolbar  .
  2. Click  the checkbox next to Android SDK Platform-Tools  so it shows a check mark. A download icon should appear in the left column  .
  3. Click  Apply  or  OK

Plugins prevent the Build Output window from functioning properly

Using  the CMake simple highlighter  plugin prevents content from being displayed in the "Build Output" window. The build runs and the "Build Output" tab is displayed, but nothing is output ( issue 204791544 ).

 

Installation order prevents booting

If you install the new version of Android Studio first, and then install the old version of Android Studio, the old version may fail to start. For example, if you first install the Canary version of Android Studio and then try to install and start the stable version, the stable version may fail to start. In such cases, you must clear your cache to start the stable (old) release. On macOS, to clear the cache, delete  Library/ApplicationSupport/Google/AndroidStudioversion_number the directory. On Windows, to clear the cache, use Disk Cleanup .

Espresso test recorder not working with Compose

The Espresso Test Recorder does not work with projects containing Compose. To create UI tests for projects that include Compose, see Testing Compose Layouts .

Logcat shortcuts conflict with non-English keyboard layouts

If you are using a non-English keyboard layout, the default Logcat keyboard shortcuts may conflict with the layout, preventing you from entering certain characters when editing text in Android Studio. To resolve this issue, delete or remap the conflicting Logcat keymaps. To modify the Logcat keymap in Android Studio, go to  Android Studio > Settings > Keymap and search in the list of keymaps  Logcat. See issue 263475910 for details .

This issue will be fixed in Android Studio Electric Eel Patch 1 by removing the Logcat shortcut.

Known Issues with the Android Gradle Plugin

This section describes known issues in the latest stable release of the Android Gradle plugin.

The system does not lint all dynamic library dependencies

When  checkDependencies = true running lint from an app module with this set, dynamic feature library dependencies are not checked unless those library dependencies are also app dependencies ( issue 191977888 ). As a workaround, you can run lint tasks on these libraries.

Sign files named with carriage returns

JAR signing (v1 scheme) does not support filenames containing carriage returns ( issue 63885809 ).

Variant output may not be properly modified at build time

The new plugin does not support using the Variant API to manipulate the variant output, but still supports using the API for some simple tasks, such as changing the APK name at build time, as follows:

// If you use each() to iterate through the variant objects,
// you need to start using all(). That's because each() iterates
// through only the objects that already exist during configuration time—
// but those object don't exist at configuration time with the new model.
// However, all() adapts to the new model by picking up object as they are
// added during execution.
android.applicationVariants.all { variant ->
    variant.outputs.all {
        outputFileName = "${variant.name}-${variant.versionName}.apk"
    }
}

However,  outputFile complex tasks involving accessing objects are no longer supported. This is because tasks specific to specific variants are no longer created during the configure phase. This prevents the plugin from knowing all the outputs up front, but it also means that configuration time will be reduced.

manifestOutputFile is no longer available

processManifest.manifestOutputFile() method is no longer available, you will encounter the following error when calling it:

 

A problem occurred configuring project ':myapp'.
   Could not get unknown property 'manifestOutputFile' for task
   ':myapp:processDebugManifest' of type
   com.android.build.gradle.tasks.ProcessManifest.

 Instead of calling to get a manifest file for each variant , you can  processManifest.manifestOutputDirectory() call to return the path to the directory containing all generated manifests  . manifestOutputFile()You can then find the manifest and apply your logic to that manifest. The following example will dynamically change the version code in the manifest:

android.applicationVariants.all { variant ->
    variant.outputs.all { output ->
        output.processManifest.doLast {
            // Stores the path to the maifest.
            String manifestPath = "$manifestOutputDirectory/AndroidManifest.xml"
            // Stores the contents of the manifest.
            def manifestContent = file(manifestPath).getText()
            // Changes the version code in the stored text.
            manifestContent = manifestContent.replace('android:versionCode="1"',
                    String.format('android:versionCode="%s"', generatedCode))
            // Overwrites the manifest with the new text.
            file(manifestPath).write(manifestContent)
        }
    }
}

 

Issues with AGP 7.3.0 AIDL support and Kotlin 1.7.x

Using AGP 7.3.0 with KAPT in Kotlin 1.7.x caused the AIDL source set to be removed for certain build variants. You can still use other AIDL source sets, including  main/AIDL source sets for build types, product variants, and combinations of product variants. If you need to use a variant-specific AIDL source set, please continue to use Kotlin 1.6.21.

Known issues fixed

This section describes known issues that have been fixed in the latest release. If you experience any of the issues described, please update Android Studio to the latest stable or preview release .

Fixed issues in Android Studio 2021.1.1

  • Missing lint output :  lint text output UP-TO-DATE when  the status of the lint task  is No output to ( issue 191897708 ). Fixed in AGP 7.1.0-alpha05.stdout
  • Issue when unit testing application projects that use the Hilt plugin : The unit test classpath contains non-instrumented application classes, which means that when running unit tests, Hilt does not instrument the application classes to handle dependency injection ( issue 213534628 ) . Fixed in AGP 7.1.1.

Fixed issues in Android Studio 2020.3.1

  • lint exceptions in Kotlin projects : Kotlin projects set up  checkDependencies = true may encounter null pointer exceptions or bugs ( issue 158777858 ).

Fixed issues in Android Studio 4.2

  • IDE freezes on macOS Big Sur : Android Studio 4.1 may freeze when you open a dialog.

Issues fixed in Android Studio 4.1

  • Restart to apply memory settings from previous IDE versions : After updating Android Studio, you need to restart Android Studio to apply any memory settings migrated from previous IDE versions.
  • Manifest classes with custom permission strings are no longer generated by default : set that if you want to generate the class  android.generateManifestClass = true.

Fixed issues in Android Studio 3.6

  • APK installation error on LineageOS : Deploying an app to devices running certain versions of LineageOS or CyanogenMod may fail with  INSTALL_PARSE_FAILED_NOT_APK an exception.

    On Android Studio 3.6 Beta 1 and higher, when you deploy your app to a LineageOS or CyanogenMod device, the IDE handles this exception by performing a full app install, which can result in longer deployment times.

Fixed issues in Android Studio 3.5.2

  • Broken XML code style : When modifying XML code, if you choose  Code > Reformat Code from the menu bar , the IDE applies an incorrect code style.

Fixed issues in Android Studio 3.3.1

  • Out of memory error when scanning C++-based projects : If Gradle scans a project that has C++ code in multiple locations on the same drive, the scan includes all directories under the first common directory of those locations. Scanning a large number of directories and files may cause out of memory errors.

Guess you like

Origin blog.csdn.net/mozushixin_1/article/details/131540439