我正在研究构建类型的基础知识,并尝试为我的应用程序创建发布和调试风格。首先,我在我的应用程序的根文件夹中创建了一个目录配置。然后我生成了一个签名的APK密钥并将路径设置为config目录。然后我在build.gradle中进行了以下更改。以下是我的build.gradle文件。
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "26.0.0"
defaultConfig {
applicationId "com.example.sarthak.chitchatmessagingapp"
minSdkVersion 21
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
signingConfigs {
chitchatReleaseConfig {
storeFile file("../config/releaseapkkey.jks");
storePassword("123456");
keyAlias("releaseapkkey");
keyPassword("123456");
}
}
buildTypes {
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
} release {
minifyEnabled true
zipAlignEnabled true
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.chitchatReleaseConfig
} releaseDebug {
debuggable true
minifyEnabled true
zipAlignEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
signingConfig signingConfigs.chitchatReleaseConfig
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.google.firebase:firebase-auth:10.0.1'
compile 'com.google.firebase:firebase-database:10.0.1'
compile 'com.google.firebase:firebase-storage:10.0.1'
compile 'com.firebaseui:firebase-ui-database:1.1.1'
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'com.squareup.picasso:picasso:2.5.2'
compile 'com.squareup.okhttp:okhttp:2.4.0'
compile 'com.theartofdev.edmodo:android-image-cropper:2.4.+'
compile 'id.zelory:compressor:2.0.0'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.google.firebase:firebase-messaging:10.0.1'
testCompile 'junit:junit:4.12'
}
apply plugin: 'com.google.gms.google-services'
但是,我一直收到以下错误。
Error:(25, 0) Could not find method release() for arguments [build_ehqm3plmr2s7xq0x3e59oqqgt$_run_closure1$_closure5$_closure8@7595456a] on BuildType_Decorated{name=debug, debuggable=true, testCoverageEnabled=false, jniDebuggable=false, pseudoLocalesEnabled=false, renderscriptDebuggable=false, renderscriptOptimLevel=3, minifyEnabled=false, zipAlignEnabled=true, signingConfig=SigningConfig_Decorated{name=debug, storeFile=C:\Users\Sarthak\.android\debug.keystore, storePassword=android, keyAlias=AndroidDebugKey, keyPassword=android, storeType=C:\Users\Sarthak\.android\debug.keystore, v1SigningEnabled=true, v2SigningEnabled=true}, embedMicroApp=false, mBuildConfigFields={}, mResValues={}, mProguardFiles=[C:\Users\Sarthak\Documents\AndroidProjects\ChitChat Messaging App\build\intermediates\proguard-files\proguard-android.txt-2.3.2, C:\Users\Sarthak\Documents\AndroidProjects\ChitChat Messaging App\app\proguard-rules.pro], mConsumerProguardFiles=[], mManifestPlaceholders={}} of type com.android.build.gradle.internal.dsl.BuildType.
有人可以帮我弄清楚错误是什么吗?
答案 0 :(得分:1)
在每个buildType之前添加换行符:
buildTypes {
debug {
...
}
release {
...
}
releaseDebug {
...
}
}
也就是说,不要将新的buildType放在与前一个buildType的右括号相同的行上,如} release {
我能够通过使用你的风格在我的项目中触发你的问题。我能够按照我的建议添加换行符来修复它。这必须与Gradle进行解析的方式有关。