I am getting started with Android development. I have followed this Getting Started guide and use Android Studio (not eclipse).
I ran Hello World on my device, so far so good. But..
Problem starts when adding this import: (as instructed by the guide)
import android.support.v4.app.NavUtils; // cannot resolve symbol 'support'
Seems its needed by this line (commenting it and auto-resolving the import didnt work)
NavUtils.navigateUpFromSameTask(this);
The support import is red underlined, mouseover tells me Cannot resolve symbol 'support'
Build wont work either ofcourse. I have seen answers to similar questions such as; suggesting clearing cache and retarting (tried that), suggesting running SDK Manager as Administrator and updating (tried that), and some other problems/solutions that seem eclipse specific.
I am new to Android development and the IDE. How about fixing this in Android Studio v0.2.9 ?
Edit:
Contents of my build.gradle file
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:0.5.+'
}
}
apply plugin: 'android'
repositories {
mavenCentral()
}
android {
compileSdkVersion 17
buildToolsVersion "17.0.0"
defaultConfig {
minSdkVersion 7
targetSdkVersion 16
}
}
dependencies {
// You must install or update the Support Repository through the SDK manager to use this dependency.
// The Support Repository (separate from the corresponding library) can be found in the Extras category.
// compile 'com.android.support:appcompat-v7:18.0.0'
}
Modify your gradle file like below and try if it works.
......
dependencies {
compile 'com.android.support:support-v4:18.0.0'
// You must install or update the Support Repository through the SDK manager to use this dependency.
// The Support Repository (separate from the corresponding library) can be found in the Extras category.
// compile 'com.android.support:appcompat-v7:18.0.0'
}
Fix in Android Studio using the GUI, without the direct editing of the Gradle files (validated for Android Studio starting v1.0.1 to v2.2.3):
Right-click your module in the project tree. It is one, in most cases the first, of the root nodes. By default, it is called app.
In the menu choose Open Module Settings:

Switch to Dependencies tab.
Click the add button (+) at the bottom of the dialog window.
Choose Library Dependency.
Choose support-v4 from the list.
Click OK and rebuild.
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