首页 > 系统 > Android > 正文

AndroidStudio签名打包爬坑记

2019-11-06 09:46:05
字体:
来源:转载
供稿:网友

昨天发布了两个APP,分别爬坑两次,每次都可以遇到一个新的问题发火大哭

第一坑:Error:Error: Expected resource of type id [ResourceType]  这个错误修改gradle(moudle:app)这个文件

android {    compileSdkVersion 17    buildToolsVersion "23.0.3"    defaultConfig {        applicationId "com.ledict.LawActivity"        minSdkVersion 8        targetSdkVersion 21        versionCode 1        versionName "1.0"        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"    }    buildTypes {        release {            minifyEnabled false            PRoguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'        }    }}修改为:
android {    compileSdkVersion 17    buildToolsVersion "23.0.3"    defaultConfig {        applicationId "com.ledict.LawActivity"        minSdkVersion 8        targetSdkVersion 21        versionCode 1        versionName "1.0"        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"    }    buildTypes {        release {            minifyEnabled false            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'        }    }    lintOptions {        disable "ResourceType"    }}在android{}中新加入lintOptions,即可解决。

第二坑:这个项目是从eclipse中迁移过来,打包的时候发现只有一个build.gradle一个文件,由于需要指定的版本名和版本号等,当时我是蒙了。经过一番折腾,在android{}下手动写入defaultConfig{},然后就可以在defaultConfig{}中配置一些打包信息。从eclipse中迁过来的项目默认只有一个gradle文件,这个gradle文件中没有defaultConfig{},需要自己手动写入。

android {    compileSdkVersion 19    buildToolsVersion "24.0.2"    defaultConfig {        applicationId "com.ledict.CaseActivity"        minSdkVersion 8        targetSdkVersion 21        versionCode 1        versionName "1.0"        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"    }    sourceSets {        main {            manifest.srcFile 'AndroidManifest.xml'            java.srcDirs = ['src']            resources.srcDirs = ['src']            aidl.srcDirs = ['src']            renderscript.srcDirs = ['src']            res.srcDirs = ['res']            assets.srcDirs = ['assets']        }        // Move the tests to tests/java, tests/res, etc...        instrumentTest.setRoot('tests')        // Move the build types to build-types/<type>        // For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...        // This moves them out of them default location under src/<type>/... which would        // conflict with src/ being used by the main source set.        // Adding new build types or product flavors should be accompanied        // by a similar customization.        debug.setRoot('build-types/debug')        release.setRoot('build-types/release')    }}边工作边学习,不对的地方欢迎拍砖奋斗


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表