【发布时间】:2017-10-28 18:38:06
【问题描述】:
我已将 Android Studio 更新到最新的 Canary 版本,但现在我无法运行我的应用。
每次我尝试构建项目时都会收到以下错误:
Error:F:\...\**app_name**\app\build\intermediates\instant-run-support\debug\slice_0\AndroidManifest.xml:2 attribute 'android:versionCode' not found
我尝试手动打开文件,属性明显存在:
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="****"
android:versionCode="1"
android:versionName="1.0"
split="lib_slice_0_apk">
</manifest>
我尝试清理项目,使缓存无效,重新启动 android studio 但没有任何帮助。
这是我的build.gradle (app) 文件:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
android {
compileSdkVersion 25
buildToolsVersion "25.0.3"
defaultConfig {
applicationId "****"
minSdkVersion 16
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
androidTestCompile('com.android.support.test.espresso:espresso-core:2.2.2', {
exclude group: 'com.android.support', module: 'support-annotations'
})
compile "org.jetbrains.kotlin:kotlin-stdlib-jre7:$kotlin_version"
compile 'com.android.support:appcompat-v7:25.3.1'
testCompile 'junit:junit:4.12'
compile 'com.android.support.constraint:constraint-layout:1.0.2'
compile 'com.android.support:design:25.3.1'
compile 'com.android.support:cardview-v7:25.3.1'
compile 'com.squareup.picasso:picasso:2.5.2'
}
【问题讨论】:
-
我也有同样的问题!
-
升级后山姆问题
-
添加到清单对我有用 package="..." android:versionCode="1" android:versionName="1.0" > 无需禁用 InstantRun
-
即使我将
versionCode和versionName明确添加到<manifest>,我有时也会收到错误消息。然后在 Gradle 项目 视图中点击 Refresh all gradle projects 帮助
标签: android-studio android-studio-3.0