Problems when learning android

Preface
Some of the problems and solutions I encountered when I first started learning android, record them.
1. When the compiled version of android is inconsistent with the actual api version, an error will be reported.

2. Need to find matching slf4j and log4j

3. Three ways to add jar package in android project

4. There is no response to clicking the button, the solution: after finding the button, btn.setOnClickListener() is fine

5.报错:java.lang.ClassNotFoundException: Didn’t find class “android.view.View$OnUnhandledKeyEventListener” on path: DexPathList[[zip file "/data/app/com.examp

Because androidx is supported from Android9.0 (API 28), if the project uses androidx but runs on a device lower than API 28, it will appear;

So just change the lower version api to a higher version.

  1. Process: com.example.evprac, PID: 11190
    java.lang.IllegalStateException: WebSocketClient objects are not reuseable
    

    The above error occurred when using webSocket. The reason is that the connection has already been made during initialization.

    switch (v.getId()) {
          
          
       case R.id.lg_login:
            if (webSocketClient.isClosed() || webSocketClient.isClosing()) {
          
          
                Snackbar.make(v, "Client正在关闭", Snackbar.LENGTH_SHORT).show();
                //webSocketClient.connect();
                webSocketClient.reconnect();
                break;
            }
            System.out.println("发送给后端的信息是"+username.getText().toString().trim());
            webSocketClient.send(username.getText().toString().trim());
            break;
    
        default:
            break;
    
    }
    

The solution is to change webSocketClient.connect(); to webSocketClient.reconnect();

java.lang.UnsupportedOperationException: Binary XML file line #7: You must supply a layout_width attribute.

This is because my own layout file does not specify the layout_width attribute. For example, my problem is that the layout_width attribute and layout_height attribute are not specified in the textView. As long as the problem is specified, the problem will be solved.

  1. wrong 2nd argument type found 'android.app.Fragment.' required 'Android.support.v4.app.Fragment'
    

    This is because of the bug in the guide error, you only need to change it to the required package.

    9. A few words that are difficult to spell in android (ignore, I don’t know why I wrote this at the time)

    10. This is the error that occurs when I want to call the method of the custom class in the button. There is no solution yet.

    Listener class android.view.View.OnClickListener with method onClick did not match signature of any method onClickUtil::onClickWithMe
    
    Cause: couldn't make a guess for com.example.androidmvvm.utils.onClickUtil
    

    12. When setting the weight attribute, be sure to set the width or height attribute to 0dp

    13. When the android project uses lamda expressions, it says that version 7 does not support lamda expressions

    Solution: hold down the alt+enter key, then select set language level to 8

    14. The previously installed HAXM suddenly needs to be reinstalled. Open the log file of the failed installation (on the C drive), and find that the previous problems have appeared again. The CPU has not been set to virtualization. You need to restart the computer and set the virtualization (bios- >system options).

    15. Because the Android project used JDK7 before, and then I changed to jdk8, this error occurred: app:compileDebugJavaWithJavac , solution: In the project structure, it is no problem to replace jdk with version 1.7 embedded in android up.

    16. If after importing dependencies, it is still popular and the package cannot be imported, you can click build→rebuild

    17. The following code is in that activity, and that activity is the first startup item

    <intent-filter>
        <action android:name="android.intent.action.MAIN" />
    
        <category android:name="android.intent.category.LAUNCHER" />
    </intent-filter>
    

18. androidx is supported from API28. If androidx is used in the project, you should pay attention to the version issue.

Didn't find class "android.view.View$OnUnhandledKeyEventListener" on path: DexPathList[[zip file "/data/app/com.example.mvvm-1/base.apk"],nativeLibraryDirectories=[/data/app/com.example.mvvm-1/lib/x86, /system/lib, /vendor/lib]]
        at java.lang.Class dalvik.system.BaseDexClassLoader.findClass(java.lang.String) (BaseDexClassLoader.java:56)

19. Set the click event in the button of the fragment, but after clicking the button, the effect that should appear does not appear, but an error is reported.

This is because there is no way to implement the click event.

E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.example.cardemo1, PID: 8599
    java.lang.IllegalStateException: Could not find method logoutDialog(View) in a parent or ancestor Context for android:onClick attribute defined on view class androidx.appcompat.widget.AppCompatButton with id 'Logout'
        at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.resolveMethod(AppCompatViewInflater.java:424)
        at androidx.appcompat.app.AppCompatViewInflater$DeclaredOnClickListener.onClick(AppCompatViewInflater.java:381)
        at android.view.View.performClick(View.java:5610)
        at android.view.View$PerformClick.run(View.java:22265)
        at android.os.Handler.handleCallback(Handler.java:751)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6077)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:866)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:756)

20. This problem has not been resolved

W/oxconn.cardemo: Accessing hidden field Landroid/view/animation/Animation;->mListener:Landroid/view/animation/Animation$AnimationListener; (greylist-max-p, reflection, denied)
E/FragmentManager: No field with the name mListener is found in Animation class
    java.lang.NoSuchFieldException: No field mListener in class Landroid/view/animation/Animation; (declaration of 'android.view.animation.Animation' appears in /system/framework/framework.jar!classes3.dex)
        at java.lang.Class.getDeclaredField(Native Method)
        at androidx.fragment.app.FragmentManagerImpl.getAnimationListener(FragmentManager.java:1301)
        at androidx.fragment.app.FragmentManagerImpl.setHWLayerAnimListenerIfAlpha(FragmentManager.java:1283)
        at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1811)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1852)
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2426)
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2372)
        at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
        at androidx.fragment.app.FragmentManagerImpl$1.run(FragmentManager.java:733)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
W/oxconn.cardemo: Accessing hidden field Landroid/view/animation/Animation;->mListener:Landroid/view/animation/Animation$AnimationListener; (greylist-max-p, reflection, denied)
E/FragmentManager: No field with the name mListener is found in Animation class
    java.lang.NoSuchFieldException: No field mListener in class Landroid/view/animation/Animation; (declaration of 'android.view.animation.Animation' appears in /system/framework/framework.jar!classes3.dex)
        at java.lang.Class.getDeclaredField(Native Method)
        at androidx.fragment.app.FragmentManagerImpl.getAnimationListener(FragmentManager.java:1301)
        at androidx.fragment.app.FragmentManagerImpl.animateRemoveFragment(FragmentManager.java:1638)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1548)
        at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1861)
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2426)
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2372)
        at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
        at androidx.fragment.app.FragmentManagerImpl$1.run(FragmentManager.java:733)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)
W/oxconn.cardemo: Accessing hidden field Landroid/view/animation/Animation;->mListener:Landroid/view/animation/Animation$AnimationListener; (greylist-max-p, reflection, denied)
E/FragmentManager: No field with the name mListener is found in Animation class
    java.lang.NoSuchFieldException: No field mListener in class Landroid/view/animation/Animation; (declaration of 'android.view.animation.Animation' appears in /system/framework/framework.jar!classes3.dex)
        at java.lang.Class.getDeclaredField(Native Method)
        at androidx.fragment.app.FragmentManagerImpl.getAnimationListener(FragmentManager.java:1301)
        at androidx.fragment.app.FragmentManagerImpl.setHWLayerAnimListenerIfAlpha(FragmentManager.java:1283)
        at androidx.fragment.app.FragmentManagerImpl.animateRemoveFragment(FragmentManager.java:1659)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1548)
        at androidx.fragment.app.FragmentManagerImpl.moveFragmentToExpectedState(FragmentManager.java:1784)
        at androidx.fragment.app.FragmentManagerImpl.moveToState(FragmentManager.java:1861)
        at androidx.fragment.app.FragmentManagerImpl.executeOpsTogether(FragmentManager.java:2426)
        at androidx.fragment.app.FragmentManagerImpl.removeRedundantOperationsAndExecute(FragmentManager.java:2372)
        at androidx.fragment.app.FragmentManagerImpl.execPendingActions(FragmentManager.java:2273)
        at androidx.fragment.app.FragmentManagerImpl$1.run(FragmentManager.java:733)
        at android.os.Handler.handleCallback(Handler.java:938)
        at android.os.Handler.dispatchMessage(Handler.java:99)
        at android.os.Looper.loop(Looper.java:223)
        at android.app.ActivityThread.main(ActivityThread.java:7656)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:592)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:947)

21 Online JSON Validation Formatting Tool (Be JSON)

22. There is such a problem when using okhttp, this is because there is no Internet connection, so it cannot be accessed

android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
  1. Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button

    A null pointer exception was reported because I wrote the following two sentences above setContentView(R.layout.activity_main); above this sentence, which resulted in the control not being found.

btn = findViewById(R.id.button);
textView = findViewById(R.id.textview);

The correct spelling should be

super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
btn = findViewById(R.id.button);
textView = findViewById(R.id.textview);

24. This is not a bug, but if the same statement is printed many times in android, it will only display two sentences, and the middle sentence indicates how many items have been folded (for example, in this example, it is printed 15 times in a loop , so the middle is folded 13 times)

insert image description here

25. This is because the version of the dependency in gradle does not match, just change the version to the matching version.

The given artifact contains a string literal with a package reference 'android.support.v4.content' that cannot be safely rewritten. Libraries using reflection such as annotation processors need to be updated manually to add support for androidx.

26. A sharedPreference object is created, but no corresponding xml file is formed.

The reason may be that the project is stuck, just close the project and write it in again.

insert image description here

27. Do not use uppercase letters when creating layout files

28. The component cannot be initialized outside the oncreatd() method, otherwise the component cannot be seen when the component is loaded.

29. The error reported in the place where the notification light was written, the illegal parameter passing error, the reason is that the parameter passing of notify() of my NotificationManager is wrong. Note here: In order to meet the requirements for the screen, the current mobile phone has canceled the breathing light. So there is no way to use the existing equipment to debug the breathing light.

 java.lang.IllegalArgumentException: Invalid notification (no valid small icon): Notification(channel=null pri=0 contentView=null vibrate=null sound=null defaults=0x0 flags=0x1 color=0x00000000 vis=PRIVATE)
        at android.app.NotificationManager.notifyAsUser(NotificationManager.java:393)

30. When switching fragments, the data in the fragments is lost.

Solution: When switching Fragments, the previous fragment is not destroyed, and there is no need to rebuild when switching back.

We don't use replace() to switch, but use add() to add and hide() to hide.

31. This problem is service leakage

E/ActivityThread: Service com.foxconn.cardemo1.MqttService has leaked ServiceConnection org.eclipse.paho.android.service.MqttAndroidClient$MyServiceConnection@4b72f7b that was originally bound here
    android.app.ServiceConnectionLeaked: Service com.foxconn.cardemo1.MqttService has leaked ServiceConnection org.eclipse.paho.android.service.MqttAndroidClient$MyServiceConnection@4b72f7b that was originally bound here
        at android.app.LoadedApk$ServiceDispatcher.<init>(LoadedApk.java:1610)
        at android.app.LoadedApk.getServiceDispatcher(LoadedApk.java:1502)
        at android.app.ContextImpl.bindServiceCommon(ContextImpl.java:1659)
        at android.app.ContextImpl.bindService(ContextImpl.java:1612)
        at android.content.ContextWrapper.bindService(ContextWrapper.java:698)
        at org.eclipse.paho.android.service.MqttAndroidClient.connect(MqttAndroidClient.java:425)
        at com.foxconn.cardemo1.MqttService.doClientConnection(MqttService.java:100)
        at com.foxconn.cardemo1.MqttService.init(MqttService.java:82)
        at com.foxconn.cardemo1.MqttService.onCreate(MqttService.java:45)
        at android.app.ActivityThread.handleCreateService(ActivityThread.java:3532)
        at android.app.ActivityThread.access$1300(ActivityThread.java:199)
        at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1666)
        at android.os.Handler.dispatchMessage(Handler.java:106)
        at android.os.Looper.loop(Looper.java:193)
        at android.app.ActivityThread.main(ActivityThread.java:6669)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:858)
D/EGL_emulation: eglMakeCurrent: 0xde185360: ver 2 0 (tinfo 0xde183650)
Process 5351 terminated.

32. Unable to connect to the mqtt service, the reason may be that the proxy server has not forwarded it.

W/System.err: MqttException (0) - java.net.SocketTimeoutException: failed to connect to /10.205.57.108 (port 1883) from /192.168.232.2 (port 38204) after 10000ms
W/System.err:     at org.eclipse.paho.client.mqttv3.internal.ExceptionHelper.createMqttException(ExceptionHelper.java:38)
        at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:736)
        at java.lang.Thread.run(Thread.java:764)
W/System.err: Caused by: java.net.SocketTimeoutException: failed to connect to /10.205.57.108 (port 1883) from /192.168.232.2 (port 38204) after 10000ms
        at libcore.io.IoBridge.connectErrno(IoBridge.java:185)
        at libcore.io.IoBridge.connect(IoBridge.java:129)
        at java.net.PlainSocketImpl.socketConnect(PlainSocketImpl.java:137)
        at java.net.AbstractPlainSocketImpl.doConnect(AbstractPlainSocketImpl.java:390)
        at java.net.AbstractPlainSocketImpl.connectToAddress(AbstractPlainSocketImpl.java:230)
        at java.net.AbstractPlainSocketImpl.connect(AbstractPlainSocketImpl.java:212)
        at java.net.SocksSocketImpl.connect(SocksSocketImpl.java:436)
        at java.net.Socket.connect(Socket.java:621)
        at org.eclipse.paho.client.mqttv3.internal.TCPNetworkModule.start(TCPNetworkModule.java:74)
W/System.err:     at org.eclipse.paho.client.mqttv3.internal.ClientComms$ConnectBG.run(ClientComms.java:722)
    	... 1 more

33. The new version of android has given up the tools. If you want to use them, you can use the old version of the tools to cover them.

34. The gradle panel on the right side of the newly created android project has no content, just click to rebuild.

insert image description here

35. If the first build fails when using gradlew build to build our app, you can execute the following command again to rebuild.

36. When running the project

Installation did not succeed.
The application could not be installed.
Installation failed due to: 'device 'emulator-5554' not found'

Solution: You can try the following three methods

method one:

[External link image transfer failed, the source site may have an anti-leeching mechanism, it is recommended to save the image and upload it directly (img-UplgyRv4-1664238560213) (C:\Users\ziying\AppData\Roaming\Typora\typora-user-images\ image-20220905110827348.png)]

Method 2. Rebuild

Method 3. Reinstall the emulator

37.Android studio detection update failure solution

Refer to the link below

http://t.csdn.cn/yI3mL

38. The following problem occurs

[(img-IKMrciT0-1664238560215)(C:\Users\ziying\AppData\Roaming\Typora\typora-user-images\image-20220905163854666.png)]

The solution is: remove the checkmark in the red box, and then synchronize the project

insert image description here

39. In the new version, the simulator is in the studio, how to put it outside

insert image description here

Remove the √ in front of launch in a tool window.

40. I don’t know why a null pointer exception was reported, but after re-running it later, this problem will disappear.

java.lang.NullPointerException
	at com.intellij.openapi.wm.impl.ToolWindowDragHelper.getBoundsOnScreen(ToolWindowDragHelper.kt:271)
	at com.intellij.openapi.wm.impl.ToolWindowDragHelper.access$getBoundsOnScreen(ToolWindowDragHelper.kt:32)
	at com.intellij.openapi.wm.impl.ToolWindowDragHelper$relocate$1.run(ToolWindowDragHelper.kt:348)
	at java.desktop/java.awt.event.InvocationEvent.dispatch(InvocationEvent.java:313)
	at java.desktop/java.awt.EventQueue.dispatchEventImpl(EventQueue.java:776)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:727)
	at java.desktop/java.awt.EventQueue$4.run(EventQueue.java:721)
	at java.base/java.security.AccessController.doPrivileged(Native Method)
	at java.base/java.security.ProtectionDomain$JavaSecurityAccessImpl.doIntersectionPrivilege(ProtectionDomain.java:85)
	at java.desktop/java.awt.EventQueue.dispatchEvent(EventQueue.java:746)
	at com.intellij.ide.IdeEventQueue.defaultDispatchEvent(IdeEventQueue.java:885)
	at com.intellij.ide.IdeEventQueue._dispatchEvent(IdeEventQueue.java:754)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$6(IdeEventQueue.java:441)
	at com.intellij.openapi.progress.impl.CoreProgressManager.computePrioritized(CoreProgressManager.java:825)
	at com.intellij.ide.IdeEventQueue.lambda$dispatchEvent$7(IdeEventQueue.java:440)
	at com.intellij.openapi.application.impl.ApplicationImpl.runIntendedWriteActionOnCurrentThread(ApplicationImpl.java:794)
	at com.intellij.ide.IdeEventQueue.dispatchEvent(IdeEventQueue.java:492)
	at java.desktop/java.awt.EventDispatchThread.pumpOneEventForFilters(EventDispatchThread.java:203)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForFilter(EventDispatchThread.java:124)
	at java.desktop/java.awt.EventDispatchThread.pumpEventsForHierarchy(EventDispatchThread.java:113)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:109)
	at java.desktop/java.awt.EventDispatchThread.pumpEvents(EventDispatchThread.java:101)
	at java.desktop/java.awt.EventDispatchThread.run(EventDispatchThread.java:90)

41. To solve this problem, see the documentation

Solve Gradle error: No plug-in with ID 'com.android.application' found - Nuggets (juejin.cn)

42. When importing other people's android projects, the java code will have a small red "J". The solution is to configure jdk for the module

43. It is very slow when synchronizing the project. It turns out that maven is not configured, so just add the maven warehouse in repositories.

insert image description here

44. Every time I create an android project or import an android project, there will always be a situation of reloading gradle, because gradle is downloaded from the external network, so every download is very slow.

Solution:

The first step. First, go to this website to download the required gradle Gradle Distributions , and download the compressed package in the -all.zip format. After downloading the corresponding version, there is no need to decompress it.

The second step. Go to android studio to set the proxy. This 127.0.0.1 is the local machine.

insert image description here

Step 3. Create a new android project, a proxy window will pop up at this time, don't worry about this window first

Step 4. Enter the directory of the android project, and put the previously downloaded compressed package here.

insert image description here

Step 5. Change the above gradle.wrapper.properties file, remove the http:XXX in front of the distributionUrl path, leaving only gradle-xxx-bin.zip, and then save the changes.

insert image description here

Step 6. Go back to Android studio, there is still the agent window, click cancel or no (different versions of studio are different), at this time, the project will be created, and at this time, gradle will not be downloaded from the external network up.

Note: In fact, here we know the reason for setting up the proxy, which is to prevent the process of downloading gradle from the external network by default when creating a project, and configure it by ourselves.

45. After importing other people's projects, I found that there is no gradle folder. After pasting the gradle folder myself, the following problems occurred.

insert image description here

46.touch target size too small

I set the textSize of EditText to 35dp, and then the above problem occurred. The solution is to add a minWidth attribute and set it to 32dp

47.No speakable text present.

The reason is: when there is no content in the editText at the beginning, there needs to be a prompt message, but I have not set it, so the above error is reported

Solution: android:hint="Here is the prompt content"

48. In constraint layout, both horizontal constraints and vertical constraints need to be set, otherwise an error will be reported.

49. When importing dependencies in the android project, it keeps prompting that the dependencies cannot be recognized. The reason is that I have been writing implements before. The solution: change the implements to api, and the compilation will pass.

50.Failed to resolve: com.scwang.smartrefresh:SmartRefreshLayout:1.1.2

The version of android studio used is the chipmunk version, which is different from the old version of build.gradle that was commonly used before. Today, I want to use smartRefreshLayout to implement the pull-down refresh and pull-up loading function, but the above problem occurs.

Solution: Add jcenter() to the following two positions in settings.gradle, and the problem will be solved.
insert image description here

  1. Caused by: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class com.scwang.smartrefresh.layout.SmartRefreshLayout

    Reason: I always thought that my layout file was written irregularly. After a little inspection, I found that it was standardized. Then I read the error message and found that the SmartRefreshLayout class was not found during compilation.

    Solution: Add in the gradle.properties file

    android.enableJetifier=true
    

52.Render problem

java.lang.NoClassDefFoundError:androidx/legacy/widget/Space

Solution:

http://t.csdn.cn/tS28r

53.gradle has been compiling error: No signature of method

When checking the problem, it was found that the repositories in build.gradle were wrong.

I wrote two allowInsecureProtocol=true in maven

54. The android project has the following problem

Your anti-virus program might be impacting your build performance.
Android Studio checked the following directories:

Solution:

Settings→Windows Security Center→Virus and Threat Protection→Find Virus and Threat Protection Settings, click Manage Settings→Find Exclusions, click Add or Remove Exclusions, and then add the files or folders you want to exclude from Windows Security Check to it. Can.

55. In the android project, many values ​​are created, but only one values ​​folder can be seen

The solution is: switch the view from project to Packages

56. If you have installed some plug-ins and want to delete them, you can find the plug-ins you have downloaded in Plugin, remove the √ in front, and then click ok, android will be uninstalled.

57. There are multiple activities in an android project, and then these activities are registered separately in the manifest file, and this error occurs.

Solution: Remove the intent-filters of other activities, leaving only the intent-filter of the main activity. Whoever has this intent-filter is the main startup item.

  • Exception is:
    org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:processDebugMainManifest'.
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.lambda$executeIfValid$1(ExecuteActionsTaskExecuter.java:145)
    at org.gradle.internal.Try$Failure.ifSuccessfulOrElse(Try.java:282)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:143)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:131)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:77)
    at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
    at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:74)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:402)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:389)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:382)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:368)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)
    Caused by: java.lang.RuntimeException: Manifest merger failed with multiple errors, see logs
    at com.android.build.gradle.internal.tasks.manifest.ManifestHelperKt.mergeManifests(ManifestHelper.kt:95)
    at com.android.build.gradle.tasks.ProcessApplicationManifest.doTaskAction(ProcessApplicationManifest.kt:149)
    at com.android.build.gradle.internal.tasks.NonIncrementalTask$taskAction$$inlined$recordTaskAction$1.invoke(BaseTask.kt:66)
    at com.android.build.gradle.internal.tasks.Blocks.recordSpan(Blocks.java:51)
    at com.android.build.gradle.internal.tasks.NonIncrementalTask.taskAction(NonIncrementalTask.kt:97)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at java.base/jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62)
    at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:104)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.doExecute(StandardTaskAction.java:58)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:51)
    at org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:29)
    at org.gradle.api.internal.tasks.execution.TaskExecution$2.run(TaskExecution.java:239)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:29)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$1.execute(DefaultBuildOperationRunner.java:26)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.run(DefaultBuildOperationRunner.java:47)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:68)
    at org.gradle.api.internal.tasks.execution.TaskExecution.executeAction(TaskExecution.java:224)
    at org.gradle.api.internal.tasks.execution.TaskExecution.executeActions(TaskExecution.java:207)
    at org.gradle.api.internal.tasks.execution.TaskExecution.executeWithPreviousOutputFiles(TaskExecution.java:190)
    at org.gradle.api.internal.tasks.execution.TaskExecution.execute(TaskExecution.java:168)
    at org.gradle.internal.execution.steps.ExecuteStep.executeInternal(ExecuteStep.java:89)
    at org.gradle.internal.execution.steps.ExecuteStep.access$000(ExecuteStep.java:40)
    at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:53)
    at org.gradle.internal.execution.steps.ExecuteStep$1.call(ExecuteStep.java:50)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
    at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:50)
    at org.gradle.internal.execution.steps.ExecuteStep.execute(ExecuteStep.java:40)
    at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:68)
    at org.gradle.internal.execution.steps.RemovePreviousOutputsStep.execute(RemovePreviousOutputsStep.java:38)
    at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:48)
    at org.gradle.internal.execution.steps.ResolveInputChangesStep.execute(ResolveInputChangesStep.java:36)
    at org.gradle.internal.execution.steps.CancelExecutionStep.execute(CancelExecutionStep.java:41)
    at org.gradle.internal.execution.steps.TimeoutStep.executeWithoutTimeout(TimeoutStep.java:74)
    at org.gradle.internal.execution.steps.TimeoutStep.execute(TimeoutStep.java:55)
    at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:51)
    at org.gradle.internal.execution.steps.CreateOutputsStep.execute(CreateOutputsStep.java:29)
    at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:61)
    at org.gradle.internal.execution.steps.CaptureStateAfterExecutionStep.execute(CaptureStateAfterExecutionStep.java:42)
    at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:60)
    at org.gradle.internal.execution.steps.BroadcastChangingOutputsStep.execute(BroadcastChangingOutputsStep.java:27)
    at org.gradle.internal.execution.steps.BuildCacheStep.executeWithoutCache(BuildCacheStep.java:188)
    at org.gradle.internal.execution.steps.BuildCacheStep.lambda$execute$1(BuildCacheStep.java:75)
    at org.gradle.internal.Either$Right.fold(Either.java:175)
    at org.gradle.internal.execution.caching.CachingState.fold(CachingState.java:59)
    at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:73)
    at org.gradle.internal.execution.steps.BuildCacheStep.execute(BuildCacheStep.java:48)
    at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:38)
    at org.gradle.internal.execution.steps.StoreExecutionStateStep.execute(StoreExecutionStateStep.java:27)
    at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:36)
    at org.gradle.internal.execution.steps.RecordOutputsStep.execute(RecordOutputsStep.java:22)
    at org.gradle.internal.execution.steps.SkipUpToDateStep.executeBecause(SkipUpToDateStep.java:109)
    at org.gradle.internal.execution.steps.SkipUpToDateStep.lambda$execute$2(SkipUpToDateStep.java:56)
    at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:56)
    at org.gradle.internal.execution.steps.SkipUpToDateStep.execute(SkipUpToDateStep.java:38)
    at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:73)
    at org.gradle.internal.execution.steps.ResolveChangesStep.execute(ResolveChangesStep.java:44)
    at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:37)
    at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsFinishedStep.execute(MarkSnapshottingInputsFinishedStep.java:27)
    at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:89)
    at org.gradle.internal.execution.steps.ResolveCachingStateStep.execute(ResolveCachingStateStep.java:50)
    at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:114)
    at org.gradle.internal.execution.steps.ValidateStep.execute(ValidateStep.java:57)
    at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:76)
    at org.gradle.internal.execution.steps.CaptureStateBeforeExecutionStep.execute(CaptureStateBeforeExecutionStep.java:50)
    at org.gradle.internal.execution.steps.SkipEmptyWorkStep.lambda$execute$2(SkipEmptyWorkStep.java:93)
    at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:93)
    at org.gradle.internal.execution.steps.SkipEmptyWorkStep.execute(SkipEmptyWorkStep.java:34)
    at org.gradle.internal.execution.steps.legacy.MarkSnapshottingInputsStartedStep.execute(MarkSnapshottingInputsStartedStep.java:38)
    at org.gradle.internal.execution.steps.LoadPreviousExecutionStateStep.execute(LoadPreviousExecutionStateStep.java:43)
    at org.gradle.internal.execution.steps.LoadPreviousExecutionStateStep.execute(LoadPreviousExecutionStateStep.java:31)
    at org.gradle.internal.execution.steps.AssignWorkspaceStep.lambda$execute$0(AssignWorkspaceStep.java:40)
    at org.gradle.api.internal.tasks.execution.TaskExecution$3.withWorkspace(TaskExecution.java:284)
    at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:40)
    at org.gradle.internal.execution.steps.AssignWorkspaceStep.execute(AssignWorkspaceStep.java:30)
    at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:37)
    at org.gradle.internal.execution.steps.IdentityCacheStep.execute(IdentityCacheStep.java:27)
    at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:44)
    at org.gradle.internal.execution.steps.IdentifyStep.execute(IdentifyStep.java:33)
    at org.gradle.internal.execution.impl.DefaultExecutionEngine$1.execute(DefaultExecutionEngine.java:76)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeIfValid(ExecuteActionsTaskExecuter.java:142)
    at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:131)
    at org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:77)
    at org.gradle.api.internal.tasks.execution.FinalizePropertiesTaskExecuter.execute(FinalizePropertiesTaskExecuter.java:46)
    at org.gradle.api.internal.tasks.execution.ResolveTaskExecutionModeExecuter.execute(ResolveTaskExecutionModeExecuter.java:51)
    at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:57)
    at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:56)
    at org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:36)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.executeTask(EventFiringTaskExecuter.java:77)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:55)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter$1.call(EventFiringTaskExecuter.java:52)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:204)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$CallableBuildOperationWorker.execute(DefaultBuildOperationRunner.java:199)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:66)
    at org.gradle.internal.operations.DefaultBuildOperationRunner$2.execute(DefaultBuildOperationRunner.java:59)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:157)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.execute(DefaultBuildOperationRunner.java:59)
    at org.gradle.internal.operations.DefaultBuildOperationRunner.call(DefaultBuildOperationRunner.java:53)
    at org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:73)
    at org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:52)
    at org.gradle.execution.plan.LocalTaskNodeExecutor.execute(LocalTaskNodeExecutor.java:74)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:402)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$InvokeNodeExecutorsAction.execute(DefaultTaskExecutionGraph.java:389)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:382)
    at org.gradle.execution.taskgraph.DefaultTaskExecutionGraph$BuildOperationAwareExecutionAction.execute(DefaultTaskExecutionGraph.java:368)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.lambda$run$0(DefaultPlanExecutor.java:127)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.execute(DefaultPlanExecutor.java:191)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.executeNextNode(DefaultPlanExecutor.java:182)
    at org.gradle.execution.plan.DefaultPlanExecutor$ExecutorWorker.run(DefaultPlanExecutor.java:124)
    at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:64)
    at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:48)
    at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:61)
    

    58. I wrote a program to switch the app language (Simplified Chinese, Traditional Chinese, English), but there is a problem with Simplified Chinese and Traditional Chinese.

    The problem that arises is: if the strings.xml is in English, then it cannot be switched; if it is Simplified Chinese, then Simplified Chinese and English can be switched; if it is Traditional Chinese, then Traditional Chinese and English can be switched.
    The reason is that I don't really understand the Locale class.
    The solution is: set Locale.CHINA, Local.TAIWAN, Local.US to switch languages.

    59.Connection timed out: connect. If you are behind an HTTP proxy, please configure the proxy settings either in IDE or Gradle.

    Reason: The continuous connection timed out. At that time, I was using a mobile phone hotspot. After the mobile phone was dormant, the hotspot was turned off, so the connection failed all the time. Modifying the dormancy time of the mobile phone solved my problem.

    60. When starting an android project, fragments cannot be loaded directly.
    61. cannot resolve system “Theme.MaterialComponents.DayNight.DarkActionBar”
    clean the project and rebuild it.
    62. How to solve the large area of ​​garbled characters in android studio?
    Go to the following directory,

    C:\Users\username.AndroidStudio4.0\system

Delete the cache folder under this directory, then restart androidstudio, and the problem is solved after the project is reloaded.

Guess you like

Origin blog.csdn.net/qq_44114147/article/details/127064732