2

生成签名的 apk 时发生错误。生成可调试的 apk 时工作正常。安卓工作室 2.3 版。我在 gradle 文件中添加了以下代码,但它不起作用。

packagingOptions {
    exclude 'META-INF/LICENSE.txt'
    exclude 'META-INF/NOTICE.txt'
    exclude '...'
}


Information:Gradle tasks [:app:assembleRelease]  
Warning:can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [constraint-layout-solver-1.0.2.jar:META-INF/MANIFEST.MF])
Warning:can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [classes.jar:META-INF/MANIFEST.MF])
Warning:can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [android.justified-1.0.jar:META-INF/MANIFEST.MF])
Warning:can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [classes.jar:META-INF/MANIFEST.MF])
Warning:can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [support-annotations-25.1.0.jar:META-INF/MANIFEST.MF])
Warning:can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [picasso-2.5.0.jar:META-INF/MANIFEST.MF])
Warning:can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [library-2.4.0.jar:META-INF/MANIFEST.MF])
Warning:can't write resource [META-INF/MANIFEST.MF] (Duplicate zip entry [classes.jar:META-INF/MANIFEST.MF])

Error:trouble processing "java/io/BufferedInputStream.class":
Error:Ill-advised or mistaken usage of a core class (java.* or javax.*)
Error:when not building a core library.
Error:This is often due to inadvertently including a core library file
Error:in your application's project, when using an IDE (such as
Error:Eclipse). If you are sure you're not intentionally defining a
Error:core class, then this is the most likely explanation of what's
going on.
Error:However, you might actually be trying to define a class in a core
Error:namespace, the source of which you may have taken, for example,
Error :from a non-Android virtual machine project. This will most
Error:assuredly not work. At a minimum, it jeopardizes the
Error:compatibility of your app with future versions of the platform.
Error:It is also often of questionable legality.
Error:If you really intend to build a core library -- which is only
Error:appropriate as part of creating a full virtual machine
Error:distribution, as opposed to compiling an application -- then use
Error:the "--core-library" option to suppress this error message.
Error:If you go ahead and use "--core-library" but are in fact
Error:building an application, then be forewarned that your application
Error:will still fail to build or run, at some point. Please be
Error:prepared for angry customers who find, for example, that your
Error:application ceases to function once they upgrade their operating
Error:system. You will be to blame for this problem.
Error:If you are legitimately using some code that happens to be in a
Error:core package, then the easiest safe alternative you have is to
Error:repackage that code. That is, move the classes in question into
Error:your own package namespace. This means that they will never be in
Error:conflict with core system classes. JarJar is a tool that may help
Error:you in this endeavor. If you find that you cannot do this, then
Error:that is an indication that the path you are on will ultimately
Error:lead to pain, suffering, grief, and lamentation.
Error:1 error; aborting

Error:Execution failed for task ':app:transformClassesWithDexForRelease'.
  com.android.build.api.transform.TransformException: 
  com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: 
  com.android.ide.common.process.ProcessException: Return code 1 for dex process

Information:BUILD FAILED

这是 app.gradle 文件。Multidex 启用,缩小禁用。我从 gradle 文件中删除了一些未使用的库。可复制的 apk 生成没有任何问题。

apply plugin: 'com.android.application'

android {
    signingConfigs {
        cybernet {
            keyAlias 'myalias'
            keyPassword 'password'
            storeFile file('E:/storefile.jks')
            storePassword 'password'
        }
    }

    compileSdkVersion 25
    buildToolsVersion "25.0.2"
    defaultConfig {
        applicationId "com.cybernetvpn.cybernetvpn"
        minSdkVersion 16
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        applicationId "com.cybernetvpn.cybernetvpn"
        testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
        //vectorDrawables.useSupportLibrary = true
        multiDexEnabled true
        signingConfig signingConfigs.cybernet
    }
    buildTypes {
        release {
            minifyEnabled false
            //shrinkResources true
            proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            signingConfig signingConfigs.cybernet
            debuggable false
        }
        debug {
            //debuggable false
            //signingConfig signingConfigs.cybernet
        }
    }
    productFlavors {
    }
}

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 'be.appfoundry.progressbuttonlibrary:progressbutton:0.9.3'
    compile 'me.drakeet.materialdialog:library:1.3.1'
    compile 'com.android.support:appcompat-v7:25.1.0'
    compile 'cn.pedant.sweetalert:library:1.3'
    compile 'com.sefford:circular-progress-drawable:1.31@aar'
    compile 'com.dmitrymalkovich.android:progress-fab:1.6'
    compile 'com.android.support:multidex:1.0.1'
    compile 'com.github.dmytrodanylyk.circular-progress-button:library:1.1.3'
    compile 'com.uncopt:android.justified:1.0'
    compile 'com.github.florent37:materialtextfield:1.0.7'
    compile 'com.android.support:design:25.1.0'
    compile 'com.wang.avi:library:2.1.3'
    compile 'com.romainpiel.shimmer:library:1.4.0@aar'
    compile 'com.android.support:support-v4:25.1.0'
    compile 'com.tuyenmonkey:mkloader:1.2.0'
    compile 'com.android.support:support-vector-drawable:25.1.0'
    compile 'com.android.support:cardview-v7:25.1.0'
    testCompile 'junit:junit:4.12'
    compile 'com.mxn.soul:flowingdrawer-core:2.0.0'
    compile 'com.nineoldandroids:library:2.4.0'
    compile 'com.squareup.picasso:picasso:2.5.0'
    compile 'com.android.support.constraint:constraint-layout:1.0.2'
}
4

0 回答 0