Android — Android Studio eRRor


Содержание

Andro >

������ �������� ������ �� �������, ��� ��������� �������� Android Studio ������������ �� �������� ����������, ����� ��� ���� ������������ ��������� � ������� ��� ������ ��������.

���������� ���������� ���������� ������������ ������� ������������ �� ���������� �������. ��� Android Studio ������� �� �������� ���������� �������� ����������� ���������. ��� ����� ������� ��� ������:

  • ���������;
  • �������� ����������� TCP,IP;
  • USB.

����� �������� Android Studio ������� �� USB, ������������ ��������������� ��������. ��� ������� ����������� ������������� ����� ������� �� ��.

Android ���������� ������������� �������������� ����� ���������������� (Java, C++, Kotlin), �������� ������������ �������� ���-������. �������� �������������� �����������:

��� �������� ADB ��� Android studio

Android Debug Bridge ��� adb � ������� ��������� ������. � �� ������� ���������� Android Studio ������������ �� �������� ����������:

  • ���������� ����� �� �������� � �������;
  • ��������� ����������;
  • ����������� ����� ���������� �����������;
  • �������������� ���������� �� �����������.

�������� �� ������ ������-������. ������� ����������� �� ���������� � ��������� �� ����� �.

Adb ��������������� ����� ����� Wi-Fi. ��� ����� �������������� ����������� ��������� � ������ Wi-Fi, ����� ��� �� ������ ���������� ���� �����. ����� ��������� Android Studio ������ ���������� �� �������� � ������������ �������� Android.

Android Debug Bridge � ���������� ���������� ��� ������������� � �������� ����� �� ��������� ��������. ������������������ ������� �������� ����������������� � ������������ �� ������������������ ��������.

��������� Android-���������� ��� ������������ � ADB

����� ��������� Android Studio �� ���������� ����������� �������������� SDK. ����� � ���������� �������������� ���������� ���������, ������� ���������� ��-�� ������ ������� �������, ������������� � ������ ������������ �����������. ��������, ��� � ������� ������ ���������� ����������, �������� � ���������� ������:

    ������� � ���������� �������� ��� �������� Andro >

Android �������, ����� ���������� Android Studio �������� ���������� ��������� USB. ������� ����������� �������:

  • ����������� ������, � ������� ����������� ������������ ������;
  • ��������� ������������ �� ������ � ����������;
  • ����������� �������� ���� � ����������;
  • ���������� ������������ � �� ����������, ������� ������ � ������ � ADB.

��������� ADB �� Windows

��������� ADB ��� Windows ������������� � ����� ���������� ��. ��� ������������� ������� �� ���������� ��������������� SDK. ��� ������������� ������ ���������� 9 ��. �� ������������ ��� ������ Windows. ���������� ������������� ������������� ��������, ������� ���������� ��� ������������ �� ����������. ����� ��� ���������� ������������ ����������� ����������� ��������� Google. ���������� ������� ��������� �� ������� ���������� �� �������. ������ ���������� � ������� ������ �� �������� � ������� Run App. ����� ����� ����������� ���� ������ ����������, � ����������� ����������.

��������� ��������� ADB ��� ������������

�������� �������� ���������� � ������� ��������� ������ Windows. ����� ������� � ���� ��� ����� ������ �������� � ������ ���������� ������ �adb devices�. � ��������� ��������� �������� ���������, ������� ���������� � ����������. ���� �� ������ �������� �������� ������, ������, ��������� ���������� ���������, � ADB �������� � ������ ��������� �������.

������������ ���������� � ������� ��������� ����������

�������������� SDK ������������� � ��������� ��������� ������ ��� ��� ����������. ������� ���������� ���������� ���� � �������� � ������������� ������ ������.

��� ������, ���� Android Studio �� ����� ������� Samsung? ��������� ����������, ����� ��� ���������� ����������, ������������ ������� adb. ��������� ������� ������������ � Android Studio, ����������, ��� ��������� ������ �� ��������.

Known issues with Andro devsite-toc-embedded >

This page tracks known issues with Android Studio 3.5 and Android Gradle plugin 3.5.0. If you experience an issue not already included here, please report a bug.

Upgrade to preview: Each release of Android Studio and the Android Gradle plugin aims to improve stability and performance, and add new features. To experience the benefits of upcoming releases now, download and install Android Studio Preview.

Known Issues with Android Studio

This section describes known issues that exist in the latest stable version of Android Studio.

Code editing

This section describes known issues related to the code editor.

Frozen keyboard input — «iBus» problems on Linux

There are some known interactions between the iBus daemon on Linux and Android Studio. In some scenarios, the IDE stops responding to keyboard input or starts inputting random characters. This bug is triggered by some missing synchronization between iBus and XLib + AWT, and has already been reported upstream to JetBrains and iBus. There are three current workarounds for this issue:


  • Workaround 1: Force iBus into synchronous mode. Before starting Andro >ibus-daemon -rd ), you effectively disable the input methods for all other applications and may also crash Andro >ibus-setup on the command line to open the IBus Preferences window. Under Keyboard Shortcuts, check the Next input method. If it is set to Control+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: Broken Pipe

The issue is that the Gradle daemon is trying to use IPv4 instead of IPv6.

    Workaround 1: On Linux, put the following in your

/.bash_profile :

  • Workaround 2: in Andro >-Djava.net.preferIPv6Addresses=true to -Djava.net.preferIPv6Addresses=true For more information, see the Networking IPv6 User Guide.
  • «peer not authenticated» errors from Gradle sync or SDK Manager

    The root cause of these errors is a missing certificate in $JAVA_HOME/jre/lib/certificates/cacerts . To resolve these errors, proceed as follows:

    • If you’re behind a proxy, try to connect directly. If the direct connection works, then in order to connect via the proxy you may need to use keytool to add the proxy server’s certificate to the cacerts file.
    • Re-install a supported, unmodified JDK. There’s a known issue affecting Ubuntu users, which results in an empty /etc/ssl/certs/java/cacerts . To work around this issue, execute the following on the command line:

    Deploying

    This section describes known issues related to deploying your app to a connected device.

    Android Emulator HAXM on macOS High Sierra

    The Android Emulator on macOS High Sierra (10.13) requires HAXM 6.2.1+ for best compatibility and stability with macOS. However, macOS 10.13 has a more involved process to install kernel extensions such as HAXM. You need to manually allow the kernel extension itself to be installed as follows:

    1. First, attempt to install the latest version of HAXM from the SDK Manager.
    2. In MacOS, go to System Preferences > Security and Privacy.

    If you see an alert that System software from developer «Intel Corporation Apps» was blocked from loading, click Allow:

    For more information and workarounds, see this Apple webpage and issue 62395878.

    Apply Changes

    This section describes known issues that are related to Apply Changes.

    Issue in Android Runtime throws error

    If you’re using a device that runs Android 8.0 or 8.1, you might encounter «VERIFICATION_ERROR» messages when trying to apply certain types of changes (especially if you’re using Kotlin). This message is caused by an issue with the Android Runtime that is fixed in Android 9.0 and higher. Although the issue causes Apply Changes to fail, you can still Run your app again to see your changes. However, we recommend that you upgrade the device to Android 9.0 or greater.

    Cannot apply changes when using android:sharedUserId

    If you try to make changes to a class that hasn’t yet been deployed to your running app, Apply Changes will fail if your app is configured in either of the following ways:

    • Your app shares data with another app using a shared android:sharedUserId .
    • Your app runs in the same process as another app using a shared android:sharedUserId and android:process .

    When Apply Changes fails due to this issue, Android Studio displays the following message:

    To work around this issue in Android Studio 3.5, click Run to re-deploy your app and see your changes.

    Note: This issue (#135172147) is fixed in Android Studio 3.6 Canary 6 and higher. If you have Android Studio set to receive updates on the Canary or Dev channel, you can get the latest version by choosing Help > Check for Updates (Android Studio > Check for Updates on macOS). Otherwise, you can download it from the Android Studio preview page.

    Debugging and testing

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


    JUnit tests missing resources in classpath when run from Android Studio

    If you have specific resource folders in your Java modules, then those resources won’t be found when running tests from the >check task from the IDE will also work. See issue 64887 for more details.

    This issue occurs because as of IntelliJ 13, which requires that you only have a single folder as the classpath. IntelliJ’s builder copies all resources into that build folder, but Gradle doesn’t copy over the resources.

    • Workaround 1: Run the Gradle check task from the IDE rather than running a unit test.
    • Workaround 2: Update your build script to manually copy resources into the build folder. See comment #13 for more information.

    Running JUnit tests may compile the code twice

    When creating a new project, the template JUnit configuration might be created with two «Before launch» steps: Make and Gradle-aware Make. This configuration is then propagated to all created JUnit run configurations.

    • To fix the issue for the current project, click Run > Edit Configurations and change the default JUnit configuration to only include the Gradle-aware Make step.
    • To fix the issue 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 only include the Gradle-aware Make step.

    Some test run configurations don’t work

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

    • Gradle run configurations (which have a Gradle logo as the icon) don’t work.
    • JUnit run configurations (which have an icon without the green Android) don’t apply to instrumentation tests, which cannot be run on the local JVM.

    Android Studio also remembers the run configuration created in a given context (for example, right-clicking a specific class or method), and will not offer to run in a different configuration in the future. To fix this, click Run > Edit Configurations and remove the incorrectly-created configurations.

    Adding Java breakpoints while debugging native code

    While your app is paused at a breakpoint in your native code, the Auto and Dual debuggers may not immediately recognize new Java breakpoints that you set. To avoid this issue, add Java breakpoints either before starting a debug session or while the app is paused on a Java breakpoint. For more information, see issue 229949.

    Stepping out of the native debugger

    While using the Auto or Dual debugger to debug Java and native code, if you step into a native function from your Java code (for example, the debugger pauses execution at a line in your Java code that calls a native function and you click Step Into ) and you want to return to your Java code, click Resume Program (instead of Step Out or Step Over ). Your app process will still be paused, so click Resume Program in the your-module -java tab to resume it. For more information, see issue 224385.

    Profilers

    This section describes known issues with the Profilers.

    ADB exception when debugging or profiling

    When using Platform Tools 29.0.3, native debugging and the Andro >idea.log file when you select Help > Show Log. Upgrading the Platform Tools to 29.0.4 or higher fixes both issues.

    To upgrade the Platform Tools, do the following:

      Open the SDK Manager from Android Studio by clicking Tools > SDK Manager or click SDK Manager in the toolbar.

    Click the checkbox next to Android SDK Platform-Tools so it shows a checkmark. A download icon should appear in the left column.

  • Click Apply or OK.
  • Цукерберг рекомендует:  Поиск по сайту с использованием API Google AJAX Search

    Known issues with the Android Gradle Plugin

    This section describes known issues that exist in the latest stable version of the Android Gradle plugin.

    Signing file named with Carriage Return (CR) characters

    JAR signing (v1 scheme) does not support file names containing Carriage Return (CR) characters. (See issue #63885809).

    API changes

    Android Gradle Plugin 3.0.0 and higher introduce API changes that remove certain functionalities and may break your existing builds. Later versions of the plugin may introduce new public APIs that replace broken functionalities.

    Modifying variant outputs at build time may not work

    Using the Variant API to manipulate variant outputs is broken with the new plugin. It still works for simple tasks, such as changing the APK name during build time, as shown below:

    However, more complicated tasks that involve accessing outputFile objects no longer work. That’s because variant-specific tasks are no longer created during the configuration stage. This results in the plugin not knowing all of its outputs up front, but it also means faster configuration times.


    manifestOutputFile is no longer available

    The processManifest.manifestOutputFile() method is no longer available, and you get the following error when you call it:

    Instead of calling manifestOutputFile() to get the manifest file for each variant, you can call processManifest.manifestOutputDirectory() to return the path of the directory that contains all generated manifests. You can then locate a manifest and apply your logic to it. The sample below dynamically changes the version code in the manifest:

    Fixed known issues

    This section describes known issues that have been fixed in a recent release. If you are experiencing any of these issues, you should update Android Studio to the latest stable or preview version.

    Fixed in Android Studio 3.6 Beta 1

    APK installation error on LineageOS: Deploying your app to devices running certain versions of LineageOS or CyanogenMod might fail and throw an INSTALL_PARSE_FAILED_NOT_APK exception.

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

    Fixed in Android Studio 3.5.2

    • Broken XML code style: When editing XML code, the IDE applied an incorrect code style when you selected Code > Reformat Code from the menu bar.

    Fixed in Android Studio 3.3.1

    Out of memory errors when scanning C++-based projects: When Gradle scans a project that has C++ code in more than one location on the same drive, the scan includes all directories below the first common directory. Scanning a large number of directories and files may lead to out of memory errors.

    For more information on this issue, read the bug associated with the issue.

    Content and code samples on this page are subject to the licenses described in the Content License. Java is a registered trademark of Oracle and/or its affiliates.

    Android Studio: 10 ������� ����������� ������������ � �� �������

    ���������� ������

    ������� ��������� ���������� ��� ����� ���������, �� ����������� ����� �� ���������� �� ��������� � ������� ������� ���������� ��������� ������. ����������� �� ��� ����� ������� � ����� ��������� �������: ������������ � API, ������� �������, �����������, ������ ����� ���������������� ��� ���������. ���� � �����, ������� ������� �������: ������������ � �������������� �����������, �������� �������� � ������, ��������� �������������� ����-��������. ��������� ������������ ��� Android ������� ������ � ��� ��� ����.

    � ���� ������ �� ���������� �������� ���������� ��� Android � ��������� ������ � ������������. �� ��������� �� ������������� ���������� �������� � ������� ������ �� ����� ������������ � ������� �� ����������, �������� ���������� �� ������ Lite � Pro, ������� � ���� �������� �������������� ��������� � ������� �� ������ ����-��������, �������������� ������������, ����������� � ������������ ���, � ����� �� ��������� ����� �������� ��� ���������� ������ � ��� ����������� �������. �������.

    1. ��������� ��������

    ����, �� �������� ���� ������ ����������, � ���� ��� ��������� � ��������� �� �����������������. ��� ����� � ��������� Android SDK ���� ��������. ������ ����� ��� �������� �� ��������������, �� � �������� Android Studio 2.0 �������� ������� ���������� � x86-������ ��������� �������� ���������� ���������, ��� ��� ������ �� �������� ������� �������� ���������. � ���� �� � ���� �������� ������� ����������� ���������, � ������� �������� ����� ������������ ������, ���, �������� ������ GPS � ���� � ����, �� ���� ���, ��� ���� ������ ����������� ������������ ����������� ��������� ������.

    �������, ���� �� ��� �� ���������, ������������ ���������� ��� �������, �� ������ ��� � �������� � Eclipse. � ����������� �������� x86-������ ��������� � AVD manager, ARM-������ �� ������������ ���������� ���������.

    ����� �������� Android Studio 2.0

    2. �������� �� �������

    ������ ���� � ������������ �� �������� ����������. ����� ��� ������: ����������� �������� �� USB, �������������� ��������, ��������� ����� ������� � ���������� ��� �������������, ����� ���� ������ ���������� � ������ ��������� ��� ��������� ���������� (����� � ����������). �������� ������ � ���, ��� � ������ ������ ���������� ���������� ������� ������������ � �� � ������� ������, � ���� ��� ���� �������� ��������, �� ������� ��������� ������ � ���������, �� �� �������� �������� �� ����������.

    � �������, Android Studio (� ������, ������� ADB, ������� �� ���������� ��� ����� � �����������) ������������ ������ �� ����. �� ������ ������� ��� ����� ������������. ���� � ���� ���������� ��������, �� ���� �������: �������� ������� �� ���� ����� � ������� ���������� WiFi ADB. ������������������ ��������:

    1. ������������� WiFi ADB, ���������, �������� ������� ����� � ������� ������������� � ���������� IP-�����.
    2. ��������� Android Studio.
    3. ��������� �������, ��������� � ������� � ������������� SDK, ����� � platform-tools � ��������� ��������� �������:

    $ adb connect IP-�����

    ������, ���� ���������� ������� � ��������� ����������, �� ������� � ������ ��������� ����� � ���� ��������. ��, � ���� ��� root, ����� ������������� ADB � ������� ������, �������������� ��������� ��� �������. �������� ��� ���:

    1. ���������� �������� � ������������� ��������.
    2. �������� ����� ������� � ���������� ��� �������������.
    3. ��������� �������, ��������� � ������� SDK/platform-tools � ��������� ��������� �������:

    ������������ � ��������� �� ����:

    $ adb connect IP-�����

    IP-����� ����� ������ ����� ���������: �� �������� (� ��������) > ����� ���������, ����� �IP-�����.

    3. ����������

    ����, ���� ���������� �� ������� ������� ����� �� ��������, � ������� ����� ���������� ��� � ��������� ���������� � �������� ����������� � ��������� ��� �������� �����. �� ���� ����� ���� ��������� ����������� ������� ����������, ����������� ��������� ��������� ����������, �������� ���������������� � ����� � �������� ���������. � ���� � ���������� ��� ���� (����� SDK ��� Dropbox � ���������� ������ ��� ������������� � �������� �����������), �� � ���������� ��� �������. ��� �� ������ � ����� ���������� �����?


    �������� ������ ������� ��������� � ��� Android Arsenal. ��� �� ������� ����������� ���, ��� ���� �����. �������� ������� ����� � ���������� �� ��������, ��� ������ ���������� ���� ����������, ��� �� ���������� � ������ �������, � ��� ����� � ������� ����������� ��� Android ������� ������ Gradle: ���������� �������� ����������� � ���� build.gradle ������� � ������� ���������� � ������ ������������.

    ��� ������ ���������� ���� ���������� �� �����������

    �������� ������ must have ��������� �� ������� �� ���� ��������. �� ���� �������, ��� �� ������ ������ ����� ����� ������� Dagger 2, RxJavaRetrofit. ���� ����������� �������������, �� ��� ��� ����� ������� � ������������� ���� ���������.

    4. ������ � �������

    �������, ������ ��� ��� ������ � ���� �������� �������������� ����������� ����������. ��� ������ �������� ������������ ��������� ��� �� ��� ���: ������ �����������, � ����� �������� ������, ������ �������� � ��������. ��������, ��� ������� �������� � ������� ������������, ������ � ������� �� ������ ��� ������ ������� ���������� ���� �����. ��� ������?

    �� ����� ���� ������ ����� �������������. ���� ������������� ���-������ Android Asset Studio, � ������� �������� ��������� �� ���� ����� �� �������� �������� ������ �� ���� ��������� �����������. � �������� ������ ����� ����� �������������� ����� ��������, ������ �������� ����� ���, ��� ����� �����, ������� �� ���������������� �������� ��������. ����� �� ������� ������ ����� ������ (�������, ����������, � ����� iOS. ), ����, ��������� ���� � ������ ���������. � ���������� � ����� ������������ �������� ����� ic_launcher.zip , ������� ���������� ���������� � ������� AndroidstudioProjects/���_����������/app/src/main/res . ����������� ������ ���-������, ����� �� ������ �Generate web icon�. ��� ���� �����������.

    �� ������ ��� ���-������

    ��� �� ������ ��������� ������� ������ ��� ActionBar�� � ������ ���������. ������� �������� ��� ��, ����� ����, ��� � ������ ��������� ����� ����� ��������� ������ � �������� �� ����� 15%.

    ����� ����, ���� ����������� ��� ���������� Feature Image. ��� ����������� ��������, ������� Play Market � ������ �������� ���������� ���������� � �������� ������ � ������� ����� ������ (����� ���������� �������� ���������� �� ���������). �� ����� ������������� � ������� ������� �������. ��� ���������� ���������� ����� ������������ ����������� ������ �� Google. �� ������� ������ ��������� ����� ���������.

    5. ����-�������

    ���������� ������, ������ ����, ��������� �������, ��� ������������. ������� ����� ������������, � ������, ��� �� �������, � ���������� ���������� ������� � ��������. �� ��� ��������: � ��������� �� ��� ���������� ������, � � ���� ��� �������� �������, � ��������� ��������, ��������� � �������, �� �� ������. ��� ������, ������� ������ ��������� ���� ������� logcat?

    ���, ��� ����� ������� ����-����������. ����� ���������� �������� ���������, � ��� ��� ��������� ���� � ��� �� ������� ������: � ���������� ������������ ��������� ����������, ������� � ������ ������� ���������� ��������� � ������ ������ � ������� � ���������� �� �� ������, � ����� ����������� ���-��������� ��������� �� �� ������ �������� � ��������� ������.

    ���� �� ����� ���������� ����� ������ � Fabric, ������ � ���������� ���������� � ������� Splunk MINT: �� ����������, ������� � ����� ������������� � ���������� (���������� �������� ����� ���� ������ ����). ����� ������ �� ������������, ���������� ���������� � ������� SDK, ������� ��� ����� � ������� ��� ���� �� Gradle. ��������� ���� build.gradle (���, ��� ��������� � ����������, � �� �� ����� �������) � ��������� ��������� ������:

    ����� ��������� ���-�������� Splunk MINT, �������������� � ��������� ����� ���������� ����� ������ ���������� (add app):

    ����� ����� Splunk MINT ������� ���� ������ ����, ������� ���������� �������� � ���:

    ����������� �������� ������ ����������

    ������� 1. ������������ � ���������� �Xakep.ru�, ����� ������ ��� ��������� �� �����

    �������� � ���������� � ������� ���������� ����� ������� ���� ������ �� ���� ���������� �������, �������� ������ ������������� ������ � �������� ����������� ���������������� ������� Xakep Score! ���������

    Android Studio 3.0 ������� �������� �AAPT2 error�

    ��� ������� ���������� ������ �������� ��� �������� ������ ����� ���������� Android Studio �� ������ 3.0 ������������ ������ ���������� ����:

    ������� ��� � ���, ��� ������ �� ��������� ������������ AAPT2 (Andro >

    ��� ���������� AAPT2 ���������� ������� ���� gradle.properties , ����������� � ����� �������, � �������� ������� andro >, ����� ���� �������������� ������ (File -> Synchronize ��� Crtl+Alt+Y).

    ����������� ������ ������� � ���, ��� ��������� ������������� AAPT2 � ������ ������ ������ �������� ������� � ������ �������, ��� ���� ������ ������ ����� ���� ��������� ���������� � �� ����, ��� � ������� � ������ �� �������.

    ������� ����������� ���� � ����� ���������, � �� ��������� �� �� �����. � ���� �� ��� ������ ������.

    ���� ������� ���� ������, �� ���������� ����, ��� ������ ������� � �������� ��������� � ���� � �����, � ������� ����� ������� gradle. ������� ��� � ���, ��� AAPT2 ������ ������ � ASCII ���������.

    ������������ ��� ���� ��������� �������:

    • ��������� ��������� File -> Settings (CTRL+ALT+S)
    • ���� ������� Build, Execution, Deployment -> Gradle
    • ������ ����, ����������� � ���� Service directory path, �� �����, �� ���������� ���������.

    ����� ����� � ����� �������� ������� �� �����, � ��� ������ ���� ������ ���������� ������: Build -> Make Project (CTRL+F9)

    How to Solve Android�s 13 Most Common Error Messages

    Testing is a crucial part of Android development, allowing you to iron out all the bugs, errors and performance problems that may be lurking in your app, before you unleash it on the general public.

    Every time you encounter an error, Android generates an error message, and then either displays that message as part of Android Studio�s Logcat Monitor or as a dialogue on the device you�re using to test your app.

    These error messages are typically short and to the point, and at first glance may not seem all that helpful. However, these messages actually contain all the information you need to get your project back on track�you just need to know how to decipher them!

    In this article, we�re going to take an in-depth look at the 13 error messages you�re most likely to encounter when developing any Android app. We�ll be scrutinising what each of these error messages really means, examining all the possible reasons why you might encounter each error and, most importantly, sharing step-by-step instructions on how you can resolve them.

    Spotting Error Messages

    There�s a wide range of error messages you may encounter when testing your app, ranging from severe errors that will cause your app to crash the very first time you try to install it on a target device to more subtle errors that degrade your application�s performance over time.


    Depending on the kind of error you encounter, Android will display the error message either on the device you�re using to test your app or in Android Studio.

    Spotting error messages that appear on a physical device or AVD is easy�you just need to be paying attention to any dialogues that appear on your device’s screen! However, spotting errors that appear in Android Studio can be tricky, as the Logcat Monitor records a huge amount of information, making it easy to miss important error messages.

    The easiest way to make sure you don�t miss out any error messages is to open Logcat Monitor�s Verbose dropdown and set it to Error, which will filter out everything except error messages.

    1. R.layout.main Cannot Be Found / Cannot Resolve Symbol R

    This error is caused when Andro >R.layout error, it�ll usually flag all your layout resource files as containing errors, which makes it difficult to know where to start looking for the source of the error.

    Often, the most effective solution is the simplest: clean and rebuild your project. Select Build > Clean Project from the Android Studio toolbar, wait a few moments, and then build your project by selecting Build > Rebuild Project.

    If a single clean/rebuild cycle doesn�t work, then try repeating this process a few times, as some developers have reported positive results after completing multiple clean/rebuild cycles in quick succession.

    If you encounter this error after moving some files and directories around, then it�s possible that the R.layout error is being caused by a mismatch between Android Studio�s cache and your project�s current layout. If you suspect this may be the case, then select File > Invalidate Caches / Restart > Invalidate and Restart from Android Studio�s toolbar.

    Issues with the names of your resources can also prevent the R.java file from being created correctly, so check that you don’t have multiple resources with the same name and that none of your file names contain inval >R.layout error across your entire project, even if you don�t actually use this resource anywhere in your project!

    If you do >R.layout error, then you may need to complete a clean/rebuild cycle before Android Studio properly registers your changes.

    2. Too Many Field References�.Max is 65,536

    When you compile your app, the APK contains executable bytecode files in the form of Dalvik Executable (DEX) bytecode files. The DEX specification states that a single DEX file can reference a maximum of 65,536 methods, and if you encounter the Too many fields� error then it means your app has gone over this limit. Note that this is a limitation on the number of methods your project references, and not the number of methods your project defines.

    If you encounter this error, then you can either:

    • Reduce the number of references in your project. One of the most effective ways of trimming your method references is to review your application�s dependencies, as these are often one of the biggest contributors of method references.
    • Configure your app to use more than one DEX file, by enabling multidex.

    The process of enabling multidex support will vary depending on the versions of Android your project supports.

    If you�re targeting Andro >multiDexEnabled to true :

    However, if your minSdkVersion is 20 or lower, then you�ll need to add the multiDexEnabled true attribute and then add the multidex support library as a project dependency:

    The next step depends on whether or not you�re overr >Application class.

    If your project does overr >Application > tag:

    If your project doesn�t overr >Application >MultiDexApplication instead:

    Finally, if you do overr >Application >attachBaseContext() method and calling MultiDex.install(this) , for example:

    3. Please Choose a Valid JDK Directory

    If you�re getting a JDK error whenever you try to build your app, then it means Android Studio is struggling to find where the JDK is installed on your development machine.

    To fix this error:

      Select File > Project structure� from the Andro >

    If this doesn�t solve the problem, then navigate back to File > Project structure� > SDK Location, and manually enter the full file path for your JDK. If you�re not sure where the JDK is installed on your development machine, then you can find out by opening the Terminal (Mac) or Command Prompt (Windows) and entering the following command:

    4. Error Installing APK

    While AVDs are great for testing your app across a wide range of different hardware and software, you should always test your app on at least one physical Android smartphone or tablet. However, Android Studio�s ability to recognize a connected Android device is notoriously hit and miss.

    If you�ve attached your device to your development machine but are encountering an Error installing APK message whenever you try to install your APK, or your device isn�t even appearing in the Select Deployment Target window, then try the following fixes:

    Check USB debugging is enabled.

    Open your device�s Settings, then select Developer Options, and make sure USB Debugging is enabled. If you don�t see Developer Options in the Settings menu, then select About Phone and keep tapping Build Number until a You are now a developer notification appears. Return to the main Settings screen, and you should find that Developer Options has been added.

    Check your smartphone or tablet�s screen.

    Sometimes your device may require some additional input before it connects to your development machine. For example, it may be asking you to choose between different modes, or to explicitly authorize the connection.

    Make sure you have the correct USB driver installed.


    If you’re developing on Windows, then you�ll need to download the appropriate OEM USB driver for your device. If you�re a Nexus user, then you can download the Google USB driver through Android Studio�s SDK Manager.

    Check that your device meets your project�s minimum SDK requirements.

    You�ll find your project�s minimum SDK in your module-level gradle.build file, and can check what version of Android is installed on your device by opening its Settings and swiping to the About Phone section.

    Try restarting your adb (Android Debug Bridge) process.

    Open a Terminal or Command Prompt window, and then change directory ( cd ), so it�s pointing at your platform-tools window, for example:

    Then, terminate and restart the adb process by entering the following commands, one after the other:

    Restart everything!

    If all else fails, then try disconnecting and then reconnecting your device, restarting your device, restarting Android Studio and, as an absolute last resort, restarting your development machine.

    5. INSTALL_FAILED_INSUFFICIENT_STORAGE

    If you encounter this error when attempting to install your project, then it means the target device doesn�t have enough memory.

    If you�re trying to install your project on an AVD, then you should check how much space you�ve assigned this particular AVD:

    • Launch the AVD Manager.
    • Find the AVD in question, and click its accompanying Edit this AVD icon.
    • In the window that appears, click Show Advanced Settings.
    • Scroll to the Memory and Storage section.

    This section lists the various types of memory you’ve allocated to this particular AVD. If any of these values are unusually low, then you should increase them to more closely reflect the memory that�s available to your typical Android smartphone or tablet:

    • RAM. The amount of RAM available to the emulated device.
    • VM Heap. How much heap space (i.e. memory) is allocated to the Virtual Machine (VM) of the emulated smartphone or tablet.
    • Internal Storage. The amount of non-removable memory available to the emulated device.
    • SD card. The amount of removable memory available. If you want to use a virtual SD card that�s managed by Android Studio, then select Studio-managed and enter the size of the virtual SD card you want to create (the minimum recommended value is 100 MB). Alternatively, you can manage the SD card �space� in a file, by selecting External file and then specifying the location you want to use.

    If there�s nothing odd about your AVD�s memory, or you�re trying to install your app on a physical Android smartphone or tablet, then this error usually means that your compiled app is simply too large. An application that takes a significant bite out of the device�s memory at install time is never going to go down well.

    If you need to dramatically reduce the size of your APK, then try the following techniques:

    Use ProGuard to remove unused classes, fields, methods, and attributes. To enable ProGuard, open your module-level build.gradle file and add the following:

    Optimize your libraries. Try to remove any unnecessary or memory-intensive libraries from your project. If you do need to use a large library, then check whether there�s any way you can optimize this library for the mobile environment, as external library code often isn�t written with mobile in mind. You should also bear in mind that many libraries contain a large amount of localized strings. If your app doesn�t officially support these libraries, then you may be able to reduce the size of the library by telling Gradle not to include these strings in your compiled APK. To specify the languages that your app officially supports, open your module-level build.gradle file and use the resConfigs attribute. For example, here we�re specifying that we want to include only English-language strings in our project:

    Cons >xxxhdpi assets! One of the most effective ways of reducing the size of your APK is to separate it into multiple APKs, so when the user downloads your app, they�ll receive an APK that contains only the code and resources that make sense for their particular device. You�ll find more information on creating APKs that target different screen densities and specific ABIs (application binary interfaces) over at the official Android docs.

    6. ActivityNotFoundException

    An ActivityNotFoundException occurs when a call to startActivity(Intent) or one of its variants fails because the Activity can�t execute the given Intent .

    The most common cause of an ActivityNotFoundException is forgetting to declare an activity in your manifest, so open your manifest and check that you�ve declared all your activities. You should also check that you�ve declared each activity correctly, using either a fully qualified class name or a full stop as a shorthand for the package name. For example, both of the following are valid:

    If you can�t spot any problems with your manifest, then there are a few other potential causes of ActivityNotFoundExceptions . Firstly, if you encounter this error after moving an Activity class from one package to another, then it�s possible that you�ve confused Android Studio and just need to clean and rebuild your project.

    An ActivityNotFoundException can also be caused if an error in the target Activity is not loading correctly. To check whether this is occurring in your project, put your intent code inside a try-catch block:

    Run your application again, and then take a look at Andro >ActivityNotFoundException , too.

    7. ClassCastException

    The ClassCastException error is related to Java�s type conversion feature, which allows you to cast variables of one type to another. You encounter a ClassCastException when you try to cast an object to a >ClassCastException :

    This error message contains information about the line that�s causing the ClassCastException error, so navigate to this part of your project, check what objects are being cast there, and resolve any mismatch.

    If you can�t spot a problem with your casting, then cons >Views around in your layout resource files, as some users have reported encountering a ClassCastException after rearranging their Views . If you suspect this may be the cause of your ClassCastException , then tell Andro >ClassCastException .

    8. NullPointerException

    In Java, when you declare a reference variable, you�re actually creating a pointer to an object. You can declare that an object is currently pointing at an unknown piece of data by assigning a null value to that object�s reference. Null values can be useful in coding some design patterns, but if you encounter a NullPointerException (NPE) then it means that you�ve tried to use a reference that�s pointing at a null value, as though it were referencing an object. Since there�s no code to execute in the location where this reference is pointing, you wind up with an NPE.

    An NPE is usually accompanied by information about where this exception was caught, so the Logcat Monitor should contain the exact line where this error occurred. Navigate to this area of your project and identify the reference that equals null. You’ll then need to find the location where the value should be set, and set it.

    The findViewById method can also return null if the requested View can�t be found, so if your NPE is occurring in a line that contains a findViewById , check that you�ve initialized the layout that contains this View . Also be on the lookout for any spelling mistakes or typos that may have crept into your findViewById call, as these can also result in an NPE.

    To avoid NPEs occurring in your project, make sure all your objects are initialized before you attempt to use them, and always verify that a variable isn�t null before you request a method or field from that object.


    9. Application Not Responding Error

    This is an error that appears as a dialogue on the Android device or AVD you�re using to test your app. The Application Not Responding (ANR) error occurs when your app�s UI freezes and remains unresponsive to user input for more than five seconds. This usually happens because your app is trying to perform lengthy or intensive operations on Android�s main UI thread.

    In Android, the main UI thread is responsible for dispatching all user input events to the appropriate UI widgets, and for updating your app�s UI. However, this thread can only process one task at a time, so if you block the main thread with any long-running or intensive operations, then your UI will be completely unresponsive until this task is complete.

    If you encounter an ANR message while testing your app, then you definitely need to take a look at the work you�re performing on the main thread. However, if you don�t explicitly encounter this error but notice that your app sometimes feels sluggish or laggy, then this is an indication that you�re on the verge of an ANR error, and once again you should take a look at the state of your UI thread.

    To resolve ANR errors (and near-ANR errors), you need to identify all the operations that have the potential to run slowly, or that require significant processing power, and then move them off the main thread. You do this by creating a worker thread where these operations can be performed with zero risk of blocking the main UI thread.

    There are several methods of creating additional threads, but the simplest solution is to use an AsynTask , as this >onPostExecute() callback that you can use to communicate with Android�s main UI thread.

    However, AsyncTasks are better suited to performing short background operations, so if you need to perform a long-running operation, then you should use a Service or an IntentService instead.

    Although moving long-running and intensive tasks off the main thread will have the most impact on your app�s performance, it�s best practice to perform as little work as possible on the main UI thread. Even running a small amount of unnecessary code on the main thread can have an impact on your app�s responsiveness, so once you�ve successfully relocated all of your long-running and intensive operations, you should look at whether there�s any more code that you can move off the main thread.

    10. Only the Original Thread That Created a View Hierarchy Can Touch Its Views

    In Android, you can update your UI from the main thread only. If you try to access UI elements from any other thread, then you�re going to encounter this error.

    To resolve this issue, >runOnUiThread , for example:

    Alternatively, you can use a handler or perform your background work in an AsyncTask, as you can communicate with the main thread using AsyncTask�s onPostExecute() callback method. Finally, if you find yourself regularly switching between threads, then you may want to look into RxAndroid, as this library allows you to create a new thread, schedule work to be performed on this thread, and then post the results to the main thread, all with just a few lines of code.

    11. NetworkOnMainThreadException

    This exception is thrown when your app attempts to perform networking operations on the main thread, such as sending API requests, connecting to a remote database, or downloading a file. Since network operations can be time-consuming and labour-intensive, they are highly likely to block the main thread, so Android 3.0 (Honeycomb) and higher will throw this error whenever you attempt to make a network request on the main thread.

    If you do encounter a NetworkOnMainThreadException , then find the networking code that�s running on your main thread, and move it to a separate thread.

    If you do need to make frequent networking requests, then you may want to take a look at Volley, an HTTP library that initiates its own background threads so that all networking requests are performed off the main thread by default.

    12. Activity Has Leaked Window That Was Originally Added Here

    This error occurs when trying to show a dialogue after exiting the Activity. If you do encounter this issue, then open your Activity and make sure you�re dismissing the dialogue properly, by calling dismiss() in either your Activity�s onDestroy() or onPause() method, for example:

    13. OutofMemoryError

    This error occurs when your app makes a memory request that the system can�t meet. If you encounter this error message, then start by ruling out all of the most common memory management mistakes. Check that you�ve remembered to unregister all your broadcast receivers and that you�ve stopped all of your services; make sure you�re not holding onto references in any static member variables, and that you�re not attempting to load any large bitmaps.

    If you�ve ruled out all the obvious causes of an OutOfMemoryError , then you�ll need to dig deeper and examine exactly how your app is allocating memory, as chances are there are a few areas where you can improve your app�s memory management.

    Android Studio has a whole area dedicated to helping you analyze your app�s memory usage, so start by selecting View > Tools Window from the Android Studio toolbar. At this point you�ll see either an Android Monitor or Android Profiler option, depending on the version of Android Studio you have installed.

    We�ve discussed working with the Memory Monitor on this website before, but since Android Profiler is a new addition to Android Studio, let�s take a quick look at its major features.

    When you open Android Profiler, it starts recording three pieces of information automatically.

    Since we�re interested in the way our app is using memory, give the Memory section a click, which will launch the Memory Profiler.

    The Memory Profiler consists of a timeline that displays the different kinds of memory currently being allocated by your app, for example Java, native, and stack. Above this graph you�ll find a row of icons that you can use to trigger different actions:

    • Force a garbage collection event.
    • Take an Hprof snapshot of the application memory. This is a snapshot of all the objects in your app�s heap, including the kind of objects your app is allocating, the number of allocated objects, and how much space these objects are taking up.
    • Record memory allocations. By recording your app�s memory allocations while performing certain actions, you can >

    To >OutOfMemoryError , spend some time interacting with your app, and monitor how your app�s memory allocations change in response to different actions. Once you�ve identified the section of your project that�s causing the problem, spend some time scrutinising it for any memory leaks, as well as any inefficiencies in the way it�s using memory.

    Conclusion

    In this article we looked at 13 of the error messages you�re most likely to encounter when developing for Android. We discussed all the different factors that can contribute towards these errors, and the steps you need to take to resolve them.

    If you�re being plagued by an error message that we didn�t cover, then your first step should be copy/pasting the entire error message into Google, as this will often turn up threads and blog posts where people are discussing how to solve this particular error.

    And, if you can�t find a solution anywhere on the web, then you can always reach out to the Android community for help directly, by posting your question to Stack Overflow.

    While you’re here, check out some of our other posts on Android app development!

    Ready Android

    Pursuing Perfection Passionately

    Thanks to


    • 351,558 star views

    Evergreen Posts & Pages

    Nice to see u :)

    Error � Please select Android SDK; App edit configuration error: Android Studio

    Error � �Please select Android SDK�; Not able to run the app

    Origin of the error �

    This dialog opens up when I click on app �Edit configuration�:

    Here you can see Error: Please select Android SDK with the red icon.

    Android Studio — ������: ��� ��������� ��� ������������

    ����� � ������� �������������� ���, �� Android Studio 3.0.1 ���������� ��������� ������.

    ��� ��������� ��� gradle script, ����� ��������� ������?

    �������� ��� � ���� ������ build.gradle file

    � ���� ������ ���� ����� �� ��������, ������� � �������� ��������, ������� ��������� ��� ����. ��� ������ ����:

    Program type already present: org.json.CDL

    � �� ����� ���������� ����� ����, ��� � ������� compra acra � ��� ���� gradle. ����� �������, ������� ���� �������� acra ��������� �������:

    ��� ��� � ������ OP ������� ���� �� �����, ����� �� ��� ������������ ��� ����������� com.squareup.picasso � ���������, ��� � ���� ����.

    ��������� ������ ���������� � ���������� ������ ����������. � ������� ��� �� ������, ����������� � ������� API, � ������� � �������� ���� ������. ��� ��������� �������� ��� ����.

    � ���������� � �������� ��������� ������� ��� �������� APK ����� ����, ��� ������� Android Studio �� 3.1.2 � targetSdkVersion �� 27. ��� ��� ���� �� ���.

    ��� ������ �������� ������ ������. Program type already present: me.leolin.shortcutbadger.Badger

    ������ � ������ ���������������� ���, � �� ������������� ������.

    ���������� �������������� ������ ����������. ���� �� ����������� ����� ����� ������ Android Studio, ��� ����� ������������� ��������� �� ������. ������ ��������� �������������� ������ ��� �������� ������ ����������, � ��� ����� � �������.

    �������� �����������, ������������ ����

    ������, ��������, ��� �� ���� ����, �� ��� ��������� ������� �� ���������� ����� � ��������� ��������

    � ������ ����������. ����� � ������������� ���� ���������� gradle ����� �������, ����� ������� ���� aar ������ apk [i.e. apply plugin: ‘com.android.library’ ], ����� ����������� ����� ��������� �� �������, ������� ������ ���� ���� ������� �������� �����������

    ����� — � �������� ���������� — � ���������������� ������, ������� � ���������� � ���� aar, � ������� � ������ ���������� ���� aar, ��������� ��

    � ���� ������ � ������� �� �� ������

    ��������� Error:Program type already present ������� ��� ������, ��� ��� �������� ������������� ��� ������ ������� Android Studio, ������� �������� ����������, ������ ��� � ��� ���� ���������� ��� ������. ������� � ������������ ���, � ����� �������� ���� aar � ����� ������� ���� «�����» ���� � ������ Android Studio, ������ apk

    ������ ������� ������

    prolisk � 19 ��� 2020, 23:54

    ����� ����� �����������?

    �.�. ������� ����, ����� �������� ������������� �� ����. ���� ��������������.

    k0ttee � 20 ��� 2020, 06:52

    ��������: ��������������: �� ������� ��������� ���� �� ����� ‘D:\android-locat/D:\Android Studio\plugins\android\lib\device-art-resources/nexus_5/layout’, ����� ����������� ����������

    >>>> ��, ��� � ������� ������, ��� �������� ���-��?


    ��������: ��������������: ������������� ����������� ���� � SD �����: C:\Users\Администратор\.android\avd\Nexus_5_API_22.avd\sdcard.img

    >>>> � ��? ����� �������������� ������������ ��� ���������?
    >>>> �������� ������ ������ ���� �������� ���������, ������ ���� �� � �����-������ base-64 �����������.

    ��������: ��������������: �������� ����������� x86 ��� ������� �������� ��������� ���������� ���������!

    �������, ����� ��, �������� ��, ��������� Intel HAXM.
    ������ CPU-����������: ������ ���� HAX �� ����������!

    >>>> ���� ��������� ������ ����� �������� � ���������� ���������� ��� ������. ������� ���������!

    Google Android — ��� ��������

    ����� ���������� �� ����� �����

    • ���� ��� �������
    • �������� ����
    • �����

    ������ ������� Andro > ��������

    ������ ������� Andro > ������

    ��������� fruzo � 29 ��� 2014, 09:38

    Re: ������ ������� Andro > ������

    ��������� Mikhail_dev � 29 ��� 2014, 11:31

    Re: ������ ������� Andro > ������

    ��������� fruzo � 30 ��� 2014, 19:26

    Re: ������ ������� Andro > ������

    ��������� Mikhail_dev � 01 ��� 2014, 08:32

    Re: ������ ������� Andro > ������

    ��������� Makso � 01 ��� 2014, 12:16

    � ���� � ��������� ���� �������� � HTTP. ���� �� ������ ����� ������, � ����������, ��� �������� � ���.

    — ���� � ���������� �������� HTTP Proxy ���������� � No proxy, �� ������ �����:
    Failed to sync Gradle project ‘MyApplication’. Error: Unknown host services.gradle.org

    — ���� � � ���������� �������� ������, ����, �������� ������ � ������ (������ � ����� ����������� �������� ������), �� ������:
    Gradle ‘MyApplication’ project refresh failed. Error: Authentication failure

    ���������, ������� ������� ������ ������, ���� �� ��� ������, �� ���� � ���, ��� � ���� �� ���� ��� �� ��������� ��� ������ ��������. ������ ��������� �� ����� ����� � ��� �������� �� ������ ������.

    �� � ��� ������ � ���� ����� �����, ��� ��� ��������� ������ � �������������� ������ � �������� ��, � ��� �� ��������� ���� ����������� �����������? ����� Gradle User Guide �����, �� ������� ���� ��������� ������, �� ��� ��� �� �������.

    Android Studio: ������� ���������� �� �������: ������?

    ����� � ������� �������� Android Studio , �������� ������������ ������ � ������� Run , � ������� ��������� �� ������ Error running app, No target device found . � ���� ���� ��� Samsung � ADB debugging enabled . �� ��������� ������������ � ������� ������� adb devices , � �������� ADB �������� ���������. � �������� adb start-server ��� �������. ��� �� �������, ���� � ������� �������� ���������� «�������», � ����� «���������», �� ������� ��������, �� � �� �������, ������ ���� ������������ ��� ���������. ������ StackOverflow ������ �������, ��� ��� ������ «������������� ������������», �� ��� �� ���������� ������������ ��������. � �������� AS V3.01 . ����� ���������?

    1 �����

    � ����� ���� ��������. � ������� Run- > EditConfigurations- > DeploymentTargetOptions, � ������ ���������� USB (��� ������� �������� USB-�����������, �����?). �� noooo, ����� � ������� Open Select Deployment Target Dialog, ��� ������. ����� ����, �������� ������������ �� �� ����� ���������� ��� ������� �������� ��������� ������� ������, � ��� ��� ������.

    Понравилась статья? Поделиться с друзьями:
    Все языки программирования для начинающих