build.gradle(module:app)
apply plugin: 'com.android.application'
android {
compileSdkVersion 27
buildToolsVersion "27.0.3"
defaultConfig {
applicationId ""com.khaidemsandipsingha.builditbigger""
minSdkVersion 15
targetSdkVersion 27
versionCode 1
versionName "1.0"
multiDexEnabled true
}
buildTypes {
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
packagingOptions {
exclude 'LICENSE.txt'
}
flavorDimensions "tier"
productFlavors {
paid {
applicationId 'com.example.khaidemsandipsingha.builditbigger.paid'
versionName '1.0-paid'
buildConfigField "boolean", "PAID_VERSION", "true"
dimension "tier"
}
free {
applicationId 'com.example.khaidemsandipsingha.builditbigger.free'
versionName '1.0-free'
buildConfigField "boolean", "PAID_VERSION", "false"
dimension "tier"
}
}
sourceSets {
main {
java.srcDirs = ['src/main/java', 'src/main/java/com.example.khaidemsandipsingha.builditbigger.paid']
}
paid {
manifest.srcFile 'src/paid/AndroidManifest.xml'
}
free {
manifest.srcFile 'src/free/AndroidManifest.xml'
}
}
repositories {
maven { url "https://maven.google.com" }
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
//Tests
androidTestImplementation 'org.hamcrest:hamcrest-library:1.3'
//Support
//noinspection GradleCompatible
implementation 'com.android.support:appcompat-v7:27.1.1'
// Added for AdMob
freeImplementation 'com.google.android.gms:play-services:8.3.0'
//Add AndroidJoke
implementation project(':androidjoke')
//Backend
implementation project(path: ':backend', configuration: 'android-endpoints')
implementation 'com.google.api-client:google-api-client-android:1.23.0'
implementation 'com.google.api-client:google-api-client:1.23.0'
implementation 'com.android.support:multidex:1.0.3'
}
构建错误输出 失败:构建失败,并出现异常。
com.android.build.api.transform.TransformException:生成主dex列表时出错。
逐步构建-s
org.gradle.api.tasks.TaskExecutionException:任务执行失败 ':app:transformClassesWithMultidexlistForFreeDebug'。 在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:110) 在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.execute(ExecuteActionsTaskExecuter.java:77) 在org.gradle.api.internal.tasks.execution.OutputDirectoryCreatingTaskExecuter.execute(OutputDirectoryCreatingTaskExecuter.java:51)处 在org.gradle.api.internal.tasks.execution.SkipUpToDateTaskExecuter.execute(SkipUpToDateTaskExecuter.java:59) 在org.gradle.api.internal.tasks.execution.ResolveTaskOutputCachingStateExecuter.execute(ResolveTaskOutputCachingStateExecuter.java:54) 在org.gradle.api.internal.tasks.execution.ValidatingTaskExecuter.execute(ValidatingTaskExecuter.java:59) 在org.gradle.api.internal.tasks.execution.SkipEmptySourceFilesTaskExecuter.execute(SkipEmptySourceFilesTaskExecuter.java:101)处 在org.gradle.api.internal.tasks.execution.FinalizeInputFilePropertiesTaskExecuter.execute(FinalizeInputFilePropertiesTaskExecuter.java:44) 在org.gradle.api.internal.tasks.execution.CleanupStaleOutputsExecuter.execute(CleanupStaleOutputsExecuter.java:91) 在org.gradle.api.internal.tasks.execution.ResolveTaskArtifactStateTaskExecuter.execute(ResolveTaskArtifactStateTaskExecuter.java:62)处 在org.gradle.api.internal.tasks.execution.SkipTaskWithNoActionsExecuter.execute(SkipTaskWithNoActionsExecuter.java:59) 在org.gradle.api.internal.tasks.execution.SkipOnlyIfTaskExecuter.execute(SkipOnlyIfTaskExecuter.java:54) 在org.gradle.api.internal.tasks.execution.ExecuteAtMostOnceTaskExecuter.execute(ExecuteAtMostOnceTaskExecuter.java:43) 在org.gradle.api.internal.tasks.execution.CatchExceptionTaskExecuter.execute(CatchExceptionTaskExecuter.java:34) 在org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter $ 1.run(EventFiringTaskExecuter.java:51) 在org.gradle.internal.operations.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)处 在org.gradle.internal.operations.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)处 在org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174) 在org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90) 在org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31) 在org.gradle.api.internal.tasks.execution.EventFiringTaskExecuter.execute(EventFiringTaskExecuter.java:46) 在org.gradle.execution.taskgraph.LocalTaskInfoExecutor.execute(LocalTaskInfoExecutor.java:42) 在org.gradle.execution.taskgraph.DefaultTaskExecutionGraph $ BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:273)处 在org.gradle.execution.taskgraph.DefaultTaskExecutionGraph $ BuildOperationAwareWorkItemExecutor.execute(DefaultTaskExecutionGraph.java:258)处 在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ ExecutorWorker $ 1.execute(DefaultTaskPlanExecutor.java:135)处 在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ ExecutorWorker $ 1.execute(DefaultTaskPlanExecutor.java:130)处 在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ ExecutorWorker.execute(DefaultTaskPlanExecutor.java:200)处 在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ ExecutorWorker.executeWithWork(DefaultTaskPlanExecutor.java:191)处 在org.gradle.execution.taskgraph.DefaultTaskPlanExecutor $ ExecutorWorker.run(DefaultTaskPlanExecutor.java:130)处 在org.gradle.internal.concurrent.ExecutorPolicy $ CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63) 在org.gradle.internal.concurrent.ManagedExecutorImpl $ 1.run(ManagedExecutorImpl.java:46) 在org.gradle.internal.concurrent.ThreadFactoryImpl $ ManagedThreadRunnable.run(ThreadFactoryImpl.java:55) 造成原因:java.lang.RuntimeException: com.android.build.api.transform.TransformException:时出错 生成主要的dex列表。 在com.android.builder.profile.Recorder $ Block.handleException(Recorder.java:55) 在com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:104) 在com.android.build.gradle.internal.pipeline.TransformTask.transform(TransformTask.java:212) 在java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(本机 方法) 在java.base / jdk.internal.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) 在java.base / jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) 在org.gradle.internal.reflect.JavaMethod.invoke(JavaMethod.java:73) 在org.gradle.api.internal.project.taskfactory.IncrementalTaskAction.doExecute(IncrementalTaskAction.java:50) 在org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:39) 在org.gradle.api.internal.project.taskfactory.StandardTaskAction.execute(StandardTaskAction.java:26) 在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter $ 1.run(ExecuteActionsTaskExecuter.java:131) 在org.gradle.internal.operations.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:300)处 在org.gradle.internal.operations.DefaultBuildOperationExecutor $ RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:292)处 在org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:174) 在org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:90) 在org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31) 在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeAction(ExecuteActionsTaskExecuter.java:120)处 在org.gradle.api.internal.tasks.execution.ExecuteActionsTaskExecuter.executeActions(ExecuteActionsTaskExecuter.java:99) ... 31更多原因:com.android.build.api.transform.TransformException:错误 生成主要的dex列表。 在com.android.build.gradle.internal.transforms.D8MainDexListTransform.transform(D8MainDexListTransform.kt:127) 在com.android.build.gradle.internal.pipeline.TransformTask $ 2.call(TransformTask.java:221) 在com.android.build.gradle.internal.pipeline.TransformTask $ 2.call(TransformTask.java:217) 在com.android.builder.profile.ThreadRecorder.record(ThreadRecorder.java:102) ... 47更多原因:com.android.builder.multidex.D8MainDexList $ MainDexListException: com.android.tools.r8.errors.CompilationError:程序类型已经 礼物:android.support.v4.graphics.drawable.RoundedBitmapDrawable 在com.android.builder.multidex.D8MainDexList.generate(D8MainDexList.java:87) 在com.android.build.gradle.internal.transforms.D8MainDexListTransform.transform(D8MainDexListTransform.kt:114) ... 50更多原因:com.android.tools.r8.errors.CompilationError:程序类型已经 礼物:android.support.v4.graphics.drawable.RoundedBitmapDrawable 在com.android.tools.r8.utils.ProgramClassCollection.resolveClassConflictImpl(ProgramClassCollection.java:64) 在com.android.tools.r8.utils.ProgramClassCollection.lambda $ create $ 0(ProgramClassCollection.java:25) 在com.android.tools.r8.utils.ProgramClassCollection.create(ProgramClassCollection.java:24) 在com.android.tools.r8.graph.LazyLoadedDexApplication $ Builder.build(LazyLoadedDexApplication.java:121) 在com.android.tools.r8.dex.ApplicationReader.read(ApplicationReader.java:122) 在com.android.tools.r8.dex.ApplicationReader.read(ApplicationReader.java:86) 在com.android.tools.r8.GenerateMainDexList.run(GenerateMainDexList.java:40) 在com.android.tools.r8.GenerateMainDexList.run(GenerateMainDexList.java:110) 在com.android.builder.multidex.D8MainDexList.generate(D8MainDexList.java:83) ...还有51个
GitHub项目链接:https://github.com/Kurosakicoder/BuildItBiggerGradle-master
答案 0 :(得分:1)
您的应用程序类别如何? 如果没有,则需要创建一个并将其名称放入清单中 那里的代码应该像这样
AndroidManifest.xml
<application
android:name="ApplicationName"
...
>
,您的应用程序类别将是:
public class ApplicationName extends MultiDexApplication{
.....
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
MultiDex.install(this);
}
}
更新 我注意到您使用
release {
minifyEnabled true
shrinkResources true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.config
}
当您在调试中运行应用程序时,此方法不起作用。尝试导出版本(如果可行),则需要在调试构建类型中添加这些配置