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

fix: Unresolved reference: attr after upgrading to 0.73.0-rc.2 #1919

Merged

Conversation

ivanignatiev
Copy link
Contributor

@ivanignatiev ivanignatiev commented Oct 14, 2023

Description

Small PR which probably resolves #1515.

For my case, I got this build issue after upgrading from 0.72.5 to 0.73.0-rc.2:

> Task :react-native-screens:compileDebugKotlin FAILED
e: file:///Users/ivanignatiev/GitHub/****/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt:391:46 Unresolved reference: attr

I do not know Java or Kotlin, so, please guide me if additional work is needed.

@kkafar: Since AGP 8.0 the default value for android.nonTransitiveRClass property has changed from false to true. This requires resource file names to be fully qualified. React Native 0.73 depends on AGP 8.0 thus we get the build issues.

@tboba
Copy link
Member

tboba commented Oct 14, 2023

Hi @ivanignatiev! I remember we've already got similar issue and there was just a problem with a cache (see #1104) - can you please ensure that cleaning the build cache (via npm run android --reset-cache) isn't just sufficient here? 🙏

@adolfogc
Copy link

Hi, this fix helped me solve the same problem, but using RN 0.72.6.

@tboba
Copy link
Member

tboba commented Oct 16, 2023

Hi @adolfogc, have you tried running npm run android --reset-cache before, or it didn't fix the problem? I'm just wondering if reseting cache is a potential fix there 🤔

@ivanignatiev
Copy link
Contributor Author

@tboba I will check from my side this evening to confirm and give you more details

@adolfogc
Copy link

Hi @tboba, I am using PNPM and rnx-kit, so I ran the following:

git clean -fdx

# Install without the patch
pnpm install

pnpm react-native rnx-start --reset-cache

However, the problem persists:

* What went wrong:
Execution failed for task ':react-native-screens:compileDebugKotlin'.
> A failure occurred while executing org.jetbrains.kotlin.compilerRunner.GradleCompilerRunnerWithWorkers$GradleKotlinCompilerWorkAction
   > Compilation error. See log for more details

@ivanignatiev
Copy link
Contributor Author

Test with [email protected]:

npx [email protected] init AwesomeProject --version 0.72.6
npm run android # BUILD - OK
npm install -s react-native-screens
npm run android # BUILD - OK

Test with [email protected]:

npx [email protected] init AwesomeProject2 --version 0.73.0-rc.2
npm run android # BUILD - OK
npm install -s react-native-screens
npm run android # BUILD - FAILED

FAILURE: Build failed with an exception.

# * What went wrong:
# A problem occurred configuring project ':react-native-screens'.
# > com.android.builder.errors.EvalIssueException: defaultConfig contains custom BuildConfig fields, but the feature is # disabled.
# To enable the feature, add the following to your module-level build.gradle:
#  `android.buildFeatures.buildConfig true`

# Adding buildFeatures.buildConfig true just after namespace in build.grandle

npm run android # BUILD - FAILED

# > Task :react-native-screens:compileDebugKotlin FAILED
# e: file:///Users/ivanignatiev/Projects/AwesomeProject2/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt:391:46 Unresolved reference: attr

npm run android --reset-cache # BUILD - FAILED

# > Task :react-native-screens:compileDebugKotlin FAILED
# e: file:///Users/ivanignatiev/Projects/AwesomeProject2/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt:391:46 Unresolved reference: attr

react-info:

npx react-native info  
info Fetching system and libraries information...
System:
  OS: macOS 14.0
  CPU: (8) arm64 Apple M1
  Memory: 139.47 MB / 16.00 GB
  Shell:
    version: "5.9"
    path: /bin/zsh
Binaries:
  Node:
    version: 20.8.1
    path: /opt/homebrew/bin/node
  Yarn:
    version: 1.22.19
    path: /opt/homebrew/bin/yarn
  npm:
    version: 10.1.0
    path: /opt/homebrew/bin/npm
  Watchman:
    version: 2023.10.09.00
    path: /opt/homebrew/bin/watchman
Managers:
  CocoaPods:
    version: 1.13.0
    path: /usr/local/bin/pod
SDKs:
  iOS SDK:
    Platforms:
      - DriverKit 23.0
      - iOS 17.0
      - macOS 14.0
      - tvOS 17.0
      - watchOS 10.0
  Android SDK: Not Found
IDEs:
  Android Studio: 2022.3 AI-223.8836.35.2231.10811636
  Xcode:
    version: 15.0/15A240d
    path: /usr/bin/xcodebuild
Languages:
  Java:
    version: 17.0.8.1
    path: /usr/bin/javac
  Ruby:
    version: 2.6.10
    path: /Users/ivanignatiev/.rbenv/shims/ruby
npmPackages:
  "@react-native-community/cli": Not Found
  react:
    installed: 18.2.0
    wanted: 18.2.0
  react-native:
    installed: 0.73.0-rc.2
    wanted: 0.73.0-rc.2
  react-native-macos: Not Found
npmGlobalPackages:
  "*react-native*": Not Found
Android:
  hermesEnabled: true
  newArchEnabled: false
iOS:
  hermesEnabled: Not found
  newArchEnabled: Not found

Should I add android.buildFeatures.buildConfig true in build.gradle to this PR?

@adolfogc
Copy link

I am using Java 17.0.8.1 (.asdf/installs/java/temurin-17.0.8+101/bin/javac).

Copy link
Member

@kkafar kkafar left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for contributing <3 I'll modify the PR description to give better explanation why this change is needed.

@kkafar kkafar merged commit ca7abf0 into software-mansion:main Oct 23, 2023
4 checks passed
@ivanignatiev
Copy link
Contributor Author

@kkafar thank you for clear explanation !

gabrieldonadel added a commit to expo/expo that referenced this pull request Nov 9, 2023
# Why

With AGP 8, non-transitive R classes are now enabled by default,
requiring the resource file names to be fully qualified. Given that
React Native 0.73 depends on AGP 8.0 we must update react-native-screens
to include
[this](software-mansion/react-native-screens#1919)
fix.

# How

- `et uvm -m react-native-screens -c 3.27.0`

# Test Plan

- unversioned expo go + ncl screens
- bare expo + ncl screens

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).
onizam95 pushed a commit to onizam95/expo-av-drm that referenced this pull request Jan 15, 2024
# Why

With AGP 8, non-transitive R classes are now enabled by default,
requiring the resource file names to be fully qualified. Given that
React Native 0.73 depends on AGP 8.0 we must update react-native-screens
to include
[this](software-mansion/react-native-screens#1919)
fix.

# How

- `et uvm -m react-native-screens -c 3.27.0`

# Test Plan

- unversioned expo go + ncl screens
- bare expo + ncl screens

# Checklist

<!--
Please check the appropriate items below if they apply to your diff.
This is required for changes to Expo modules.
-->

- [ ] Documentation is up to date to reflect these changes (eg:
https://docs.expo.dev and README.md).
- [ ] Conforms with the [Documentation Writing Style
Guide](https://github.com/expo/expo/blob/main/guides/Expo%20Documentation%20Writing%20Style%20Guide.md)
- [ ] This diff will work correctly for `npx expo prebuild` & EAS Build
(eg: updated a module plugin).
ja1ns pushed a commit to WiseOwlTech/react-native-screens that referenced this pull request Oct 9, 2024
…are-mansion#1919)

## Description

Small PR which probably resolves
[software-mansion#1515](software-mansion#1515).

For my case, I got this build issue after upgrading from 0.72.5 to
0.73.0-rc.2:

```
> Task :react-native-screens:compileDebugKotlin FAILED
e: file:///Users/ivanignatiev/GitHub/****/node_modules/react-native-screens/android/src/main/java/com/swmansion/rnscreens/ScreenStackHeaderConfig.kt:391:46 Unresolved reference: attr
```

I do not know Java or Kotlin, so, please guide me if additional work is
needed.

@kkafar: Since AGP 8.0 the default value for
`android.nonTransitiveRClass` property [has changed from `false` to
`true`](https://developer.android.com/build/releases/past-releases/agp-8-0-0-release-notes).
This requires resource file names to be fully qualified. React Native
0.73 depends on AGP 8.0 thus we get the build issues.
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

Successfully merging this pull request may close these issues.

RNScreens 3.14.1: Unresolved reference: attr.
4 participants