2016-04-30 164 views
0

這裏的錯誤:錯誤,無法解析方法,符號

C:\Users\User\AndroidStudioProjects\FinalProject\app\src\main\res\values-v21\styles.xml 
Error:(3, 5) No resource found that matches the given name: attr 'windowActionBar'. 
Error:(3, 5) No resource found that matches the given name: attr 'windowNoTitle'. 
C:\Users\User\AndroidStudioProjects\FinalProject\app\src\main\res\values\styles.xml 
Error:(11, 5) No resource found that matches the given name: attr 'windowActionBar'. 
Error:(11, 5) No resource found that matches the given name: attr 'windowNoTitle'. 
Error:(4, 5) No resource found that matches the given name: attr 'colorAccent'. 
Error:(4, 5) No resource found that matches the given name: attr 'colorPrimary'. 
Error:(4, 5) No resource found that matches the given name: attr 'colorPrimaryDark'. 
C:\Users\User\AndroidStudioProjects\FinalProject\app\build\intermediates\res\merged\debug\values\values.xml 
Error:(31) Error retrieving parent for item: No resource found that matches the given name 'Theme.AppCompat.Light.DarkActionBar'. 
Error:(37) Error retrieving parent for item: No resource found that matches the given name 'ThemeOverlay.AppCompat.Dark.ActionBar'. 
Error:(42) Error retrieving parent for item: No resource found that matches the given name 'ThemeOverlay.AppCompat.Light'. 
Error:Execution failed for task ':app:processDebugResources'. 
> com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process 'command 'C:\Users\User\AppData\Local\Android\sdk\build-tools\23.0.2\aapt.exe'' finished with non-zero exit value 1 

而且我的AndroidManifest.xml:

<?xml version="1.0" encoding="utf-8"?> 
    <manifest xmlns:android="http://schemas.android.com/apk/res/android" 
    package="com.example.user.finalproject"> 

    <application 
     android:allowBackup="true" 
     android:icon="@mipmap/ic_launcher" 
     android:label="@string/app_name" 
     android:supportsRtl="true" 
     android:theme="@style/AppTheme"> 
     <activity 
      android:name=".MainActivity" 
      android:label="@string/app_name" 
      android:theme="@style/AppTheme.NoActionBar"> 
      <!--<intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter>--> 
     </activity> 
     <activity 
      android:name=".Login" 
      android:label="@string/title_activity_login" 
      android:theme="@style/AppTheme.NoActionBar"> 
      <!-- 
      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter>--> 
     </activity> 
     <activity 
      android:name=".ReceiveOffer" 
      android:label="@string/title_activity_receive_offer" 
      android:theme="@style/AppTheme.NoActionBar"> 

       <!--<intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter>--> 
     </activity> 
     <activity 
      android:name=".PostReviews" 
      android:label="@string/title_activity_post_reviews" 
      android:theme="@style/AppTheme.NoActionBar"> 

      <!--<intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter>--> 
     </activity> 
     <activity 
      android:name=".PostComplaints" 
      android:label="@string/title_activity_post_complaints" 
      android:theme="@style/AppTheme.NoActionBar"> 

      <!--<intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter>--> 
     </activity> 
     <activity 
      android:name=".RegistrationV" 
      android:label="@string/title_activity_registration_v" 
      android:theme="@style/AppTheme.NoActionBar"> 
     <!-- 
     <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter>--> 
     </activity> 
     <activity 
      android:name=".LoginV" 
      android:label="@string/title_activity_login_v" 
      android:theme="@style/AppTheme.NoActionBar"> 

     <!-- <intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter>--> 
     </activity> 
     <activity 
      android:name=".ProvideOffer" 
      android:label="@string/title_activity_provide_offer" 
      android:theme="@style/AppTheme.NoActionBar"> 

      <intent-filter> 
       <action android:name="android.intent.action.MAIN" /> 

       <category android:name="android.intent.category.LAUNCHER" /> 
      </intent-filter> 
     </activity> 
     <activity 
      android:name=".RegActivity" 
      android:label="@string/title_activity_reg" 
      android:theme="@style/AppTheme.NoActionBar"> 
     <!--<intent-filter> 
      <action android:name="android.intent.action.MAIN" /> 

      <category android:name="android.intent.category.LAUNCHER" /> 
     </intent-filter>--> 
     </activity> 
     </application> 

     </manifest> 

我mainactivity.java:

package com.example.user.finalproject; 

    import android.app.Activity; 
    import android.os.Bundle; 
    import android.support.design.widget.FloatingActionButton; 
    import android.support.design.widget.Snackbar; 
    import android.support.v7.app.AppCompatActivity; 
    import android.support.v7.widget.Toolbar; 
    import android.view.View; 
    import android.view.Menu; 
    import android.view.MenuItem; 
    import android.view.ViewGroup.LayoutParams; 

    public class MainActivity extends AppCompactActivity { 


     @Override 
     protected void onCreate(Bundle savedInstanceState) { 
      super.onCreate(savedInstanceState); 
      setContentView(R.layout.activity_main); 
      Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar); 
      setSupportActionBar(toolbar); 

      FloatingActionButton fab = (FloatingActionButton) findViewById(R.id.fab); 
      fab.setOnClickListener(new View.OnClickListener() { 
       @Override 
       public void onClick(View view) { 
        Snackbar.make(view, "Replace with your own action", Snackbar.LENGTH_LONG) 
          .setAction("Action", null).show(); 
       } 
      }); 
     } 

     @Override 
     public boolean onCreateOptionsMenu(Menu menu) { 
      // Inflate the menu; this adds items to the action bar if it is present. 
      getMenuInflater().inflate(R.menu.menu_main, menu); 
      return true; 
     } 

     @Override 
     public boolean onOptionsItemSelected(MenuItem item) { 
      // Handle action bar item clicks here. The action bar will 
      // automatically handle clicks on the Home/Up button, so long 
      // as you specify a parent activity in AndroidManifest.xml. 
      int id = item.getItemId(); 

      //noinspection SimplifiableIfStatement 
      if (id == R.id.action_settings) { 
       return true; 
      } 

      return super.onOptionsItemSelected(item); 
     } 
    } 

而且這種事情發生因爲不知道什麼原因。

請推薦一些解決方案,因爲我試過了: 1.安裝新的Android Studio 2.清理項目。 3. Gradle構建。

Styles.XML:

<resources> 

<!-- Base application theme. --> 
<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
    <!-- Customize your theme here. --> 
    <item name="colorPrimary">@color/colorPrimary</item> 
    <item name="colorPrimaryDark">@color/colorPrimaryDark</item> 
    <item name="colorAccent">@color/colorAccent</item> 
</style> 

<style name="AppTheme.NoActionBar"> 
    <item name="windowActionBar">false</item> 
    <item name="windowNoTitle">true</item> 
</style> 

<style name="AppTheme.AppBarOverlay" parent="ThemeOverlay.AppCompat.NoActionBar" /> 

<style name="AppTheme.PopupOverlay" parent="ThemeOverlay.AppCompat.Light" /> 

應用級別的build.gradle:

apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion '23.0.2' 

defaultConfig { 
    applicationId "com.example.user.finalproject" 
    minSdkVersion 19 
    targetSdkVersion 23 
    versionCode 1 
    versionName "1.0" 
} 
buildTypes { 
    release { 
     minifyEnabled false 
     proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
    } 
} 
} 

dependencies { 
apply plugin: 'com.android.application' 

android { 
    compileSdkVersion 23 
    buildToolsVersion '23.0.3' 
    defaultConfig { 
     applicationId "com.example.user.finalproject" 
     minSdkVersion 19 
     targetSdkVersion 19 
     versionCode 1 
     versionName "1.0" 
    } 
    buildTypes { 
     release { 
      minifyEnabled false 
      proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' 
     } 
    } 
    productFlavors { 
    } 
} 
dependencies { 

compile 'com.android.support:appcompat-v7:23.0.3-alpha2' 
compile 'com.android.support:design:23.0.3-alpha2' 
compile 'com.android.support:support-annotations:23.0.3-alpha2' 
compile 'com.android.support:support-v4:23.0.3-alpha2' 
compile 'com.android.support:support-v13:23.0.3-alpha2' 
compile 'com.android.support:gridlayout-v7:23.0.3-alpha2' 
compile 'com.android.support:mediarouter-v7:23.0.3-alpha2' 
compile 'com.google.android.gms:play-services:8.4.0' 
compile 'com.google.android.gms:play-services-maps:8.4.0' 
compile 'com.google.android.gms:play-services-ads:8.4.0' 
compile 'com.google.android.gms:play-services-auth:8.4.0' 
compile 'com.google.android.gms:play-services-gcm:8.4.0' 
compile fileTree(dir: 'libs', include: ['*.jar']) 
testCompile 'junit:junit:4.12' 
compile 'com.android.support:appcompat-v7:23.0.3' 

}

} 

在構建的gradle所示的錯誤是這樣的: 不能由C讀取軟件包名稱:\用戶\用戶\ AndroidStudioProjects \ FinalProject \程序\ SRC \主\ AndroidManifest.xml中

現在有這樣的錯誤:

com.android.ide.common.process.ProcessException :org.gradle.process.internal.ExecException:進程'command'C:\ Users \ User \ AppData \ Local \ Android \ sdk \ build-tools \ 23.0.3 \ aapt.exe''以非零退出值結束1

回答

0

你應該去RES /價值/ styles.xml和改變這一行:

<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar"> 

<style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar"> 
+0

我沒有發生任何事@majid –

+0

在你的問題的最後加上你的'styles.xml' – majid

+0

你能提出一些建議嗎? - @ majid –

0

你可以添加build.gradle文件嗎? 這裏有一些參考 link link2 link3 link4

編輯

dependencies { 
    compile fileTree(dir: 'libs', include: ['*.jar']) 
    testCompile 'junit:junit:4.12' 
    compile 'com.android.support:appcompat-v7:23.2.1' 
} 

你的依賴是空的。

+0

這裏是build.gradle:'code'//頂層構建文件,您可以在其中添加所有子項目/模塊通用的配置選項。 buildscript { 庫{ jcenter() } 依賴{ 類路徑 'com.android.tools.build:gradle:2.1.0' //注意:不要在這裏把你的應用程序依賴關係;他們屬於 //各個模塊的build.gradle文件 }} allprojects { 庫{ jcenter() }} 任務乾淨(類型:刪除){ 刪除rootProject.buildDir } –

+0

應用程序級別build.gradle,您可以使用相同的編輯ans –

+0

我非常抱歉,我很急! –

0

我猜的錯誤是在

<style name="AppTheme.NoActionBar"> 

將其更改爲

<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.NoActionBar"> 

或其他任何主題已經可以從安卓(父屬性)。在第一種情況下,您只是創建了一個名爲「AppTheme.NoActionBar」的新樣式。但是爲了創建一個新的樣式,你必須在父屬性中指定一個父類型(由android提供)。

UPDATE

依賴部分是空的。這是導致錯誤的原因。添加

compile fileTree(dir: 'libs', include: ['*.jar']) 
testCompile 'junit:junit:4.12' 
compile 'com.android.support:appcompat-v7:23.2.1' 

您的gradle文件中的依賴關係{}。對不起,我沒有注意到它。

+0

不,它也沒有幫助,而是它也成爲一個錯誤。@ AkhilSoman –

+0

我已經更新了我的答案,請檢查。 –

+0

我已經更新了依賴項,請看看。 @Akhil Soman –