Saturday, July 22, 2017

Android Studio Gradle failing during build

Leave a Comment

Here is my problem scenario:

I am not able to build and run my app within android studio. It seems to fail before installing the apk with the error below. However when I build the app through command line with the gradle wrapper, things go smoothly. Obviously this isn't ideal, as other team members need to use the project, and the IDE UI for android studio should be enough.

When I build and run my app in Android Studio I am getting an error during build steps:

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

However when I invoke command:

./gradlew cleanRelease assembleRelease installRelease, 

This builds and installs the working version on the device.

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

So pressing the Run Button (>) on android studio is the only thing that doesn't work ... Weird thing is it works when I specify only one abi, but when I put all three it doesn't work.

My questions are :

Why is this message showing up ?? What path is null ?? And how to fix this.

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' 

2 Answers

Answers 1

To debug why one of the Gradle tasks fail when pressing the Run button, you can enable command-line options in Android Studio -> Settings -> Build, Execution, Deployment -> Compiler. Set the Command-line options to --stacktrace --debug. Press the Run button and check the output in the Gradle Console window.

Possibly you have some dependency between the three ABIs that gets reset and affects the others, but it's hard to know without more logs.

Answers 2

I don't have reputation to comment. I would like to know if you are using Instant Run? Don't keep Instant run enabled when trying to build a release apk

Check here for more on Android studio - Instant run & Proguard

If You Enjoyed This, Take 5 Seconds To Share It

0 comments:

Post a Comment