https://kotlinlang.org logo
#android
Title
# android
s

Shan

03/28/2019, 9:12 AM
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

Jacques Smuts

03/28/2019, 9:13 AM
doesn’t look like you’re importing R
import com.yourpackage.app.R
s

Shan

03/28/2019, 9:14 AM
It doesn't show as being able to import R when I manually import it
j

Jacques Smuts

03/28/2019, 9:15 AM
have you done the clean+invalidate_caches rigmarole?
s

Shan

03/28/2019, 9:15 AM
Yeah, multiple times 😞 refreshed dependencies too
j

Jacques Smuts

03/28/2019, 9:16 AM
I am 100% sure I’ve been in this situation and I cannot remember how I resolved it 🤔
😂 2
😢 1
g

Grzegorz Matyszczak

03/28/2019, 9:20 AM
remove ./idea/libraries folder in your project then invalidate caches + restart android studio and sync project with gradle, for me it usually helps 😉
u

ubububu

03/28/2019, 9:21 AM
File > Sync Project with Gradle Files
s

Shan

03/28/2019, 9:23 AM
@ubububu have tried that, did not work
@Grzegorz Matyszczak did not work unfortunately
r

ribesg

03/28/2019, 9:35 AM
It probably means your R.java cannot be compiled, you probably have an invalid resource or something. Check your recent changes on resources.
s

Slava Glushenkov

03/28/2019, 10:04 AM
Try to delete {projectDir}/.idea/libraries than File -> Sync Project with Gradle Files.
l

louiscad

03/28/2019, 10:05 AM
Which IDE on which version are you using? Does it compile with gradle from CLI when you add the import manually?
s

Shan

03/28/2019, 10:47 AM
@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

ribesg

03/28/2019, 11:12 AM
@Shan I think you’re using the 3.3 version of the Android Gradle Plugin. Try to rollback to 3.2.1
p

paulex

03/28/2019, 11:13 AM
Well, @ribesg , I use classpath 'com.android.tools.buildG3.3.2'
and i don't have that issue
r

ribesg

03/28/2019, 11:13 AM
@paulex and you’re using Android Studio
p

paulex

03/28/2019, 11:14 AM
Yes of course
r

ribesg

03/28/2019, 11:14 AM
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

paulex

03/28/2019, 11:16 AM
oh okay... so this is intelliJ? as in that is what she uses?
p

paulex

03/28/2019, 11:17 AM
Oh, Okay seen.
s

Shan

03/28/2019, 11:26 AM
@ribesg downgrading to 3.2.1 solved it 🙂 Thanks so much! That was driving me bonkers
🙌 1
r

ribesg

03/28/2019, 11:27 AM
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

Shan

03/28/2019, 11:29 AM
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

louiscad

03/28/2019, 11:40 AM
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

ribesg

03/28/2019, 11:49 AM
@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

Shan

03/28/2019, 11:50 AM
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

louiscad

03/28/2019, 12:44 PM
@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

ribesg

03/28/2019, 12:45 PM
Oh right, thanks
2 Views