首先,这是一个演示。在学习如何使用gradle的过程中,我想为apk添加自定义buildTypes,这是我的应用程序模块app-> build.gradle
apply plugin: 'com.android.application'
apply plugin: 'android-aspectjx'
apply plugin: 'patcher'
apply plugin: 'kotlintest'
apply plugin: 'javaTest'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.person.ermao.aoptest"
minSdkVersion 15
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
applicationIdSuffix ".debug"
debuggable true
}
staging {
initWith debug
manifestPlaceholders = [hostName:"internal.example.com"]
applicationIdSuffix ".debugStaging"
}
}
// splits {
// // Settings to build multiple APKs based on screen density.
// density {
//
// // Enable or disable building multiple APKs.
// enable true
//
// // Exclude these densities when building multiple APKs.
// exclude "ldpi", "tvdpi", "xxxhdpi", "400dpi", "560dpi"
// }
// }
patcher {
sourceApk "com.person.ermao"
ignoreWarning true
useSign true
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
aspectjx {
//排除所有package路径中包含`android.support`的class文件及库(jar文件)
exclude 'android.support'
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
androidTestImplementation('io.mockk:mockk-android:1.9.3') { exclude module: 'objenesis' }
androidTestImplementation 'org.objenesis:objenesis:2.6'
implementation project(':aop')
}
我遇到了一些错误:
最佳答案
尝试为每个变体添加另一个字段:
matchingFallbacks = ['Put Hear The Variant Name'] ///对于未定义此变体的项目
关于android - 设置Custom buildTypes时出现错误,谁能帮助我?,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/57306984/