AndroidStudio之自定義輸出包名報錯 Cannot set the value of read-only property 'outputFile' for
AndroidStudio 3.0後,自定義apk包名出錯: Cannot set the value of read-only property 'outputFile' for ApkVariantOutputImpl_Decorated{apkData=Main{type=MAIN, fullName=debug, filters=[]}} of type com.android.build.gradle.internal.api.ApkVariantOutputImpl.
解決方案直接貼程式碼吧:
在app.gradle的android節點中新增
android {
....................
....................
buildTypes {
release {
// 使用混淆:true
minifyEnabled false
// Zipalign優化
//zipAlignEnabled true
// 移除無用的resource檔案
//shrinkResources true
// 前一部分代表系統預設的android程式的混淆檔案,該檔案已經包含了基本的混淆宣告,後一個檔案是自己的定義混淆檔案
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
// 自定義包名
applicationVariants.all { variant ->
variant.outputs.all { output ->
// test_版本號_yyyymmdd_release.apk
def fileName = "test_release_${variant.versionName}_${releaseTime()}.apk"
def outFile = output.outputFile
if (outFile != null && outFile.name.endsWith('.apk')) {
outputFileName = fileName
}
}
}
}
}
....................
....................
}
def releaseTime() {
return new Date().format("yyyyMMdd", TimeZone.getTimeZone("UTC"))
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
}
相關文章
- Cannot set property 'innerHTML' of nullHTMLNull
- Cannot set property ‘type‘ of null(vue)NullVue
- BUG——AngularJS:Cannot set property ‘pic‘ of undefinedAngularJSUndefined
- 前端報錯:cannot read property length of undefined前端Undefined
- Java更新資料庫報錯:Data truncation: Cannot create a JSON value from a string with CHARACTER SETJava資料庫JSON
- vue+echarts報錯Cannot read property ‘init‘ of underfinedVueEcharts
- 執行專案報錯Cannot read property 'styles' of undefinedUndefined
- el-tree 報錯 TypeError: Cannot read property ‘setCheckedKeys‘ of undefined“ErrorUndefined
- 自定義AndroidStudio程式碼模板Android
- Cannot set property ‘dataIndex‘ of undefined 大資料關係圖報錯,賦予的資料有重複,去重AIIndexUndefined大資料
- 使用req.session.xxx時出現 Cannot set property ‘xxxx‘ of undefinedSessionUndefined
- 自定義 ocelot 中介軟體輸出自定義錯誤資訊
- 開發中遇到的bug-Cannot set property ‘__VUE_DEVTOOLS_UID__‘ of nullVuedevUINull
- Need to set ‘serverTimezone‘ propertyServer
- oracle 之 CLUSTER_INTERCONNECTS is not set to the recommended valueOracle
- Cannot read property ‘aDataSort‘ of undefinedUndefined
- [譯] 避免那些可惡的 "cannot read property of undefined" 錯誤Undefined
- python 報錯:raise IllegalCharacterError(f"{value} cannot be used in worksheets.") openpyxl.utils.exceptions.IllegalCharacterErrorPythonAIErrorException
- 自定義JSON名JSON
- React報錯之Function components cannot have string refsReactFunction
- Server returns invalid timezone. Need to set ‘serverTimezone‘ property. Idea連線mysql報錯問題ServerIdeaMySql
- 【報錯】elasticsearch 報錯blocked by: [FORBIDDEN/12/index read-only / allow delete (api)]ElasticsearchBloCORBIndexdeleteAPI
- js提示Cannot read property ‘replace‘ of undefinedJSUndefined
- allowedOrigins cannot contain the gateway 報錯AIGateway
- Flask_restful 之 自定義錯誤資訊FlaskREST
- AndroidStudio之NDK常見編譯錯誤Android編譯
- echarts:Uncaught TypeError: Cannot read property '0' of undefinedEchartsErrorUndefined
- (排坑) Cannot create property 'key' on boolean 'true'Boolean
- VSCode自定義快捷輸入VSCode
- Artisan 自定義輸出格式
- 皕傑報表之自定義函式函式
- React Native 自定義鍵盤之輸入車牌號React Native
- Android View篇之自定義驗證碼輸入框AndroidView
- gateway 報錯 allowedOrigins cannot contain the specialGatewayAI
- cannot access local variable where it is not associated with a value
- How to update BOL entity property value via ABAP code
- 安卓Property Animator動畫詳解(二)-自定義屬性安卓動畫
- Hadoop自定義輸出排序方式Hadoop排序