在构建Project时,错误在:app:compileDebugJava。它说错误:包android.support.v7.app不存在

时间:2015-02-10 23:29:00

标签: android android-studio

我在模块设置中拥有所有必需的依赖项。我还使用sdk管理器安装了所有支持库。

我从Gradle控制台获得以下输出

Executing tasks: [:app:assembleDebug]

Configuration on demand is an incubating feature.
:app:preBuild
:app:compileDebugNdk
:app:preDebugBuild
:app:checkDebugManifest
:app:preReleaseBuild
:app:prepareComAndroidSupportAppcompatV72103Library UP-TO-DATE
:app:prepareComAndroidSupportSupportV42103Library UP-TO-DATE
:app:prepareComGoogleAndroidGmsPlayServices6587Library UP-TO-DATE
:app:prepareDebugDependencies
:app:compileDebugAidl UP-TO-DATE
:app:compileDebugRenderscript UP-TO-DATE
:app:generateDebugBuildConfig UP-TO-DATE
:app:generateDebugAssets UP-TO-DATE
:app:mergeDebugAssets UP-TO-DATE
:app:generateDebugResValues UP-TO-DATE
:app:generateDebugResources UP-TO-DATE
:app:mergeDebugResources UP-TO-DATE
:app:processDebugManifest UP-TO-DATE
:app:processDebugResources UP-TO-DATE
:app:generateDebugSources UP-TO-DATE
:app:compileDebugJava
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/LoginConfim.java:4: error: package android.support.v7.app does not exist
import android.support.v7.app.ActionBarActivity;
                             ^
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/LoginConfim.java:11: error: cannot find symbol
public class LoginConfim extends ActionBarActivity {
                                 ^
  symbol: class ActionBarActivity
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/RegistrationScreen.java:4: error: package android.support.v7.app does not exist
import android.support.v7.app.ActionBarActivity;
                             ^
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/RegistrationScreen.java:11: error: cannot find symbol
public class RegistrationScreen extends ActionBarActivity {
                                        ^
  symbol: class ActionBarActivity
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/WelcomeScreen.java:4: error: package android.support.v7.app does not exist
import android.support.v7.app.ActionBarActivity;
                             ^
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/WelcomeScreen.java:11: error: cannot find symbol
public class WelcomeScreen extends ActionBarActivity {
                                   ^
  symbol: class ActionBarActivity
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/LoginConfim.java:13: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/LoginConfim.java:15: error: cannot find symbol
        super.onCreate(savedInstanceState);
        ^
  symbol:   variable super
  location: class LoginConfim
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/LoginConfim.java:16: error: cannot find symbol
        setContentView(R.layout.activity_login_confim);
        ^
  symbol:   method setContentView(int)
  location: class LoginConfim
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/LoginConfim.java:20: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/LoginConfim.java:23: error: cannot find symbol
        getMenuInflater().inflate(R.menu.menu_login_confim, menu);
        ^
  symbol:   method getMenuInflater()
  location: class LoginConfim
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/LoginConfim.java:27: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/LoginConfim.java:39: error: cannot find symbol
        return super.onOptionsItemSelected(item);
               ^
  symbol:   variable super
  location: class LoginConfim
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/LoginConfim.java:43: error: cannot find symbol
        startActivity(new Intent(getApplicationContext(), WelcomeScreen.class));
                                 ^
  symbol:   method getApplicationContext()
  location: class LoginConfim
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/LoginConfim.java:43: error: cannot find symbol
        startActivity(new Intent(getApplicationContext(), WelcomeScreen.class));
        ^
  symbol:   method startActivity(Intent)
  location: class LoginConfim
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/RegistrationScreen.java:13: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/RegistrationScreen.java:15: error: cannot find symbol
        super.onCreate(savedInstanceState);
        ^
  symbol:   variable super
  location: class RegistrationScreen
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/RegistrationScreen.java:16: error: cannot find symbol
        setContentView(R.layout.activity_registration_screen);
        ^
  symbol:   method setContentView(int)
  location: class RegistrationScreen
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/RegistrationScreen.java:20: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/RegistrationScreen.java:23: error: cannot find symbol
        getMenuInflater().inflate(R.menu.menu_registration_screen, menu);
        ^
  symbol:   method getMenuInflater()
  location: class RegistrationScreen
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/RegistrationScreen.java:27: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/RegistrationScreen.java:39: error: cannot find symbol
        return super.onOptionsItemSelected(item);
               ^
  symbol:   variable super
  location: class RegistrationScreen
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/RegistrationScreen.java:42: error: cannot find symbol
        startActivity(new Intent(getApplicationContext(), WelcomeScreen.class));
                                 ^
  symbol:   method getApplicationContext()
  location: class RegistrationScreen
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/RegistrationScreen.java:42: error: cannot find symbol
        startActivity(new Intent(getApplicationContext(), WelcomeScreen.class));
        ^
  symbol:   method startActivity(Intent)
  location: class RegistrationScreen
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/WelcomeScreen.java:13: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/WelcomeScreen.java:15: error: cannot find symbol
        super.onCreate(savedInstanceState);
        ^
  symbol:   variable super
  location: class WelcomeScreen
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/WelcomeScreen.java:16: error: cannot find symbol
        setContentView(R.layout.activity_welcome_screen);
        ^
  symbol:   method setContentView(int)
  location: class WelcomeScreen
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/WelcomeScreen.java:20: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/WelcomeScreen.java:23: error: cannot find symbol
        getMenuInflater().inflate(R.menu.menu_welcome_screen, menu);
        ^
  symbol:   method getMenuInflater()
  location: class WelcomeScreen
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/WelcomeScreen.java:27: error: method does not override or implement a method from a supertype
    @Override
    ^
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/WelcomeScreen.java:39: error: cannot find symbol
        return super.onOptionsItemSelected(item);
               ^
  symbol:   variable super
  location: class WelcomeScreen
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/WelcomeScreen.java:43: error: cannot find symbol
        startActivity(new Intent(getApplicationContext(), ShoppingWithFriendsLogin.class));
                                 ^
  symbol:   method getApplicationContext()
  location: class WelcomeScreen
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/WelcomeScreen.java:43: error: cannot find symbol
        startActivity(new Intent(getApplicationContext(), ShoppingWithFriendsLogin.class));
        ^
  symbol:   method startActivity(Intent)
  location: class WelcomeScreen
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/WelcomeScreen.java:47: error: cannot find symbol
        startActivity(new Intent(getApplicationContext(), RegistrationScreen.class));
                                 ^
  symbol:   method getApplicationContext()
  location: class WelcomeScreen
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/WelcomeScreen.java:47: error: cannot find symbol
        startActivity(new Intent(getApplicationContext(), RegistrationScreen.class));
        ^
  symbol:   method startActivity(Intent)
  location: class WelcomeScreen
/Users/AMTAGRWL/Downloads/Dropbox/GT:CLASSES/Spring 2015/CS 2340/git/TrueProjectUnicorn/ShoppingWithFriends/app/src/main/java/com/projectunicorn/shoppingwithfriends/WelcomeScreen.java:50: error: method does not override or implement a method from a supertype
    @Override
    ^
36 errors

 FAILED

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:compileDebugJava'.
> Compilation failed; see the compiler error output for details.

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output.

BUILD FAILED

Total time: 2.692 secs

我已经尝试了多个关于此的现有帖子,但未能找到有效的解决方案。

编辑:我的build.gradle文件。

apply plugin: 'com.android.application'

android {
    compileSdkVersion 21
    buildToolsVersion "21.1.2"

    defaultConfig {
        applicationId "com.projectunicorn.shoppingwithfriends"
        minSdkVersion 15
        targetSdkVersion 21
        versionCode 1
        versionName "1.0"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android.txt'),                        'proguard-rules.pro'
        }
    }
}

dependencies {
    compile fileTree(dir: 'libs', include: ['*.jar'])
    compile 'com.google.android.gms:play-services:6.5.87'
    compile ('com.android.support:appcompat-v7:21.0.3')
    compile ('com.android.support:support-v4:21.0.+')
}

我在OS X Yosemite上使用Android Studio 1.0.2。

2 个答案:

答案 0 :(得分:0)

安装库是不够的。您还需要将其添加到项目的依赖项列表中。

为此,请将此行添加到build.gradle的依赖项部分:

dependencies {
  ...
  compile ('com.android.support:appcompat-v7:21.0.3')
  compile ('com.android.support:support-v4:21.0.3')
}

这取自official docs

  

v7 appcompat库

     

注意:此库取决于v4支持库。如果您使用的是Ant或Eclipse,请确保将v4支持库包含在此库的类路径中。

所以不要忘记添加v4和v7。

答案 1 :(得分:0)

创建项目时您选择哪个版本? (目标,最低等)

我将所有版本更改为一个版本--API 21,它适用于我。