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
- 前端報錯:cannot read property length of undefined前端Undefined
- BUG——AngularJS:Cannot set property ‘pic‘ of undefinedAngularJSUndefined
- vue+echarts報錯Cannot read property ‘init‘ of underfinedVueEcharts
- 執行專案報錯Cannot read property 'styles' of undefinedUndefined
- Cannot set property ‘dataIndex‘ of undefined 大資料關係圖報錯,賦予的資料有重複,去重AIIndexUndefined大資料
- el-tree 報錯 TypeError: Cannot read property ‘setCheckedKeys‘ of undefined“ErrorUndefined
- 自定義 ocelot 中介軟體輸出自定義錯誤資訊
- 自定義AndroidStudio程式碼模板Android
- su - oracle報錯su: cannot set user id: Resource temporarily unavailableOracleAI
- 452 Error writing file: A file cannot be larger than the value set by ulimit.ErrorMIT
- 在AS中自定義字型庫報錯:java.lang.RuntimeException: native typeface cannot be made自定義字型JavaException
- mysql匯入報錯Variable 'sql_notes' can't be set to the value of 'NULL'MySqlNull
- log-bin自定義路徑報錯
- python 報錯:raise IllegalCharacterError(f"{value} cannot be used in worksheets.") openpyxl.utils.exceptions.IllegalCharacterErrorPythonAIErrorException
- 開發中遇到的bug-Cannot set property ‘__VUE_DEVTOOLS_UID__‘ of nullVuedevUINull
- 自定義JSON名JSON
- [譯] 避免那些可惡的 "cannot read property of undefined" 錯誤Undefined
- Flask_restful 之 自定義錯誤資訊FlaskREST
- 安卓Property Animator動畫詳解(二)-自定義屬性安卓動畫
- Need to set ‘serverTimezone‘ propertyServer
- 皕傑報表之自定義函式函式
- Cannot read property ‘aDataSort‘ of undefinedUndefined
- oracle 之 CLUSTER_INTERCONNECTS is not set to the recommended valueOracle
- React報錯之Function components cannot have string refsReactFunction
- 【報錯】elasticsearch 報錯blocked by: [FORBIDDEN/12/index read-only / allow delete (api)]ElasticsearchBloCORBIndexdeleteAPI
- Artisan 自定義輸出格式
- 自定義UITextView輸入框UITextView
- (排坑) Cannot create property 'key' on boolean 'true'Boolean
- js提示Cannot read property ‘replace‘ of undefinedJSUndefined
- 使用req.session.xxx時出現 Cannot set property ‘xxxx‘ of undefinedSessionUndefined
- VS code 自定義快捷輸入
- cannot access local variable where it is not associated with a value
- Android View篇之自定義驗證碼輸入框AndroidView
- React Native 自定義鍵盤之輸入車牌號React Native
- How to update BOL entity property value via ABAP code
- 使用普通使用者set autotrace on報錯SP2-0618: Cannot find the Session IdentifierSessionIDE