Android studio 中gradle版本不一样导致运行问题Error:Unable to find method 'com.android.build.gradle.tasks.factory

问题:

Error:Unable to find method 'com.android.build.gradle.tasks.factory.AndroidJavaCompile.setDependency


解决方案

    1.将classpath 修改为你本地的路径

        例如

    2.如果是从android studio3.0以后的项目,在android studio 3.0以前上跑,还要讲app下的build.gradle中的implementation修改为compile

  3.第二部完成分后,接着在该文件下compileSdkVersion 下面添加buildToolsVersion ""

    例如

buildToolsVersion "26.0.2"

4.打开gradle目录下的wrapper目录下gradle-wrapper.properties的这个文件,将distributionUrl=https\://services.gradle.org/distributions/中最后的gradle修改为自己的gradle。

例如

distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip

发布了33 篇原创文章 · 获赞 26 · 访问量 2万+
展开阅读全文

adnroid 开发编译mqtt报错

08-10

android studio 下载并打开paho.mqtt.android 编译报错,我的gradle版本4.4 as版本3.1.3 下载地址https://github.com/eclipse/paho.mqtt.android 直接git到的原始的项目,打开编译就报错,我本地新建空内容项目都能编译成功,adnroid 开发编译mqtt报错× 报错如下: Cannot create variant 'android-lint' after configuration ':org.eclipse.paho.android.service:debugRuntimeElements' has been resolved ![图片说明](https://img-ask.csdn.net/upload/201808/10/1533894738_767361.png) org.gradle.initialization.ReportedException: org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring project ':org.eclipse.paho.android.service'. at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:139) at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:109) at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:78) at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:75) at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152) at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:100) at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:75) at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:53) at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) 。。。 at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) at java.lang.Thread.run(Thread.java:745) Caused by: org.gradle.internal.exceptions.LocationAwareException: A problem occurred configuring project ':org.eclipse.paho.android.service'. at org.gradle.initialization.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:74) at org.gradle.initialization.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:47) at org.gradle.initialization.StackTraceSanitizingExceptionAnalyser.transform(StackTraceSanitizingExceptionAnalyser.java:30) at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:137) at org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:109) at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:78) at org.gradle.internal.invocation.GradleBuildController$1.call(GradleBuildController.java:75) at org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:152) at org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:100) at org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:75) at org.gradle.tooling.internal.provider.runner.BuildModelActionRunner.run(BuildModelActionRunner.java:53) at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35) at org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32) at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$1.run(RunAsBuildOperationBuildActionRunner.java:43) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:336) at org.gradle.internal.progress.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:328) at org.gradle.internal.progress.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:199) at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:110) at org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:40) 。。。 at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:82) at org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36) at org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:122) at org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50) at org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:295) at org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) at org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46) at org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) Caused by: org.gradle.api.ProjectConfigurationException: A problem occurred configuring project ':org.eclipse.paho.android.service'. at org.gradle.configuration.project.LifecycleProjectEvaluator.addConfigurationFailure(LifecycleProjectEvaluator.java:94) at org.gradle.configuration.project.LifecycleProjectEvaluator.notifyAfterEvaluate(LifecycleProjectEvaluator.java:89) 。。。 ... 62 more Caused by: org.gradle.api.InvalidUserCodeException: Cannot create variant 'android-lint' after configuration ':org.eclipse.paho.android.service:debugRuntimeElements' has been resolved at org.gradle.api.internal.artifacts.configurations.DefaultConfigurationPublications$ConfigurationVariantFactory.create(DefaultConfigurationPublications.java:158) at org.gradle.api.internal.artifacts.configurations.DefaultConfigurationPublications$ConfigurationVariantFactory.create(DefaultConfigurationPublications.java:151) at org.gradle.api.internal.FactoryNamedDomainObjectContainer.doCreate(FactoryNamedDomainObjectContainer.java:100) at org.gradle.api.internal.AbstractNamedDomainObjectContainer.create(AbstractNamedDomainObjectContainer.java:67) at com.android.build.gradle.internal.scope.VariantScopeImpl.lambda$publishArtifactToConfiguration$2(VariantScopeImpl.java:378) at org.gradle.api.internal.artifacts.configurations.DefaultConfigurationPublications.variants(DefaultConfigurationPublications.java:139) at com.android.build.gradle.internal.scope.VariantScopeImpl.publishArtifactToConfiguration(VariantScopeImpl.java:376) at com.android.build.gradle.internal.scope.VariantScopeImpl.publishIntermediateArtifact(VariantScopeImpl.java:347) at com.android.build.gradle.internal.scope.VariantScopeImpl.addTaskOutput(VariantScopeImpl.java:298) at com.android.build.gradle.internal.TaskManager.configureGlobalLintTask(TaskManager.java:536) at com.android.build.gradle.BasePlugin.createAndroidTasks(BasePlugin.java:7 问答

没有更多推荐了,返回首页

©️2019 CSDN 皮肤主题: 大白 设计师: CSDN官方博客

分享到微信朋友圈

×

扫一扫,手机浏览