简体   繁体   中英

Project won't build after Android Studio and Gradle update

I just updated Android studio from 1.8.11 to 1.9.2. First time I opened my project after the update, it said something like "import new gradle and syn project". I pressed it cause my project wouldn't build at all, so i though hey maybe this would work. Android studio then downloaded and installed Gradle 2.1, but now when i try to build i get a cannot resolve symbol R on all com.projectName.R , in all of my class files.

Anyone experiencing same problem or know how to fix it? Any help is much appreciated.

EDIT: This is the error i get when opening an old 1.8.11 project into 1.9.2. Error:The project is using an unsupported version of the Android Gradle plug-in (0.12.2). The recommended version is 0.14.1. <a href="fixGradleElements">Fix plug-in version and re-import project</a>

When i click the link thats when it updates Gradle from 1.12 to 2.1 and this is when my com.projectName.R imports stop working.

I had the same error and the problem was that AndroidManifest.xml file in one of my modules had no <application> tag in it.

Adding an empty <application /> tag solved the issue:

<?xml version="1.0" encoding="utf-8"?>
<manifest package="com.package.mine">
    <application />
</manifest>

If you don't have any files with missing tag, or you don't experience the same problem, I suggest you try to execute in command line:

gradlew assembleDebug --info

and see what is at the end of the output, just before the error. The extra information from --info parameter is what helped me to decrypt my problem.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM