Cannot enable character support (using Android Studio, following the getting started guide)

I am starting Android development. I follow this Getting Started guide and use Android Studio (not eclipse).

I launched Hello World on my device, so far so good. But..

The problem occurs when adding this import: (according to the instructions in the manual)

import android.support.v4.app.NavUtils; // cannot resolve symbol 'support' 

This seems to be necessary for this line (commenting this out and automatically allowing import did not work)

 NavUtils.navigateUpFromSameTask(this); 

Import support is red underlined, mouseover tells me Cannot resolve symbol 'support'

Building will not work with anyone. I saw answers to similar questions, such as; offering to clear the cache and restart (tried this), offering to launch the SDK Manager as an administrator and update (tried this), and some other problems / solutions that seem specific to eclipse.

I am new to Android and IDE development. How about fixing this in Android Studio v0.2.9?

Edit:

The 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' } 
+7
android import android-studio
source share
3 answers

Modify the gradle file as shown 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' } 
+15
source share

Fix in Android Studio using the graphical interface, without directly editing Gradle files (verified for Android Studio, starting from version 1.0.1 through v.2.2.3):

  • Right-click your module in the project tree. This is one, in most cases the first, of the root nodes. By default, it is called app .

  • In the menu, select "Open module settings":

    enter image description here

  • Click the "Dependencies" tab.

  • Click the add (+) button at the bottom of the dialog box.

  • Select a library dependency.

  • Select support-v4 from the list.

  • Click OK and rebuild.

+7
source share

Instead of editing build.gradle I did this maven with the right mouse button in the root project β†’ Open module settings β†’ Dependencies tab β†’ + β†’ Maven dependency β†’ Search for β€œNavUtils” and select com.google.android:support-v4: r7@jar .

SDK version 19 and Android Studio 0.4.2

+6
source share

All Articles