我想在我的项目中使用lambdas,所以我决定切换到Java1.8。Android Studio(2.1.3)强迫我启用JackOptions。另外,我在mac上安装了Java1.8,当我在终端中运行javac版本时,我得到的是javac 1.8.0_101,而android studio中的JDK指向正确的JDK。
ERROR: Dex writing phase: classes.dex has too many IDs. Try using multi-dex
com.android.jack.api.v01.CompilationException: Dex writing phase: classes.dex has too many IDs. Try using multi-dex
at com.android.jack.api.v01.impl.Api01ConfigImpl$Api01CompilationTaskImpl.run(Api01ConfigImpl.java:113)
at com.android.builder.core.AndroidBuilder.convertByteCodeUsingJackApis(AndroidBuilder.java:1852)
at com.android.builder.core.AndroidBuilder.convertByteCodeUsingJack(AndroidBuilder.java:1679)
at com.android.build.gradle.internal.transforms.JackTransform.runJack(JackTransform.java:221)
at com.android.build.gradle.internal.transforms.JackTransform.transform(JackTransform.java:195)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:178)
at com.android.build.gradle.internal.pipeline.TransformTask$2.call(TransformTask.java:174)
at com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:156)
at com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:173)
at sun.reflect.GeneratedMethodAccessor412.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
at java.lang.reflect.Method.invoke(Method.java:498)
at org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:75)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.doExecute(AnnotationProcessingTaskFactory.java:245)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:221)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$IncrementalTaskAction.execute(AnnotationProcessingTaskFactory.java:232)
at org.gradle.api.internal.project.taskfactory.AnnotationProcessingTaskFactory$StandardTaskAction.execute(AnnotationProcessingTaskFactory.java:210)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:80)
at org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:61)
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:66)
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.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:54)
at org.gradle.internal.concurrent.StoppableExecutorImpl$1.run(StoppableExecutorImpl.java:40)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617)
at java.lang.Thread.run(Thread.java:745)
Caused by: com.android.jack.JackAbortException: Dex writing phase: classes.dex has too many IDs. Try using multi-dex
at com.android.jack.backend.dex.DexFileWriter.run(DexFileWriter.java:90)
at com.android.jack.backend.dex.DexFileWriter.run(DexFileWriter.java:41)
at com.android.sched.scheduler.ScheduleInstance.runWithLog(ScheduleInstance.java:203)
at com.android.sched.scheduler.MultiWorkersScheduleInstance$SequentialTask.process(MultiWorkersScheduleInstance.java:466)
at com.android.sched.scheduler.MultiWorkersScheduleInstance$Worker.run(MultiWorkersScheduleInstance.java:163)
Caused by: com.android.jack.backend.dex.DexWritingException: Dex writing phase: classes.dex has too many IDs. Try using multi-dex
at com.android.jack.backend.dex.SingleDexWritingTool.write(SingleDexWritingTool.java:59)
at com.android.jack.backend.dex.DexFileWriter.run(DexFileWriter.java:87)
... 4 more
Caused by: com.android.jack.backend.dex.SingleDexOverflowException: classes.dex has too many IDs. Try using multi-dex
... 6 more
Caused by: com.android.jack.tools.merger.MethodIdOverflowException: Method ID overflow when trying to merge dex files
at com.android.jack.tools.merger.ConstantManager.addDexFile(ConstantManager.java:177)
at com.android.jack.tools.merger.JackMerger.addDexFile(JackMerger.java:69)
at com.android.jack.backend.dex.DexWritingTool.mergeDex(DexWritingTool.java:149)
at com.android.jack.backend.dex.SingleDexWritingTool.write(SingleDexWritingTool.java:57)
... 5 more
:app:transformJackWithJackForTabletsDebug FAILED
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:transformJackWithJackForTabletsDebug'.
> com.android.build.api.transform.TransformException: com.android.jack.api.v01.CompilationException: Dex writing phase: classes.dex has too many IDs. Try using multi-dex
所以我确实打开了multidex,但它在构建96%>:app:TransformJackWithJackForTableTsDebug时卡住了
我通过在app/build.gradle multiDexEnabled=true中添加一行来解决这个问题,如下所示
android{
...
compileSdkVersion rootProject.compileVersion
buildToolsVersion rootProject.buildToolsVersion
defaultConfig {
multiDexEnabled true
}
...
}
在项目建设中。Gradle
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.2.2'
}
}
allprojects {
repositories {
jcenter()
}
}
ext {
buildToolsVersion = "24.0.3"
supportLibVersion = "24.2.1"
}
这导致了另一个问题:我在运行在application类之前的DataBaseProvider中使用DEBUG变量,由于这个bug它将不能正常运行。
其中我指定了一个远程maven存储库: 在这个回购中,我部署了一个工件--实际上它是一个gradle插件。 现在我尝试使用下面的build.gradle文件构建另一个需要使用这个插件/工件的项目: 即使我有上面的settings.xml文件指向远程maven存储库,Gradle也找不到my-gradle-plugin。 如果我在build.gradle文件中指定存储库,它就会起作用: 根据本职位:
问题内容: 我正在尝试使用Gradle 1.6构建Java 8项目,但是我陷入了这个错误: JAVA_HOME设置为“ D:\ Program Files \ Java \ jdk1.8.0”,并且build.gradle包含以下行: 问题答案: 找到了答案。我替换了JAVA_HOME 与 并且建造成功。
问题内容: 我是Gradle新手。我想构建一个uberjar(AKA fatjar),其中包括项目的所有传递依赖项。我需要在“ build.gradle”中添加哪些行? 这是我目前拥有的:(我是从几天前的某个地方复制的,但是不要从那里收集。) 问题答案: 您是否尝试过 gradle食谱中 的fatjar示例? 您正在寻找的是gradle 的影子插件
我还有另一个带有SDK依赖项的lib(一个插件,假设模块B) 所以在我的项目中,有三个模块:SDK(A)、demoApp和插件(B) 现在我需要在jar文件中分发我的SDK和/或插件,以便人们可以在他们的项目中使用它 编辑:为了澄清,我加了一封信 我需要一个用于的jar文件 B需要A才能运行(依赖项) 我需要一个用于b的jar文件
这是我得到的一个例外。 [proguard]优化...