Android报错:Execution failed for task ‘:app:mergeDebugResources‘

Task ‘compileDebug’ is ambiguous in root project ‘mord’. Candidates are: ‘compileDebugAidl’, ‘compileDebugAndroidTestAidl’, ‘compileDebugAndroidTestJavaWithJavac’, ‘compileDebugAndroidTestRenderscript’, ‘compileDebugAndroidTestShaders’, ‘compileDebugAndroidTestSources’, ‘compileDebugJavaWithJavac’, ‘compileDebugRenderscript’, ‘compileDebugShaders’, ‘compileDebugSources’, ‘compileDebugUnitTestJavaWithJavac’, ‘compileDebugUnitTestSources’.
首先粗略解决问题,实现发布运行参考这篇博客
但是还是有报错在这里插入图片描述
然后来到了大家极其推崇的这篇文章
开始debug之旅,由于提示模糊不清,因此又参考这篇
于是得到文章开头一堆报错,尝试第一个细节报错,发现报错为:在这里插入图片描述
解决方案:参考这篇文章
改成以下代码将不再报错:

 //handler实现演示跳转:handler延时发送消息
        Handler handler=new Handler(Looper.getMainLooper(),new Handler.Callback() {
    
    
            //处理接收到的消息的方法
            @Override
            public boolean handleMessage(@NonNull Message msg) {
    
    
                //页面跳转
                startActivity(new Intent(getApplicationContext(),MainActivity.class));
                return false;
            }
        });//表示延时3秒发送
        handler.sendEmptyMessageDelayed(0,3000);//如果跟在Handler后面则需要将handler定义为Boolean类型

至此,compileDebugJavaWithJavac的报错完美解决,但是还有其他bug,待我闲时继续查找,先放个坑。

猜你喜欢

转载自blog.csdn.net/jinyeran/article/details/121271764