0

I am trying to generate my first .apk and facing error from past few days. I search ans on stack overflow and github to but nothing helped.
By instructions here i am able to build debug release but when when run gradlew assembleRelease i am getting errors

E:\p1\placementScript\android\app\build\intermediates\res\merged\release\drawable-hdpi\node_modules_reactnavigationstack_dist_views_assets_backicon.png: error: uncompiled PNG file passed as argument. Must be compiled first into .flat file.. error: failed parsing overlays.

FAILURE: Build failed with an exception.

  • What went wrong: Execution failed for task ':app:processReleaseResources'. Failed to process resources, see aapt output above for details.

package.json

 {
   ....
  "dependencies": {
    "babel-preset-es2015": "^6.24.1",
    "react": "^16.4.1",
    "react-native": "^0.55.4",
    "react-native-fcm": "^16.2.3",
    "react-native-firebase": "^5.0.0",
    "react-native-push-notification": "^3.1.1",
    "react-native-view-shot": "^2.4.0",
    "react-navigation": "^2.12.1"
  }

   ....
}

and android/build.gradle

// Top-level build file where you can add configuration options common to all sub-projects/modules.

buildscript {
    ext {
        buildToolsVersion = "26.0.3"
        minSdkVersion = 16
        compileSdkVersion = 26
        targetSdkVersion = 26
        supportLibVersion = "26.1.0"
    }
    repositories {
        google()
        jcenter()
    }
    dependencies {
        classpath 'com.android.tools.build:gradle:3.1.2'
                classpath 'com.google.gms:google-services:4.0.1'

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

allprojects {
    repositories {
        mavenLocal()
        google()
        jcenter()
        maven {
            // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
            url "$rootDir/../node_modules/react-native/android"
        }
    }
}


task wrapper(type: Wrapper) {
    gradleVersion = '4.4'
    distributionUrl = distributionUrl.replace("bin", "all")
}

and android/app/build.gradle

...
defaultConfig {
 ...
        }
          signingConfigs {
            release {
                if (project.hasProperty('MYAPP_RELEASE_STORE_FILE')) {
                    storeFile file(MYAPP_RELEASE_STORE_FILE)
                    storePassword MYAPP_RELEASE_STORE_PASSWORD
                    keyAlias MYAPP_RELEASE_KEY_ALIAS
                    keyPassword MYAPP_RELEASE_KEY_PASSWORD
                }
            }
        }
        splits {
        ...

Any other file you want me to upload please ask.

PS:- I have lot of .png files in my src folder (where all .js/etc files are) and do i need to specify some where that they are my assets

Rajan Lagah
  • 2,373
  • 1
  • 24
  • 40

1 Answers1

0

It's a fairly common problem. Check out this thread in the RN issues with potential solutions:

https://github.com/facebook/react-native/issues/19211

A solution that worked for me was to

Add the following code to file node_modules/react-native/react.gradle :

doLast {
    def moveFunc = { resSuffix ->
        File originalDir = file("${resourcesDir}/drawable-${resSuffix}")
        if (originalDir.exists()) {
            File destDir = file("${resourcesDir}/drawable-${resSuffix}-v4")
            ant.move(file: originalDir, tofile: destDir)
        }
    }
    moveFunc.curry("ldpi").call()
    moveFunc.curry("mdpi").call()
    moveFunc.curry("hdpi").call()
    moveFunc.curry("xhdpi").call()
    moveFunc.curry("xxhdpi").call()
    moveFunc.curry("xxxhdpi").call()
}

inside def currentBundleTask = tasks.create(...

Ariel Salem
  • 357
  • 3
  • 12