Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Build failure on Android #27

Closed
martnst opened this issue Jul 26, 2018 · 6 comments
Closed

Build failure on Android #27

martnst opened this issue Jul 26, 2018 · 6 comments

Comments

@martnst
Copy link

martnst commented Jul 26, 2018

I am encountering a build error on Android.

steps:

  • react-native init RNPDFPlay
  • cd RNPDFPlay
  • yarn add react-native-pdf-lib
  • add dexOptions { jumboMode = true } to ./android/app/build.gradle
  • react-native run-android

build log:

:react-native-pdf-lib:processReleaseResources
.../RNPDFPlay/node_modules/react-native-pdf-lib/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:3: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.
    
.../RNPDFPlay/node_modules/react-native-pdf-lib/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:4: AAPT: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.
    
.../RNPDFPlay/node_modules/react-native-pdf-lib/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:15:21-54: AAPT: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.
    
.../RNPDFPlay/node_modules/react-native-pdf-lib/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:3: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Borderless.Colored'.

.../RNPDFPlay/node_modules/react-native-pdf-lib/android/build/intermediates/res/merged/release/values-v24/values-v24.xml:4: error: Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Colored'.

.../RNPDFPlay/node_modules/react-native-pdf-lib/android/build/intermediates/res/merged/release/values-v26/values-v26.xml:15: error: Error: No resource found that matches the given name: attr 'android:keyboardNavigationCluster'.


:react-native-pdf-lib:processReleaseResources FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':react-native-pdf-lib:processReleaseResources'.
> com.android.ide.common.process.ProcessException: Failed to execute aapt

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

env:

  • macOS: 10.13.4
$ react-native --version       
react-native-cli: 2.0.1
react-native: 0.56.0
@martnst
Copy link
Author

martnst commented Jul 26, 2018

Setting up with the same steps but using react-native 0.55 via rninit react-native init instead works fine.

@Hopding
Copy link
Owner

Hopding commented Oct 17, 2018

Hello @martnst. Thanks for reporting this issue!

My apologies for the late response. I'm afraid I don't have the time to debug or fix this issue right now. But I suspect that it is caused by the minSdkVersion, compileSdkVersion, targetSdkVersion, or buildToolsVersion being incorrect for React Native 0.56+.

I think this could be fixed by updating these values. Or, even better, not hardcoding those values, and instead relying on those defined in the parent project. PRs for this are welcomed :)

In the meantime, you can add the following to your android/build.gradle file to force your dependencies to use the same compileSdkVersion and buildToolsVersion values as your main project:

/**
 * Force dependencies to use the same compileSdk and buildTools versions as the main project.
 *
 * Source: https://stackoverflow.com/a/25736483
 */
subprojects { subproject ->
    afterEvaluate{
        if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

I'm not a gradle expert, but I'm sure you could change this script to only target react-native-pdf-lib.

@Hopding Hopding changed the title Build faliure on Android Build failure on Android Oct 17, 2018
@martnst
Copy link
Author

martnst commented Oct 20, 2018

Hi @Hopding, okay fair enough. I actually ended up going a different way via some own native code turning HTML into PDF. If I remember right I kinda just wanted to report this FYI.

@Saumyadip-Pramanik
Copy link

Hello @martnst. Thanks for reporting this issue!

My apologies for the late response. I'm afraid I don't have the time to debug or fix this issue right now. But I suspect that it is caused by the minSdkVersion, compileSdkVersion, targetSdkVersion, or buildToolsVersion being incorrect for React Native 0.56+.

I think this could be fixed by updating these values. Or, even better, not hardcoding those values, and instead relying on those defined in the parent project. PRs for this are welcomed :)

In the meantime, you can add the following to your android/build.gradle file to force your dependencies to use the same compileSdkVersion and buildToolsVersion values as your main project:

/**
 * Force dependencies to use the same compileSdk and buildTools versions as the main project.
 *
 * Source: https://stackoverflow.com/a/25736483
 */
subprojects { subproject ->
    afterEvaluate{
        if((subproject.plugins.hasPlugin('android') || subproject.plugins.hasPlugin('android-library'))) {
            android {
                compileSdkVersion rootProject.ext.compileSdkVersion
                buildToolsVersion rootProject.ext.buildToolsVersion
            }
        }
    }
}

I'm not a gradle expert, but I'm sure you could change this script to only target react-native-pdf-lib.

Yes, this solution works. I am confirming after testing.

@georgewwindsor
Copy link

@Hopding , that worked for me thanks

@thekevinbrown
Copy link
Collaborator

I'll go ahead and close this issue as v1.0.0 should help here, and if not, this workaround should help too. If anyone knows of a better way we can tackle this please feel free to open a PR.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants