I have a small project that was started in Eclipse. I then exported it to a gradle file, and imported it to AS (0.5.7).
At first, not much seemed to work as it should, but after a "build => make project", I didn't seem to get any highlighted errors or so.
So I tried to run the app to an emulated device. Well, the device never launched, and now I get red squiggly lines under mentions of "String", "ArrayList" etc, saying it "cannot resolve the symbol".
What the f?
I have tried cleaning and rebuilding, as well as "sync project with gradle files".
Where do I go from here? I want to get going with developing in AS so bad!
edit: Screenshot of project setup: http://i.imgur.com/ycNyPaT.png
Contents of build.gradle:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.9.+'
}
}
apply plugin: 'android'
dependencies {
compile fileTree(dir: 'libs', include: '*.jar')
}
android {
compileSdkVersion 19
buildToolsVersion "19.0.1"
sourceSets {
main {
manifest.srcFile 'AndroidManifest.xml'
java.srcDirs = ['src']
resources.srcDirs = ['src']
aidl.srcDirs = ['src']
renderscript.srcDirs = ['src']
res.srcDirs = ['res']
assets.srcDirs = ['assets']
}
// Move the tests to tests/java, tests/res, etc...
instrumentTest.setRoot('tests')
// Move the build types to build-types/<type>
// For instance, build-types/debug/java, build-types/debug/AndroidManifest.xml, ...
// This moves them out of them default location under src/<type>/... which would
// conflict with src/ being used by the main source set.
// Adding new build types or product flavors should be accompanied
// by a similar customization.
debug.setRoot('build-types/debug')
release.setRoot('build-types/release')
}
}
Most often “R cannot be resolved” error appears if there is an issue with some of your resource files. Due to this error, you are unable to build your application. That's why we need to solve this error as it not getting away by just doing a simple restart or hitting Alt+Enter.
The cannot find symbol error, also found under the names of symbol not found and cannot resolve symbol , is a Java compile-time error which emerges whenever there is an identifier in the source code which the compiler is unable to work out what it refers to.
There is simpler and I think more correct way:
For me this successfully resolved the issue (was caused by surprising power off of PC)
So project arrangement should be as follows:
apply plugin: 'android' dependencies { compile fileTree(dir: 'libs', include: '*.jar') } android { compileSdkVersion 19 buildToolsVersion "19.0.1" }
include 'app'
buildscript { repositories { mavenCentral() } dependencies { classpath 'com.android.tools.build:gradle:0.9.+' } }
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With