Hey all. Anyone have any insight as to why `R` is ...
# android
s
Hey all. Anyone have any insight as to why
R
is giving me an unresolved reference error? edit: The solution was to downgrade the Android Gradle Plugin to 3.2.1 from 3.3.0 in Intellij, as there were some breaking changes that were not brought over.
j
doesn’t look like you’re importing R
import com.yourpackage.app.R
s
It doesn't show as being able to import R when I manually import it
j
have you done the clean+invalidate_caches rigmarole?
s
Yeah, multiple times 😞 refreshed dependencies too
j
I am 100% sure I’ve been in this situation and I cannot remember how I resolved it 🤔
😂 2
😢 1
g
remove ./idea/libraries folder in your project then invalidate caches + restart android studio and sync project with gradle, for me it usually helps 😉
u
File > Sync Project with Gradle Files
s
@ubububu have tried that, did not work
@Grzegorz Matyszczak did not work unfortunately
r
It probably means your R.java cannot be compiled, you probably have an invalid resource or something. Check your recent changes on resources.
s
Try to delete {projectDir}/.idea/libraries than File -> Sync Project with Gradle Files.
l
Which IDE on which version are you using? Does it compile with gradle from CLI when you add the import manually?
s
@ribesg I did look at my resources, I don't see any visible errors anywhere 😣
@louiscad I'm using Intellij 2018.3.5. It does not compile when I add the import manually from the IDE or CLI
r
@Shan I think you’re using the 3.3 version of the Android Gradle Plugin. Try to rollback to 3.2.1
p
Well, @ribesg , I use classpath 'com.android.tools.buildG3.3.2'
and i don't have that issue
r
@paulex and you’re using Android Studio
p
Yes of course
r
That’s the issue. 3.3 isn’t compatible with IntelliJ IDEA right now
Or rather, IntelliJ IDEA isn’t compatible with 3.3. There was a coordinated change between Android Studio and the Android Gradle Plugin on how R is built that was not made in IntelliJ IDEA. I also didn’t check if it was fixed in a recent version of IDEA or in the Android Gradle Plugin 3.3.1 or 3.3.2, as I’m still on 3.2.1 for now.
p
oh okay... so this is intelliJ? as in that is what she uses?
p
Oh, Okay seen.
s
@ribesg downgrading to 3.2.1 solved it 🙂 Thanks so much! That was driving me bonkers
🙌 1
r
Now I’m wondering if there’s a task we could track to know when we IDEA users will be able to update to 3.3.x
s
Can't seem to find one, so this means I will resort to my tried and true strategy of shifting the version up every few days or so and see if it compiles 👍
l
Don't use AGP 3.3, it makes your release apps (post R8 processing) crash on KitKat. Use 3.2 with proguard, use 3.3 with R8 explicitly disabled on IntelliJ 2019.1+, or use Android Studio 3.4+
r
@Shan it’s a good strat but I always fail to remember why I wasn’t updating. For example I know that there is a problem with Gradle 5.2.1 that prevents me from upgrading from Gradle 5.1.1 but I can’t remember which one
And now I don’t know if Gradle 5.3 fixed the problem because I don’t remember what the problem was 😛
s
I generally create an issue on git describing exactly what's preventing me from upgrading to track that kinda stuff 🙂 at least I sometimes do. usually i just forget
l
@ribesg It is multiplatform gradle plugin compatibility. Will be fixed in 1.3.30, so you can upgrade to 5.2.1 or maybe 5.3.1 if it's compatible with non preview gradle metadata.
r
Oh right, thanks