2015-02-10 198 views
0

我在模塊設置中具有所有必需的依賴關係。我還使用sdk管理器安裝了所有支持庫。在構建Project時,出現以下錯誤:app:compileDebugJava。它說錯誤:軟件包android.support.v7.app不存在

我從搖籃控制檯

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。

回答

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 library

Note: This library depends on the v4 Support Library. If you are using Ant or Eclipse, make sure you include the v4 Support Library as part of this library's classpath.

所以,不要忘了加都v4和v7。

+0

你想'支持'v4和'appcompat' v7。 – 2015-02-11 00:03:05

0

創建項目時您選擇了哪些版本? (目標,最小等)

我將所有更改爲一個版本 - API 21,它適用於我。

+0

更新問題以顯示build.grade文件。你認爲這是正確的嗎?我想我擁有所有這些版本。 – 2015-02-11 00:12:00

+0

我使用Eclipse,windows。當我有同樣的問題 - 我將所有版本(最小,目標和編譯)更改爲一個版本,它是編譯好的。 – researcher 2015-02-11 00:32:10

相關問題