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

AAPT: error: resource attr/foreground #104

Open
okechukwu0127 opened this issue Apr 12, 2022 · 1 comment
Open

AAPT: error: resource attr/foreground #104

okechukwu0127 opened this issue Apr 12, 2022 · 1 comment

Comments

@okechukwu0127
Copy link
Contributor

Describe the bug

Task :react-native-paystack:verifyReleaseResources FAILED
I suddenly started getting this error when i try to build the application from terminal.
The application works well when testing on emulator and device with no error

AAPT: error: resource attr/foreground (aka com.arttitude360.reactnative.rnpaystack:attr/foreground) not found.
 AAPT: error: resource attr/foregroundInsidePadding (aka com.arttitude360.reactnative.rnpaystack:attr/foregroundInsidePadding) not found.
 AAPT: error: resource attr/foregroundGravity (aka com.arttitude360.reactnative.rnpaystack:attr/foregroundGravity) not found.

To Reproduce
Steps to reproduce the behavior:

  1. Go to terminal and run the command from the android dir ./gradlew assembleRelease -x bundleReleaseJsAndAssets
  2. Error shows up

Expected behavior
Build the app and output an .aab file

Screenshots
Find screenshot of my terminal output below
image

How i tried resolving the issue

Create an attrs.xml file in the values directory (/android/app/src/res/values/attr.xml) and added content

<declare-styleable name="ForegroundView">
    <attr name="foreground" format="color" />
    <attr name="foregroundGravity" format="integer" />
    <attr name="foregroundInsidePadding" format="boolean" />
</declare-styleable>

Also changed my gradlew version from gradle-6.2 to gradle-6.1.1 and i got the same error

Additional context
react-native-paystack-webview:4.0.3
react-native-cli: 2.0.1
react-native: 0.59.8
node: v14.17.0

Kindly let me know whats causing the error as have been stock here for weeks.
Regards

@okechukwu0127
Copy link
Contributor Author

okechukwu0127 commented Apr 15, 2022

Describe the bug

Task :react-native-paystack:verifyReleaseResources FAILED I suddenly started getting this error when i try to build the application from terminal. The application works well when testing on emulator and device with no error

AAPT: error: resource attr/foreground (aka com.arttitude360.reactnative.rnpaystack:attr/foreground) not found.
 AAPT: error: resource attr/foregroundInsidePadding (aka com.arttitude360.reactnative.rnpaystack:attr/foregroundInsidePadding) not found.
 AAPT: error: resource attr/foregroundGravity (aka com.arttitude360.reactnative.rnpaystack:attr/foregroundGravity) not found.

To Reproduce Steps to reproduce the behavior:

  1. Go to terminal and run the command from the android dir ./gradlew assembleRelease -x bundleReleaseJsAndAssets
  2. Error shows up

Expected behavior Build the app and output an .aab file

Screenshots Find screenshot of my terminal output below image

How i tried resolving the issue

Create an attrs.xml file in the values directory (/android/app/src/res/values/attr.xml) and added content

<declare-styleable name="ForegroundView">
    <attr name="foreground" format="color" />
    <attr name="foregroundGravity" format="integer" />
    <attr name="foregroundInsidePadding" format="boolean" />
</declare-styleable>

Also changed my gradlew version from gradle-6.2 to gradle-6.1.1 and i got the same error

Additional context react-native-paystack-webview:4.0.3 react-native-cli: 2.0.1 react-native: 0.59.8 node: v14.17.0

Kindly let me know whats causing the error as have been stock here for weeks. Regards

I was able to solve this in a very interesting way.

After many back and forth, the only solution that worked for me was to

  • upgrade my gradlew plugin to 4.2.0 (android/build.gradle) i.e classpath 'com.android.tools.build:gradle:4.2.0'
  • upgrade my gradlew distributionUrl version to 7.0 (android/gradle/wrapper/gradle-wrapper.properties) i.e https://services.gradle.org/distributions/gradle-7.0-all.zip

After this gradlew related upgrade, all AAPT: error: resource attr error disapeared.

THIS LEAD ME TO ANOTHER ERROR WHICH TOOK ME DAYS TO RESOLVE AS WELL

Just incase after you reolved the AAPT related error and you hit this next break wall.

'app:lintVitalRelease' error when generating signed app

Did a lot of try and error because the error message after the app:lintVitalRelease error ready the following below.

> Failed to list versions for com.google.firebase:firebase-messaging.
         > Unable to load Maven meta-data from https://jcenter.bintray.com/com/google/firebase/firebase-messaging/maven-metadata.xml.

At the end of the day, i got a solution from the following StackOverflow Link

ANSWER


I had this problem and solved it by adding:

lintOptions { 

    checkReleaseBuilds false

}
to my build.gradle file within the android{ } section.

I hope this saves a persons time and life in general.

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

1 participant