org.gradle.api.tasks.TaskExecutionException:任务':app:transformClassesWithDexForDebug'

时间:2016-06-02 06:05:07

标签: java android android-studio

我是Android Studio的新手,我一直在使用eclipse,但由于项目中出现65K错误,我需要将其迁移到Android Studio。在运行时

  

./ gradlew assembleDebug

我收到错误消息: -

Execution failed for task ':app:transformClassesWithDexForDebug'.
com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command '/opt/jdk/jdk1.8.0_45/bin/java'' finished with non-zero exit value 1

我知道这是将eclipse项目迁移到Android Studio时非常常见的错误。

并且相信我,我搜索了很多有相同问题的链接并尝试了他们在答案中提到的所有内容,但是没有为我工作

以下是我获得的链接:

Execution failed for task ':app:transformClassesWithDexForDebug' - Gradle dependencies?

Execution failed for task ':app:transformClassesWithDexForDebug' while implementing Google sign in for Android

Android Studio TransformException : Error:Execution failed for task ':app:transformClassesWithDexForDebug'

Error:Execution failed for task ':app:transformClassesWithDexForDebug'

com.android.build.transform.api.TransformException

https://github.com/journeyapps/zxing-android-embedded/issues/110

还有更多

我尝试了所有解决方案,我尝试在我的项目中逐个添加.jar个文件,我只使用了那些在我的项目中使用的Google服务包,我甚至添加了multidex jar但没有什么可以帮助我

这是我的Build.gradle文件: -

apply plugin: 'com.android.application'

android {
    compileSdkVersion 23
    buildToolsVersion "23.0.3"

    defaultConfig {
        applicationId "com.petzview.android"
        minSdkVersion 15
        targetSdkVersion 23
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        }
    }
    lintOptions {
        abortOnError false
        checkReleaseBuilds false
    }

    dexOptions {
        incremental = true;
        maxProcessCount 4
        javaMaxHeapSize "4g"
        dexInProcess = false
        preDexLibraries = false
    }
}

dependencies {
    compile fileTree(include: ['*.jar'], dir: 'libs')
    testCompile 'junit:junit:4.12'
    compile 'com.android.support:appcompat-v7:23.4.0'
    compile 'com.google.android.gms:play-services-ads:9.0.0'
    compile 'com.google.android.gms:play-services-plus:9.0.0'
    compile 'com.google.android.gms:play-services-gcm:9.0.0'
    compile project(':AVIOCtrlDefine')
    compile project(':Facebook')
    compile project(':SlidingMenu-master')
    compile 'com.android.support:multidex:1.0.1'
}
android.packagingOptions {
    exclude 'the META-INF / DEPENDENCIES'
    exclude 'META-INF/DEPENDENCIES.txt'
    exclude 'the META-INF / LICENSE'
    exclude 'the META-INF / LICENSE.txt'
    exclude 'the META-INF / license.txt'
    exclude 'the META-INF / NOTICE'
    exclude 'the META-INF / the NOTICE.txt '
    exclude ' the META-INF / NOTICE.txt '
    exclude ' the META-INF / ASL2.0 '
    exclude ' the META-INF / Services / javax.annotation.processing.Processor '
}
apply plugin: 'com.google.gms.google-services'

我的主要gradle文件: -

buildscript {
    repositories {
        jcenter()
    }
    dependencies {
       classpath 'com.android.tools.build:gradle:2.1.0'
       classpath 'com.google.gms:google-services:3.0.0'
    }
}

allprojects {
    repositories {
        jcenter()
    }
}

这里我附上我的libs文件夹的屏幕截图: -

这是我的MyApplication.java类: -

public class MyApplication extends MultiDexApplication {
    private Object mTempObject = null;

    private boolean flagHomeFragmentFirstCreate = true;

    @Override
    protected void attachBaseContext(Context base) {
        super.attachBaseContext(base);
        MultiDex.install(this);
        FacebookSdk.sdkInitialize(getApplicationContext());
    }

我的Manifest类包含MyApplication: -

 <application
        android:name=".MyApplication"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:theme="@style/AppTheme">

运行后

  

./ gradlew assembleDebug --stacktrace

我明白了: -

错误记录

org.gradle.api.tasks.TaskExecutionException: Execution failed for task ':app:transformClassesWithDexForDebug'.
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:69)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:46)
at org.gradle.api.internal.tasks.execution.PostExecutionAnalysisTaskExecuter.execute(PostExecutionAnalysisTaskExecuter.java:35)
at org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:64)
at org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:58)
at org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:52)
at org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:53)
at org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:203)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter$EventFiringTaskWorker.execute(DefaultTaskGraphExecuter.java:185)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.processTask(AbstractTaskPlanExecutor.java:66)
at org.gradle.execution.taskgraph.AbstractTaskPlanExecutor$TaskExecutorWorker.run(AbstractTaskPlanExecutor.java:50)
at org.gradle.execution.taskgraph.DefaultTaskPlanExecutor.process(DefaultTaskPlanExecutor.java:25)
at org.gradle.execution.taskgraph.DefaultTaskGraphExecuter.execute(DefaultTaskGraphExecuter.java:110)
at org.gradle.execution.SelectedTaskExecutionAction.execute(SelectedTaskExecutionAction.java:37)
         org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at org.gradle.execution.DefaultBuildExecuter.access$000(DefaultBuildExecuter.java:23)
at org.gradle.execution.DefaultBuildExecuter$1.proceed(DefaultBuildExecuter.java:43)
at org.gradle.execution.DryRunBuildExecutionAction.execute(DryRunBuildExecutionAction.java:32)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:37)
at org.gradle.execution.DefaultBuildExecuter.execute(DefaultBuildExecuter.java:30)
at org.gradle.initialization.DefaultGradleLauncher$4.run(DefaultGradleLauncher.java:154)
at org.gradle.internal.Factories$1.create(Factories.java:22)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:52)
at org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:151)
at org.gradle.initialization.DefaultGradleLauncher.access$200(DefaultGradleLauncher.java:32)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:99)
at org.gradle.initialization.DefaultGradleLauncher$1.create(DefaultGradleLauncher.java:93)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90)
at org.gradle.internal.progress.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:62)
at org.gradle.initialization.DefaultGradleLauncher.doBuild(DefaultGradleLauncher.java:93)
at org.gradle.initialization.DefaultGradleLauncher.run(DefaultGradleLauncher.java:82)
at org.gradle.launcher.exec.InProcessBuildActionExecuter$DefaultBuildController.run(InProcessBuildActionExecuter.java:94)
at org.gradle.tooling.internal.provider.ExecuteBuildActionRunner.run(ExecuteBuildActionRunner.java:28)
at org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:43)
at org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:28)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:78)
at org.gradle.launcher.exec.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:48)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:51)
at org.gradle.launcher.exec.DaemonUsageSuggestingBuildActionExecuter.execute(DaemonUsageSuggestingBuildActionExecuter.java:28)
at org.gradle.launcher.cli.RunBuildAction.run(RunBuildAction.java:43)
at org.gradle.internal.Actions$RunnableActionAdapter.execute(Actions.java:170)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:237)
at org.gradle.launcher.cli.CommandLineActionFactory$ParseAndBuildAction.execute(CommandLineActionFactory.java:210)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:35)
at org.gradle.launcher.cli.JavaRuntimeValidationAction.execute(JavaRuntimeValidationAction.java:24)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:206)
at org.gradle.launcher.cli.CommandLineActionFactory$WithLogging.execute(CommandLineActionFactory.java:169)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:33)
at org.gradle.launcher.cli.ExceptionReportingAction.execute(ExceptionReportingAction.java:22)
at org.gradle.launcher.Main.doAction(Main.java:33)
at org.gradle.launcher.bootstrap.EntryPoint.run(EntryPoint.java:45)
at org.gradle.launcher.bootstrap.ProcessBootstrap.runNoExit(ProcessBootstrap.java:54)
at org.gradle.launcher.bootstrap.ProcessBootstrap.run(ProcessBootstrap.java:35)
at org.gradle.launcher.GradleMain.main(GradleMain.java:23)
at org.gradle.wrapper.BootstrapMainStarter.start(BootstrapMainStarter.java:30)
at org.gradle.wrapper.WrapperExecutor.execute(WrapperExecutor.java:129)
at org.gradle.wrapper.GradleWrapperMain.main(GradleWrapperMain.java:61)
Caused by: java.lang.RuntimeException:
com.android.build.api.transform.TransformException:
com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException:
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
 '/opt/jdk/jdk1.8.0_45/bin/java'' finished with non-zero exit value 1
at com.android.builder.profile.Recorder$Block.handleException(Recorder.java:54)
at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:57)
at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:47)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:173)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:244)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:220)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:231)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:209)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
         ... 60 more Caused by: com.android.build.api.transform.TransformException:> com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException:
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
 '/opt/jdk/jdk1.8.0_45/bin/java'' finished with non-zero exit value 1
at com.android.build.gradle.internal.transforms.DexTransform.transform(DexTransform.java:421)
at com.android.build.gradle.internal.pipeline.TransformTask$3.call(TransformTask.java:178)
at com.android.build.gradle.internal.pipeline.TransformTask$3.call(TransformTask.java:174)
at com.android.builder.profile.ThreadRecorder$1.record(ThreadRecorder.java:55)
         ... 69 more Caused by: com.android.ide.common.process.ProcessException:
java.util.concurrent.ExecutionException:
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
 '/opt/jdk/jdk1.8.0_45/bin/java'' finished with non-zero exit value 1
at com.android.builder.core.AndroidBuilder.dexOutOfProcess(AndroidBuilder.java:1553)
at com.android.builder.core.AndroidBuilder.runDexer(AndroidBuilder.java:1495)
at com.android.builder.core.AndroidBuilder.convertByteCode(AndroidBuilder.java:1482)
 at com.android.build.gradle.internal.transforms.DexTransform.transform(DexTransform.java:251)
         ... 72 more Caused by: java.util.concurrent.ExecutionException:
com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
 '/opt/jdk/jdk1.8.0_45/bin/java'' finished with non-zero exit value 1
at com.android.builder.core.AndroidBuilder.dexOutOfProcess(AndroidBuilder.java:1549)
        ... 75 more Caused by: com.android.ide.common.process.ProcessException:
org.gradle.process.internal.ExecException: Process 'command
 '/opt/jdk/jdk1.8.0_45/bin/java'' finished with non-zero exit value 1
at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:43)
at com.android.builder.core.AndroidBuilder$3.call(AndroidBuilder.java:1538)
at com.android.builder.core.AndroidBuilder$3.call(AndroidBuilder.java:1531)
Caused by: org.gradle.process.internal.ExecException: Process 'command
 '/opt/jdk/jdk1.8.0_45/bin/java'' finished with non-zero exit value 1
at org.gradle.process.internal.DefaultExecHandle$ExecResultImpl.assertNormalExitValue(DefaultExecHandle.java:367)
at com.android.build.gradle.internal.process.GradleProcessResult.assertNormalExitValue(GradleProcessResult.java:41)
         ... 2 more

在设备上运行应用程序时出错: -

  

错误:处理“java / awt / font / NumericShaper.class”时遇到问题:   错误:错误使用或错误使用核心类(java。*或   javax。*)错误:没有构建核心库时。错误:这通常是   由于无意中包含一个核心库文件错误:在你的   应用程序的项目,使用IDE时(例如Error:Eclipse)。如果   你确定你不是故意定义一个错误:核心类,   那么这就是错误的最可能的解释:继续。   错误:但是,您实际上可能正在尝试在a中定义类   核心错误:名称空间,您可能已经采取的来源   例如,错误:来自非Android虚拟机项目。这将   大多数错误:肯定不行。它至少会危害它   错误:您的应用与该平台的未来版本的兼容性。   错误:合法性通常也是有问题的。错误:如果你真的   打算构建一个核心库 - 这只是错误:适当的   创建完整虚拟机的一部分错误:分发,而不是   编译应用程序 - 然后使用错误:“ - core-library”   选项以禁止此错误消息。错误:如果您继续使用   “--core-library”但实际上是错误:构建应用程序,然后   预先警告您的应用程序错误:仍然无法构建或   在某些时候跑。请错误:为愤怒的客户做好准备   例如,查找您的错误:应用程序停止运行一次   他们升级了他们的操作错误:系统。你应该受到责备   这个问题。错误:如果您合法地使用某些代码   碰巧是在一个错误:核心包,然后是最简单的安全   替代方法是错误:重新包装该代码。那就是搬家   有问题的类到Error:你自己的包命名空间。这个   意味着它们永远不会出现错误:与核心系统发生冲突   类。 JarJar是一个可以帮助错误的工具:你在这方面的努力。如果   你发现你不能这样做,然后错误:这是一个指示   您所在的路径最终会出错:导致疼痛,   痛苦,悲伤和悲伤。错误:1错误;中止   错误:任务执行失败   ':应用程序:transformClassesWithDexForDebug'。

     
    

com.android.build.api.transform.TransformException:com.android.ide.common.process.ProcessException:     java.util.concurrent.ExecutionException:     com.android.ide.common.process.ProcessException:     org.gradle.process.internal.ExecException:进程'命令     '/ usr / lib / jvm / java-8-oracle / bin / java''以非零退出结束     值1信息:BUILD FAILED

  

请查看一次,如果我在某些地方出错了,请告诉我,过去3天我被困了

先谢谢

23 个答案:

答案 0 :(得分:16)

为我检查build.gradle(模块:Android)已解决的问题。

将其修改为可行的版本。

android {
    buildToolsVersion '23.0.1'
}

答案 1 :(得分:10)

这里有一个简单的解决方案……对我有用:

  1. 清洁项目
  2. 重建项目
  3. 使用gradle文件同步项目

答案 2 :(得分:5)

我有同样的问题,我可以这样解决:

1)如果您将minSdkVersion设置为21或更高的值,则唯一要做的就是在multiDexEnabled中设置build.gradle文件在模块级别,如下所示:

android {
    defaultConfig {
        ...
        minSdkVersion 21 
        targetSdkVersion 28
        multiDexEnabled true
    }
    ...
}

2)但是,如果您的minSdkVersion设置为20或更小,则应使用MultiDex兼容性库,如下所示:

2.1)修改模块级build.gradle文件以启用MultiDex并将MultiDex库添加为依赖项,如下所示

android {
    defaultConfig {
        ...
        minSdkVersion 15 
        targetSdkVersion 28
        multiDexEnabled true
    }
    ...
}

dependencies {
  implementation 'com.android.support:multidex:1.0.3'
}

2.2)是否根据Application类,执行以下操作之一:

2.2.1)如果不取消Application类,请修改清单文件,以在android: name标记中设置<application>,如下所示:

<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapp">
    <application
            android:name="android.support.multidex.MultiDexApplication" >
        ...
    </application>
</manifest>

2.2.2)如果取消Application类,则必须将其更改为扩展MultiDexApplication(如果可能),如下所示:

public class MyApplication extends MultiDexApplication { ... }

2.2.3)另外,如果您覆盖Application类并且不能更改基类,则可以覆盖attachBaseContext ()方法并调用MultiDex.install (this)以启用MultiDex:< / p>

public class MyApplication extends SomeOtherApplication {
  @Override
  protected void attachBaseContext(Context base) {
     super.attachBaseContext(base);
     MultiDex.install(this);
  }
}

Please use this link, it was really useful for me!

答案 3 :(得分:3)

尝试移动:

apply plugin: 'com.google.gms.google-services'

就在下面:

apply plugin: 'com.android.application'

在您的模块Gradle文件中,确保所有Google服务都具有版本9.0.0

确保仅使用此构建工具:

classpath 'com.android.tools.build:gradle:2.1.0'

在gradle-wrapper.properties中确保:

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

毕竟以上是正确的,然后制作菜单文件 - &gt;使缓存无效并重新启动。

答案 4 :(得分:2)

我已经为这个问题苦苦挣扎了2天。并尝试了所有选项。 最终注意到,更新我的android studio后,它没有向我显示诸如@ v.d之类的编译错误。上面写过。我的问题是,在我的构建文件中,我正在使用compile(应替换为实现 api )和 testcompile (也应替换为通过 testimplementation )。请注意,我已经更改了整个构建文件(android,app和其他构建文件-在我的情况下,我还具有折叠单元库)

例如,以

代替

compile project(path: ':folding-cell')

编写此

implementation project(path: ':folding-cell')

答案 5 :(得分:1)

您的清单应用程序名称应包含应用程序类名称。 喜欢

<application
        android:name="your package name.MyApplication"
        android:allowBackup="true"
        android:icon="@drawable/ic_launcher"
        android:label="@string/app_name"
        android:largeHeap="true"
        android:theme="@style/AppTheme"> 

答案 6 :(得分:1)

迁移到androidX库

在Android Studio 3.2及更高版本中,您可以通过从菜单栏中选择Refactor > Migrate到AndroidX来将现有项目迁移到AndroidX。

来源: https://developer.android.com/jetpack/androidx/migrate

答案 7 :(得分:1)

我遵循的步骤是:

  1. 关闭Android Studio
  2. 删除.idea目录
  3. 删除.gradle目录
  4. 删除所有.iml个文件
    • 终端命令:find . | grep -e .iml$ | xargs rm
  5. 使用Android Studio作为项目重新打开目录

答案 8 :(得分:1)

我的简单答案是唯一的解决方法...

请检查最后添加的布局文件,确保.xml文件中肯定有错误。

我们可以简单地复制和粘贴其他项目中的.xml文件,并将其粘贴到xml文件中。

.xml文件中的错误可能是以下某些情况。...

  1. Drawable文件夹或String.xml或Dimen.xml中缺少某些东西

在将所有可用代码放置在受关注的文件夹中之后,不要忘记清理项目...

答案 9 :(得分:1)

编译器很简单不接受您所做的最后更改,因此请转到您进行了更改的最后一个文件,它将显示错误,只需对其进行更改并重新编译。 / p>

答案 10 :(得分:1)

对我来说,这只是一个编译错误,可惜Android Studio没有显示它。请手动搜索。 尝试使工作脱机并清理和重建可能会为您提供更多帮助

答案 11 :(得分:0)

只需从build.gradle(项目文件夹)中删除此行

apply plugin: 'com.google.gms.google-services'

现在重建应用程序。工作良好 编码愉快

答案 12 :(得分:0)

应用于ProGuard规则

-ignorewarnings

答案 13 :(得分:0)

对于我来说,我遵循Firebase中的步骤操作,但错误地将其粘贴到了错误的文件中。

然后,我从Project返回到项目Android。在Android view中,我粘贴了文件/projectname/app/YOUR-FILE-HERE,现在,您必须再次编译。

答案 14 :(得分:0)

对我来说,唯一可行的方法是添加到存储库中

maven {
        url "https://maven.google.com"
    }

它应该像这样:

allprojects {
    repositories {
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }

答案 15 :(得分:0)

您只需更改import android.support.v7.app.ActionBarActivity; 至 导入android.support.v7.app.AppCompatActivity;

并扩展AppCompatActivity

答案 16 :(得分:0)

在我的情况下,我正在通过引用该类来访问该类的静态数组,但是我们知道我们可以通过类名直接访问静态成员。因此,当我用访问该数组的类名替换引用时。它修复了此错误。

答案 17 :(得分:0)

我从首选项中禁用了“即时运行”功能,问题已解决。

答案 18 :(得分:0)

从app \ build \ intermediates中删除中间体文件夹。  然后重建项目。它会工作

答案 19 :(得分:0)

像这样在gradle(应用程序级别)中添加multiDexEnabled:

defaultConfig {
        ...
        ...
        multiDexEnabled true
    }

答案 20 :(得分:0)

首先在项目中删除此项目..它在build.gradle(module:app)中,然后构建您的应用,现在您的项目显示实际错误,然后您发现真正的问题是..,然后找到实际问题再次将其粘贴到其所属的地方

allprojects {gradle.projectsEvaluated {

    tasks.withType(JavaCompile)

{             options.encoding ='UTF-8'

        options.compilerArgs

<<“ -Xlint:unchecked” <<“ -Xlint:deprecation”}]}}

答案 21 :(得分:0)

清除项目,然后运行。它会工作

答案 22 :(得分:0)

如果有人在 android 中添加 ShimmerRecyclerView Loader 时遇到类似类型的错误,请确保添加 maven { url "https://jitpack.io" } under allprojects 像下面。

    allprojects {
    repositories {
        google()
        jcenter()
        //add it here
        maven { url "https://jitpack.io" }
      }
   }