android studio升級3.0版本,問題處理

來源:互聯網
上載者:User

標籤:opera   config   intern   b2c   圖片   warnings   sde   center   baidu   

android studio升級3.0版本,問題處理問題1:編譯版本與構建版本修改

compileSdkVersion : 26, 
buildToolsVersion : “26.0.2”, 
gradle版本: 
distributionUrl=https://services.gradle.org/distributions/gradle-4.1-all.zip 
classpath ‘com.android.tools.build:gradle:3.0.0’

問題2:apk名稱配置調整,build有一個outputFileName ,直接配置
Error:(120, 0) 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.<a href="openFile:D:\Android\workspace_zhy\qufish_office\app\build.gradle">Open File</a>

            //輸出apk配置            applicationVariants.all { variant ->                variant.outputs.each { output ->                    def outputFile = output.outputFile                    if (outputFile != null && outputFile.name.endsWith(‘.apk‘)) {                        // 輸出apk名稱                        def fileName                        if (variant.buildType.zipAlignEnabled) {                            //正式版本                            fileName =  "XX_${defaultConfig.versionName}_${packageTime()}_${buildType.name}.apk"                        } else {                            fileName = "XX_${defaultConfig.versionName}_${packageTime()}_${buildType.name}.apk"                        }                        output.outputFile = new File(outputFile.parent, fileName)                    }                }            }

調整後

            applicationVariants.all {                outputs.all {                    // 輸出apk名稱                    def newApkName                    if (buildType.zipAlignEnabled) {                        newApkName = "XX_${defaultConfig.versionName}_${packageTime()}_${buildType.name}.apk"                    } else {                        newApkName = "XX_${defaultConfig.versionName}_${packageTime()}_${buildType.name}.apk"                    }                    outputFileName = newApkName                }            }
問題3:如果你有配置多渠道包,會報錯dimension
//android{}內flavorDimensions "color"productFlavors {        baidu {//每個渠道多家一個這個配置            dimension "color"...        }}
問題4:

compile ‘com.android.support:multidex:1.0.1’

倉庫位置調整到google,需要在配置倉庫的地方加入google()(報錯的時候直接點擊下也可以自動添加這個倉庫),另外multidex的版本號碼升級到1.0.2

allprojects {    repositories {        jcenter()        mavenCentral()        maven { url ‘https://jitpack.io‘ }        google()    }}
問題5:

Information:Gradle tasks [:pickerview:generateDebugSources, :pickerview:generateDebugAndroidTestSources, :pickerview:mockableAndroidJar, :zhxflib:generateDebugSources, :zhxflib:generateDebugAndroidTestSources, :zhxflib:mockableAndroidJar, :wigetlib:generateDebugSources, :wigetlib:generateDebugAndroidTestSources, :wigetlib:mockableAndroidJar, :app:generateDebugSources, :app:generateDebugAndroidTestSources, :app:mockableAndroidJar] 
D:\zhihuixinfanWorkerSpace\ZhiHuiXinFan\app\build\intermediates\manifests\full\debug\AndroidManifest.xml 
Error:(12) error: unknown element found. 
Error:(12) unknown element found. 
Error:java.util.concurrent.ExecutionException: java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details 
Error:java.util.concurrent.ExecutionException: com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details 
Error:com.android.tools.aapt2.Aapt2Exception: AAPT2 error: check logs for details 
Error:Execution failed for task ‘:app:processDebugResources’. 
Failed to execute aapt 
Information:BUILD FAILED in 8s 
Information:6 errors 
Information:0 warnings 
Information:See complete output in console

解決方案:

在項目的gradle.properties中: 
android.enableAapt2=false

android studio升級3.0版本,問題處理

相關文章

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.