Android Studio Gradle not working during build

Here is my problematic scenario:

I cannot create and run my application in Android studio. It seems to not work before installing apk with error below. However, when I create the application through the command line using the gradle shell, everything goes smoothly. Obviously, this is not ideal, as other team members need to use the project, and the IDE interface for the Android studio should be sufficient.

When I create and run my application in Android Studio, I get an error message during the build steps:

transformClassesAndResourcesWithProguardForRelease FAILED 

path may not be null or empty: path='null'

However, when I invoke the command:

./gradlew cleanRelease assembleRelease installRelease,

This creates and installs a working version on the device.

I can also Build-> Generate Signed Apk and it works.

( > ) Android - , ... , , , , .

:

? null? .

apply plugin: 'com.android.application'

////Grab location of opencv sdk
String systemHome = System.getenv('HOME');
File libDir = new File(systemHome + "/Library/Android/sdk/OpenCV-android-sdk");

//If home directory exists choose this path, otherwise we're doing CI 
//with jenkins so we can hardcode this ...
String opencvSdkPath =
    (libDir != null && libDir.isDirectory()) ?
            systemHome + "/Library/Android/sdk/OpenCV-android-sdk/sdk/native/libs"
            :
            "/Users/userx/Library/Android/OpenCV-android-sdk/sdk/native/libs";

println("Look for opencv within " + opencvSdkPath)

android {
signingConfigs {
    XSigningCredentials {
        keyAlias 'asdfsdf'
        keyPassword 'asdfasdf'
        storeFile file('asdfsdf.jks')
        storePassword 'asdfsdf'
    }
}
compileSdkVersion 25
buildToolsVersion '25.0.2'
//Give the default configurations for gradles build
defaultConfig {
    //Package name
    applicationId "a.b.c"

    //Minimum working sdk
    minSdkVersion 19

    //Target sdk with support
    targetSdkVersion 25

    //Actual version ID
    versionCode vrsCode as Integer

    //Google play visible version string
    versionName vrsCustomerFacingCode

    multiDexEnabled true

    ndk {
        abiFilters 'armeabi', 'armeabi-v7a', 'x86'
    }
    externalNativeBuild {
        cmake {
            cppFlags "-std=c++11" ,
                    "-latomic",
                    "-DASSIMP_BUILD_NO_X_IMPORTER",
                    "-DASSIMP_BUILD_NO_3DS_IMPORTER",
                    "-DASSIMP_BUILD_NO_MD3_IMPORTER",
                    "-DASSIMP_BUILD_NO_MDL_IMPORTER",
                    "-DASSIMP_BUILD_NO_MD2_IMPORTER",
                    "-DASSIMP_BUILD_NO_PLY_IMPORTER",
                    "-DASSIMP_BUILD_NO_ASE_IMPORTER",
                    "-DASSIMP_BUILD_NO_HMP_IMPORTER",
                    "-DASSIMP_BUILD_NO_SMD_IMPORTER",
                    "-DASSIMP_BUILD_NO_MDC_IMPORTER",
                    "-DASSIMP_BUILD_NO_MD5_IMPORTER",
                    "-DASSIMP_BUILD_NO_STL_IMPORTER",
                    "-DASSIMP_BUILD_NO_LWO_IMPORTER",
                    "-DASSIMP_BUILD_NO_DXF_IMPORTER",
                    "-DASSIMP_BUILD_NO_NFF_IMPORTER",
                    "-DASSIMP_BUILD_NO_RAW_IMPORTER",
                    "-DASSIMP_BUILD_NO_OFF_IMPORTER",
                    "-DASSIMP_BUILD_NO_AC_IMPORTER",
                    "-DASSIMP_BUILD_NO_BVH_IMPORTER",
                    "-DASSIMP_BUILD_NO_IRRMESH_IMPORTER",
                    "-DASSIMP_BUILD_NO_IRR_IMPORTER",
                    "-DASSIMP_BUILD_NO_Q3D_IMPORTER",
                    "-DASSIMP_BUILD_NO_B3D_IMPORTER",
                    "-DASSIMP_BUILD_NO_COLLADA_IMPORTER",
                    "-DASSIMP_BUILD_NO_TERRAGEN_IMPORTER",
                    "-DASSIMP_BUILD_NO_CSM_IMPORTER",
                    "-DASSIMP_BUILD_NO_3D_IMPORTER",
                    "-DASSIMP_BUILD_NO_LWS_IMPORTER",
                    "-DASSIMP_BUILD_NO_OGRE_IMPORTER",
                    "-DASSIMP_BUILD_NO_MS3D_IMPORTER",
                    "-DASSIMP_BUILD_NO_COB_IMPORTER",
                    "-DASSIMP_BUILD_NO_Q3BSP_IMPORTER",
                    "-DASSIMP_BUILD_NO_NDO_IMPORTER",
                    "-DASSIMP_BUILD_NO_IFC_IMPORTER",
                    "-DASSIMP_BUILD_NO_XGL_IMPORTER",
                    "-DASSIMP_BUILD_NO_FBX_IMPORTER",
                    "-DASSIMP_BUILD_NO_C4D_IMPORTER",
                    "-DASSIMP_BUILD_NO_OPENGEX_IMPORTER",
                    "-DASSIMP_BUILD_NO_ASSBIN_IMPORTER",
                    "-DASSIMP_BUILD_NO_BLEND_IMPORTER",
                    "-DASSIMP_BUILD_NO_GEO_IMPORTER",
                    "-DANDROID -fPIC",
                    "-DANDROID -fsigned-char",
                    "-mstackrealign",
                    "-O2",
                    "-fexceptions",
                    "-frtti"

            cFlags "-latomic",
                    "-DASSIMP_BUILD_NO_X_IMPORTER",
                    "-DASSIMP_BUILD_NO_3DS_IMPORTER",
                    "-DASSIMP_BUILD_NO_MD3_IMPORTER",
                    "-DASSIMP_BUILD_NO_MDL_IMPORTER",
                    "-DASSIMP_BUILD_NO_MD2_IMPORTER",
                    "-DASSIMP_BUILD_NO_PLY_IMPORTER",
                    "-DASSIMP_BUILD_NO_ASE_IMPORTER",
                    "-DASSIMP_BUILD_NO_HMP_IMPORTER",
                    "-DASSIMP_BUILD_NO_SMD_IMPORTER",
                    "-DASSIMP_BUILD_NO_MDC_IMPORTER",
                    "-DASSIMP_BUILD_NO_MD5_IMPORTER",
                    "-DASSIMP_BUILD_NO_STL_IMPORTER",
                    "-DASSIMP_BUILD_NO_LWO_IMPORTER",
                    "-DASSIMP_BUILD_NO_DXF_IMPORTER",
                    "-DASSIMP_BUILD_NO_NFF_IMPORTER",
                    "-DASSIMP_BUILD_NO_RAW_IMPORTER",
                    "-DASSIMP_BUILD_NO_OFF_IMPORTER",
                    "-DASSIMP_BUILD_NO_AC_IMPORTER",
                    "-DASSIMP_BUILD_NO_BVH_IMPORTER",
                    "-DASSIMP_BUILD_NO_IRRMESH_IMPORTER",
                    "-DASSIMP_BUILD_NO_IRR_IMPORTER",
                    "-DASSIMP_BUILD_NO_Q3D_IMPORTER",
                    "-DASSIMP_BUILD_NO_B3D_IMPORTER",
                    "-DASSIMP_BUILD_NO_COLLADA_IMPORTER",
                    "-DASSIMP_BUILD_NO_TERRAGEN_IMPORTER",
                    "-DASSIMP_BUILD_NO_CSM_IMPORTER",
                    "-DASSIMP_BUILD_NO_3D_IMPORTER",
                    "-DASSIMP_BUILD_NO_LWS_IMPORTER",
                    "-DASSIMP_BUILD_NO_OGRE_IMPORTER",
                    "-DASSIMP_BUILD_NO_MS3D_IMPORTER",
                    "-DASSIMP_BUILD_NO_COB_IMPORTER",
                    "-DASSIMP_BUILD_NO_Q3BSP_IMPORTER",
                    "-DASSIMP_BUILD_NO_NDO_IMPORTER",
                    "-DASSIMP_BUILD_NO_IFC_IMPORTER",
                    "-DASSIMP_BUILD_NO_XGL_IMPORTER",
                    "-DASSIMP_BUILD_NO_FBX_IMPORTER",
                    "-DASSIMP_BUILD_NO_C4D_IMPORTER",
                    "-DASSIMP_BUILD_NO_OPENGEX_IMPORTER",
                    "-DASSIMP_BUILD_NO_ASSBIN_IMPORTER",
                    "-DASSIMP_BUILD_NO_BLEND_IMPORTER",
                    "-DASSIMP_BUILD_NO_GEO_IMPORTER",
                    "-DANDROID -fPIC",
                    "-DANDROID -fsigned-char",
                    "-mstackrealign",
                    "-O2",
                    "-fexceptions",
                    "-frtti"

            arguments "-DANDROID_STL=gnustl_shared"

        }
    }
}
splits {

    // Configures screen ABI split settings

    abi {

        // Enable ABI APK splits
        enable true

        // Resets the list of ABIs that Gradle should create APKs for to none
        reset()

        // Specifies a list of ABIs that Gradle should create APKs for
        include "armeabi", "armeabi-v7a", "x86"

        // Specify that we do not want to also generate a universal APK that includes all ABIs
        universalApk false
    }

}
buildTypes {
    release {
        proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
        signingConfig signingConfigs.XSigningCredentials
        minifyEnabled true
    }
    debug {
        debuggable true
        minifyEnabled false
    }
}
packagingOptions {
    exclude 'META-INF/services/javax.annotation.processing.Processor'
    pickFirst 'META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.properties'
    pickFirst 'META-INF/maven/org.bytedeco.javacpp-presets/opencv/pom.xml'
    pickFirst 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.properties'
    pickFirst 'META-INF/maven/org.bytedeco.javacpp-presets/ffmpeg/pom.xml'
}
dexOptions {
    javaMaxHeapSize "2g"
}
externalNativeBuild {
    cmake {
        path 'CMakeLists.txt'
    }
}
sourceSets {
    main {
        jniLibs.srcDirs opencvSdkPath, 'src/main/jni/ffmpeg'
    }
    }
}
// map for the version code that gives each ABI a value
ext.versionCodes = ['armeabi': 1, 'armeabi-v7a': 2, 'x86': 3]

// For each APK output variant, override versionCode with an ABI value 
schema
android.applicationVariants.all { variant ->
    // assign different version code for each output
    variant.outputs.each { output ->
        output.versionCodeOverride =((project.versionCodes.get(output.getFilter(com.android.build.OutputFile.ABI)) * 1000000)
                    + android.defaultConfig.versionCode)
}
}

repositories {
    mavenCentral()
}

configurations {
all*.exclude group: 'org.bytedeco', module: 'javacpp-presets'
}

dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
compile project(':openCVLibrary310')
compile 'org.bytedeco.javacpp-presets:opencv:3.1.0-1.2'
compile 'org.bytedeco.javacpp-presets:ffmpeg:3.0.2-1.2'
compile 'com.squareup.okhttp3:okhttp:3.5.0'
compile 'org.bytedeco.javacpp-presets:opencv:3.1.0-1.2'
compile 'org.bytedeco.javacpp-presets:ffmpeg:3.0.2-1.2'
compile 'com.squareup.okhttp3:okhttp:3.5.0'
compile 'org.bytedeco:javacv:1.2'
compile 'org.bytedeco:javacpp:1.2.4'
compile 'com.android.support:appcompat-v7:25.3.1'
compile 'com.android.support:design:25.3.1'
compile 'com.github.bumptech.glide:glide:3.7.0'
compile 'com.android.support:support-v4:25.3.1'
compile 'com.facebook.android:facebook-android-sdk:[4,5)'
compile 'com.android.support:multidex:1.0.1'
compile 'com.google.firebase:firebase-core:11.0.2'
compile 'com.google.firebase:firebase-crash:11.0.2'
compile 'com.google.firebase:firebase-auth:11.0.2'
compile 'com.google.android.gms:play-services-auth:11.0.2'
compile 'com.android.support.constraint:constraint-layout:1.0.0-beta4'
compile 'com.desk:sdk:1.3.1'
compile 'se.akerfeldt:okhttp-signpost:1.1.0'
compile 'oauth.signpost:signpost-core:1.2.1.2'
compile 'com.jakewharton.timber:timber:4.5.1'
compile 'org.slf4j:slf4j-api:1.7.21'
compile 'com.github.tony19:logback-android-core:1.1.1-6'
compile 'com.github.tony19:logback-android-classic:1.1.1-6'
testCompile 'junit:junit:4.12'
}

apply plugin: 'com.google.gms.google-services'
+4
2

, Gradle "", Android Studio → "" → "", "", "" → "". --stacktrace --debug. "" Gradle.

, ABI, reset , .

+2

. , Instant Run? Instant run apk-

Android - Proguard

0

Source: https://habr.com/ru/post/1681296/


All Articles