初学android时出现的问题
前言
一些自己刚开始学android的时候遇到的问题以及解决方法,记录一下。
1.当android的编译版本和实际的api版本不一致的时候,会报错。
需要找到匹配的slf4j和log4j
android项目中添加jar包的三种方式
点击按钮没反应,解决方法:找到按钮后,btn.setOnClickListener()就可以了
报错:java.lang.ClassNotFoundException: Didn’t find class “android.view.View$OnUnhandledKeyEventListener” on path: DexPathList[[zip file "/data/app/com.examp
因为androidx从Android9.0(API 28)开始支持,如果项目使用了androidx但是运行在低于API 28版本的设备上就会出现;
所以把低版本的api改到高版本就可以了。
-
Process: com.example.evprac, PID: 11190java.lang.IllegalStateException: WebSocketClient objects are not reuseable
使用webSocket出现了上面的错误。原因是初始化的时候,已经进行了连接。
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;}
解决办法是把 webSocketClient.connect();改为webSocketClient.reconnect();
java.lang.UnsupportedOperationException: Binary XML file line #7: You must supply a layout_width attribute.
这是因为自己的布局文件没有指定layout_width属性,比如我的问题就是在textView中没有指定layout_width属性和layout_height属性,只要指定了问题也就解决了。
-
wrong 2nd argument type found 'android.app.Fragment.' required 'Android.support.v4.app.Fragment'
这是因为导报错误出现的bug,只需要改成需要的包就可以了
android中比较难拼的几个单词(忽略掉,当时不知道为什么要写这一点)
这是我在button想要调用自定义的类的方法的时候出现的错误。目前还没有解决。
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
设置weight属性的时候,一定要设置width或者height属性为0dp
android项目使用lamda表达式的时候,说版本7不支持lamda表达式
解决方法:按住alt+enter键,然后选择set language level to 8
之前安装的HAXM突然需要重新安装,打开安装失败的日志文件(在C盘),发现又出现了之前存在的问题,没有将cpu设置为虚拟化,需要重启电脑,设置虚拟化(bios->system options)。
因为之前Android项目应用的是JDK7,然后我换成jdk8之后就出现了这样的错误:app:compileDebugJavaWithJavac,解决方法:在项目结构中,把jdk换成android中内嵌的1.7版本就没问题了。
如果导入依赖后,还是爆红,无法导包,可以点击build→rebuild
下面这段代码在那个activity里面,那个activity就是第一启动项
androidx从API28开始支持,如果项目中使用了androidx,应该注意版本问题。
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)
在fragment的button中设置点击事件,但是点击按钮后,没有出现该出现的效果,反而报错。
这是因为没有实现点击事件的方法。
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)
此问题还没有解决
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)
在使用okhttp的时候出现了这样的问题,这是因为没有联网,所以访问不到
android.system.GaiException: android_getaddrinfo failed: EAI_NODATA (No address associated with hostname)
-
Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.Button
报空指针异常,原因是我把下面两句话写在了setContentView(R.layout.activity_main);这句话的上面,因此导致了找不到控件。
btn = findViewById(R.id.button);textView = findViewById(R.id.textview);
正确的写法应该是
super.onCreate(savedInstanceState);setContentView(R.layout.activity_main);btn = findViewById(R.id.button);textView = findViewById(R.id.textview);
这个也不算bug,只是如果在android中重复打印很多次相同的语句的时候,它只会显示两句,中间那句话表示折叠了多少项(比如本例中,循环打印了15遍,所以中间折叠了13次)
这是因为在gradle中的依赖的版本不匹配,只需要把版本换成匹配的版本就可以了。
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.
创建了一个sharedPreference对象,但是没有形成对应的xml文件。
原因可能是项目卡了,关掉项目重新写进一下就可以了。
在创建layout文件的时候不能使用大写字母
不能再oncreatd()方法外边初始化组件,否则再加载组件的时候无法看到组件。
在写通知灯的地方报的错,非法传参错误,原因是我的NotificationManager的notify()的参数传递错误。这里注意:现在的手机为了满足对屏幕的要求,已经把呼吸灯取消了。所以没有办法使用现有的设备对呼吸灯进行调试。
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)
切换碎片的时候,碎片中的数据丢失。
解决思路:切换Fragment的时候不消毁前一个fragment,再切换回去的时候也不需要重建。
我们不用replace()去切换,而使用add()添加,hide()隐藏。
这个问题是service泄露
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.(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.
无法连接mqtt服务,原因可能是代理服务器没有转发过来。
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 10000msW/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
新版本的android放弃了tools,如果想用的话,可以用旧版的tools覆盖。
新创建的android项目右边gradle面板没有内容,点击重新构建一下就可以了。
如果使用gradlew build构建我们的app的时候第一次构建失败的话,可以重新再执行以下命令,重新构建。
运行项目的时候
Installation did not succeed.The application could not be installed.Installation failed due to: 'device 'emulator-5554' not found'
解决方法:下面三种方法都可以试试
方法一:
方法二.rebuild一下
方法三.重新安装模拟器
android studio检测更新失败解决办法
参考下面链接
http://t.csdn.cn/yI3mL
出现下面的问题
解决方法是:把红框里面的对勾去掉,然后同步一下项目
新版本中模拟器在studio里面,怎么放外面
把launch in a tool window前面的√去掉。
不知道为啥报了空指针异常,后面重新运行了一下就没这个问题了。
java.lang.NullPointerExceptionat 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)
解决这个问题,看文档
解决Gradle错误:未找到ID为’com.android.application’的插件 - 掘金 (juejin.cn)
导入别人的android项目,java代码都会有一个红色的小“J”,解决方法是给模块配置jdk
同步项目的时候特别慢,原来是因为没有配置maven,所有在repositories里面添加maven仓库即可。
每次创建项目的android项目或者导入android项目的时候,总是会出现重新加载gradle的情况,因为gradle是从外网下载的,所以每次下载都很慢。
解决方法:
第一步.首先,先去这个网站下载需要的gradleGradle Distributions,下载-all.zip格式的压缩包。下载完对应的版本后,不需要解压。
第二步.去android studio中设置代理。这个127.0.0.1就是本机。
第三步.创建一个新的android项目,此时会弹出来一个代理的窗口,先不需要管这个窗口
第四步.进入android项目的目录,把之前下载的压缩包放在这里。
第五步.更改上面的gradle.wrapper.properties文件,把distributionUrl的路径前面的http:XXX去掉,只剩下gradle-x.x.x-bin.zip,然后保存更改。
第六步.回到Android studio,此时还是有那个代理的窗口,点击cancel或者no(不同版本studio不一样),这时候,就开始创建项目了,而且此时,也不会在外网下载gradle了。
注:其实到这里,也就知道设置代理的原因了,就是为了在创建项目的时候,阻止默认从外网下载gradle的过程,由我们自己配置。
导入别人的项目后,发现没有gradle文件夹,自己粘贴了gradle文件夹之后,出现了下面这些问题。
touch target size too small
我把EditText的textSize设为35dp,然后就出现了上面这个问题,解决方法是添加一个minWidth属性并设置为32dp
No speakable text present.
原因是:editText里面刚开始什么内容都没有的时候,需要有提示信息,但是我没有设置,所以就报上面的错误
解决方法:android:hint=”这里是提示内容“
在约束布局中,水平约束和垂直约束都需要设置,否则会报错。
在android项目中导入依赖的时候,一直提示无法识别依赖,原因是我之前一直写的是implement,解决方法:把implement改成api,就能编译通过了。
Failed to resolve: com.scwang.smartrefresh:SmartRefreshLayout:1.1.2
使用的android studio版本是花栗鼠版本的,该版本和之前常用的旧版本的build.gradle不太一样,今天想用smartRefreshLayout实现下拉刷新上拉加载的功能,结果就出现了上面的问题。
解决方法:在settings.gradle中下面这两个位置中添加jcenter(),问题就会解决。
-
Caused by: android.view.InflateException: Binary XML file line #20: Binary XML file line #20: Error inflating class com.scwang.smartrefresh.layout.SmartRefreshLayout
原因:之前一直以为我的布局文件写的不规范,一点点检查后,发现是规范的,然后又看报错信息,发现是编译的时候没有找到SmartRefreshLayout类
解决方法:在gradle.properties文件中添加
android.enableJetifier=true
Render problem
java.lang.NoClassDefFoundError:androidx/legacy/widget/Space
解决方法:
http://t.csdn.cn/tS28r
gradle一直编译错误:No signature of method
检查问题的时候,发现时build.gradle中的repositories出错了。
我在maven那里写了两个allowInsecureProtocol=true
android项目出现下面这个问题
Your anti-virus program might be impacting your build performance.
Android Studio checked the following directories:
解决方法:
设置→windows安全中心→病毒和威胁防护→找到病毒和威胁防护设置,点击管理设置→找到排除项,点击添加或删除排除项,然后把想要排除windows安全检查的文件或者文件夹添加到里面即可。
在android项目中,创建了很多个values,但是只能看到一个values文件夹
解决方法是:将视图从project切换到Packages
如果安装了一些插件,想要删除的话,可以在Plugin里面找到自己曾经下载过的插件,把前面的√去掉,然后点击ok,android就会卸载了。
一个android项目里面有多个activity,然后在manifest文件里面分别注册这几个activity就出现了这个报错。
解决方法:把其他activity的intent-filter去掉,只留下一个主activity的intent-filter,谁有这个intent-filter,谁就是主启动项。
-
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 logsat 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)
写了一个程序,切换app语言(简体中文、繁体中文、英文),但是简体中文和繁体中文出现了问题。
出现的问题就是:如果strings.xml里面是英文,那么无法切换;如果是简体中文,那么可以切换简体中文和英文;如果是繁体中文,那么可以切换繁体中文和英文。
原因是我没真正理解Locale类
解决方法是:设置Locale.CHINA、Local.TAIWAN、Local.US就能切换语言了。Connection timed out: connect. If you are behind an HTTP proxy, please configure the proxy settings either in IDE or Gradle.
原因:一直连接超时,当时用的是手机热点,手机休眠后,热点关闭,所以才导致一直连接失败,修改了手机的休眠时间我的问题就解决了。
启动android项目时,是不能直接加载fragment的。
61.cannot resolve system “Theme.MaterialComponents.DayNight.DarkActionBar”
clean一下项目,在rebuild一下就可以了。
62.android studio中出现大面积的乱码该如何解决?
进入到以下目录,C:\Users\用户名.AndroidStudio4.0\system
将该目录下面的cache文件夹删掉,然后重启androidstudio,工程重新载入后问题解决。
来源地址:https://blog.csdn.net/qq_44114147/article/details/127064732
免责声明:
① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。
② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341