预期名称,但STRING在第1行第99行路径$ [0] .apkInfo.versionName

use*_*014 26 android gradle

我升级到gradle到3.1.1,但现在我想再次更改为3.0.1但在更改为3.0.1后,我收到此错误

预期名称,但STRING在第1行第99行路径$ [0] .apkInfo.versionName

我以前使用3.0.1并且它工作得很好但是在android studio更新后我改变了.

只有在生成签名的apk时才会出现错误.

Project Gradle

buildscript {

repositories {
    google()
    jcenter()
}
dependencies {
    classpath 'com.android.tools.build:gradle:3.0.1'


    // NOTE: Do not place your application dependencies here; they belong
    // in the individual module build.gradle files
}
}

 allprojects {
repositories {
    google()
    jcenter()
    maven { url "https://jitpack.io" }
}
}

task clean(type: Delete) {
delete rootProject.buildDir
}
Run Code Online (Sandbox Code Playgroud)

App gradle

apply plugin: 'com.android.application'

android {
compileSdkVersion 27
defaultConfig {
    applicationId "com.smiles.smartstuddy"
    minSdkVersion 16
    targetSdkVersion 27
    versionCode 4
    versionName "1.1"
    testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
    vectorDrawables.useSupportLibrary = true
}
packagingOptions {
    exclude 'META-INF/DEPENDENCIES'
    exclude 'META-INF/LICENSE'
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/license.txt'
    exclude 'META-INF/NOTICE'
    exclude 'META-INF/NOTICE.txt'
    exclude 'META-INF/notice.txt'
    exclude 'META-INF/ASL2.0'
}
buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
    }
}
}

dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.android.support:support-v13:27.1.1'
compile 'com.github.lzyzsd:circleprogress:1.2.1'
compile 'dev.dworks.libs:volleyplus:+'
implementation files('libs/YouTubeAndroidPlayerApi.jar')
compile 'de.hdodenhof:circleimageview:2.1.0'
compile 'commons-io:commons-io:2.4'
compile 'com.github.bumptech.glide:glide:4.6.1'
compile 'es.voghdev.pdfviewpager:library:1.0.3'
 }
Run Code Online (Sandbox Code Playgroud)

Dan*_*oss 32

检查将生成.apk 的release文件夹.如果存在任何现有的.apk或.json文件,则删除或移动到其他位置.尝试再次生成您签名的apk,您应该会成功.

  • 特别是删除output.json就足够了. (3认同)

小智 27

我在同一个用例中得到了同样的错误,为我修复的是清理和重建项目.

  • 什么工作是改变输出目录...我不知道为什么,但如果它有助于原始输出目录与另一个应用程序(同一代文件夹)共享. (9认同)