Tag Archives: Android studio

Re installing Android studio always fails to install SDK when installing software (solution)

**

Android studio cannot install the SDK when the software is installed

**
I don’t know what’s going on. Android’s AVD can’t be started. It’s stuck in the loading place all the time, indicating that it can’t respond. No matter it’s forced to shut down AVD or recreate one, it can’t be solved, so I decided to reload Android studio. However, when I uninstall Android and delete all the files and then install Android studio again, it always shows that the SDK has been installed and the project cannot be started because there is no SDK. As shown in the figure

finally, with the help of the teacher, I can use the new Android studio again!! Tearful eyes
specific operation:

    uninstall the current Android studio and delete the SDK, gradle, AVD and other folders in the installation directory. Find the. Android studioxxxx and. Gradle folder in the computer user directory, and then delete them. Go to the hidden appdata folder, go to the roaming folder, and then go to the Google folder to delete Android studio XXX. Everyone’s catalog may be different. The last and most important step: restart the computer( I just didn’t restart, so every time I reload, I will display SDK installed Installing Android studio is the same as installing it for the first time. Ha ha

After Android studio creates a new bottomnavigationactivity, there is a blank solution in the upper area of fragment

Problem description

For example, the screenshot is as follows, which is often empty above and incomplete below (recyclerview list) (blocked by the navigation bar at the bottom)

Problem solving ideas

After switching to another fragment, it is found that it is also lower than the whole, so it should be the whole setting problem, so the problem is located to activity_ Main.xml or mobile_ In navigation. XML, which is used to specify the newly created fragment, it turns out to be an activity_ Main.xml specifies mobile_ There’s a problem with navigation’s fragment.

Problem solving

At activity_ In main.xml

    deleting the paddingtop attribute of the outermost constraintlayout will @ + ID/NAV_ host_ Layout of fragment_ Height is set to 0dp

    result


Could not install Gradle distribution

Could not install Gradle distribution

New computer, new Android studio 4.2, new first project error:

Could not install Gradle distribution from 'https\://services.gradle.org/distributions/gradle-6.7.1-bin.zip'

Solution:
(1) click the link in the error message:
1 https://services.gradle.org/distributions/gradle-6.7.1-bin.zip
Download the compressed package to the specified path and unzip it
(2) click file – & gt; Settings-> Build, Execution,Deployment-> Build Tools-> Gradle, in the gradle projects area, change use gradle from to your own download path, retry:

(3) Successful solution:

Gradle tasks disappeared after upgrading Android stuido 4.2?

Recently, many people asked that after upgrading Android studio 4.2, tasks could not be seen in the gradle window

Before 4.2
4.2, there were only dependencies and no tasks

The answer is found in the official issue:

https://issuetracker.google.com/issues/185420705

Gradle task list is large and slow to populate in Android projects. This feature by default is disabled for performance reasons. You can re-enable it in: Settings | Experimental | Do not build Gradle task list during Gradle sync.

Gradle tasks is closed by default due to performance problems. You can open it in the following ways:

File -> Settings -> Experimental

Remove the check below

Do not build Gradle task list during Gradle sync

After re engineering sync, you can see gradle tasks.

Flash back problem when Android studio plays music in sdcard through intent

Code

Add a button in the layout file, set listening events for button in the main class, and play music through intent

1. Write activity_ main.xml

<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    android:orientation="vertical" >
    
    <Button
        android:id="@+id/btn_click"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:layout_margin="10dp"
        android:gravity="center"
        android:padding="8dp"
        android:text="@string/click4" />

</LinearLayout>

2. Import music into virtual machine

There is a device file explorer in the lower right corner of Android studio. After opening, you can see the file directory of the virtual machine. Find/MNT/sdcard/music, right-click upload and select the music to be imported. The file name should not appear in Chinese

3. Write mainactivity.class

package com.ch5_2;
import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.View;

import java.io.File;

public class MainActivity extends Activity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        
        findViewById(R.id.btn_click4).setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                intent.setAction(Intent.ACTION_VIEW);
                //Get the file path, the path is the virtual machine memory card path
                Uri data = Uri.fromFile(new File("/mnt/sdcard/Music/nogoodbye.mp3"));
                intent.setDataAndType(data,"audio/*");
                startActivity(intent);
            }
        });
    }
}

Questions

1. Flashback

Here, the version of the virtual machine will affect the operation. If the version is too high, it will flash back. I used to use Android 11.0, but as soon as I click button, it will flash back. The reason should be the compatibility problem. Change to a lower version

here is Android 5.0

2. This file type problem is not supported

When changing to a lower version of the virtual machine, you may encounter the problem that Android music playing software does not support this type of file. I used MP3 file at the beginning, and the result shows that it does not support it. It’s OK to change to WAV format.

Android studio Error:Execution failed for task ‘: app:transformResourcesWithMergeJavaResForDebug ‘

Android studio error Error:Execution failed for task

Recently, when doing the face recognition check-in system based on Android platform, after importing the third party’s lib package, Android studio reported the following error:

Error:Execution failed for task ‘: app:transformResourcesWithMergeJavaResForDebug ’.
com.android.build . api.transform.TransformException : com.android.builder . packaging.DuplicateFileException : Duplicate files copied in APK META-INF/LICENSE
File1: E:\Workspaces\Swface\app\libs\httpcore-4.4.4.jar
File2: E:\Workspaces\Swface\app\libs\httpclient-4.5.2.jar

After consulting the data, it is found that there are duplicate contents loaded in the meta-inf directory of the jar package. Open the corresponding jar package
sure enough, both of the two jar packages have license, and further Click to find that the contents are exactly the same. However, it seems that the next three files are also duplicate (only there is no clear prompt in the error report), so we can solve them all at once
all Now that we know that it is caused by repeatedly loading files, the solution is to remove the repeatedly loaded files during compilation. The specific operations are as follows:

    1. Open app\ build.gradle File
    1. 2. Modify the configuration as follows:
buildTypes {
          ...... (omit part of the code)
          // Add the following code here
          packagingOptions {
            exclude 'META-INF/DEPENDENCIES'
            exclude 'META-INF/NOTICE'
            exclude 'META-INF/LICENSE'
            exclude 'META-INF/LICENSE.txt'
            exclude 'META-INF/NOTICE.txt'
            exclude 'META-INF/ASL2.0'
            exclude 'META-INF/notice.txt'
        }
 }       
``

3. Rebuild project

A link to the original text is attached

http://stackoverflow.com/questions/34031395/errorexecution-failed-for-task-apptransformresourceswithmergejavaresfordebug

Android studio upgrade 4.1 plug-in error

reason

The plugins plug-in failed

terms of settlement

1. Delete plug-in
user directory

\AppData\Roaming\Google\Android studio4.1\plugins

Find the directory and delete the corresponding plug-in
uninstall butterknife zelezny and install Android butterknife injections (support kotlin)
uninstall gsonformat and install gsonformatplus

2. The code is not highlighted and the error is not red

Errors don’t pop up, and they don’t pop up without this layout (I have already solved this problem)
don’t create an XML file according to the prompt

3. Code writing does not prompt

Click the file in the upper left corner to find the power save mode. If it is checked, you can cancel the check and restart studio.

Android studio reported an error, Error:SSL peer shut down incorrectly

When we import projects with Android studio, we often encounter all kinds of errors, resulting in the project not running.

Recently, I have encountered a problem. What’s wrong Error:SSL peer shut down incorrectly

After checking, it seems that we have to change various configuration files, which is very troublesome.

I took a look at it right here

Compare with the local project that can be compiled normally, change the parameters.

Then it’s ready to run.

An error is reported after Android studio creates a new virtual machine. Emulator: emulator: error: unknown AVD name

Background: after Android studio is installed, a new virtual machine is created, and then it runs normally for the first time, and then it runs with two errors:
1. Emulator: emulator: error: unknown AVD name, use – list avds to see valid list.
2. Emulator: process finished with exit code 1
search the Internet for the problem, and find the following solution: save a note.
Original source: https://blog.csdn.net/xiaoxiao133/article/details/79819532
Abstract:
Open AVD manager, or you can find

in the menu bar tools, and then click Show on disk in the inverted triangle on the right

the picture is from the original blog Then jump to the folder of your virtual machine and copy the previous path. Take the original blog map as an example:
* * C: (users/administrator) \ *
just use the previous path (all the previous paths of Android include “\”)

and then go to Android in the computer environment variable_ SDK_ Under home

* add Android_ SDK_ The value of the home variable is changed to the path that was copied just now, C:: Restart Android studio!!
Thank you again for understanding Android_ SDK_ Environment variable of home!
Please contact me to delete it.

Android studio error Error:Could not Determine java version from ‘9.0.4’

The beginning of the matter is to export an APK with signature package and report an error Error:Execution failed for task ‘: app:compileReleaseJava ‘& gt; cannot find sys

At that time, my default setting location did not point to the correct JDK path, so an error was reported. Since I haven’t found my previous JDK for a long time, I went to the next version of JDK (9.0.4). Please pay attention to the latest version.

Then I try to export again and report an error: Error:Could not Determine java version from ‘9.0.4’

Then try again and continue to report errors Error:Gradle version 2.2 is required. Current version is 4.6. If using the gradle wrapper, try editing the distributionUrl in /Users//Desktop/gradle/wrapper/gradle- wrapper.properties to gradle-2.2- all.zip … because of the error caused by the inconsistency between the gradle version and the gradle version of as, modifying the gradle configuration file (there are many detailed solutions on the Internet) is of no use to me… Because after the change, an error is reported: could not initialize class com.android.repository . api.RepoManager Well, I gave up.

I began to think about why I encountered this series of problems at the beginning, right! Because of the latest version of JDK! So, I went to download a 1.8.0 JDK (download address), download and install it, change the JDK location of Android studio (Figure), and then gradle changed back to the old version, APK signature package export, success!!

So why should I download the latest JDK?:)