错误 - 无法解析方法,符号

时间:2016-04-30 08:34:05

标签: android android-resources

这是错误:

 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 build。

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" />

App level 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 build中显示的错误是: 无法从C:\ Users \ User \ AndroidStudioProjects \ FinalProject \ app \ src \ main \中读取包名称 的AndroidManifest.xml

现在出现了这个错误:

com.android.ide.common.process.ProcessException:org.gradle.process.internal.ExecException:进程&#39;命令&#39; C:\ Users \ User \ AppData \ Local \ Android \ sdk \构建工具\ 23.0.3 \ aapt.exe&#39;&#39;完成非零退出值1

3 个答案:

答案 0 :(得分:0)

您应该转到res / values / styles.xml并更改此行:

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

到:

@{
    ViewBag.Title = "Index";
    Layout = "~/Views/Shared/_Layout.cshtml";
}

<h2>Create popup</h2>
<input  onclick="showPopup()" type="button" value="Click"/>
<div id="divContaiPopup" class="table-responsive" style="display:none;">
    <div>
        <table class="table table-striped table-hover3">
            <tr>
                <td>hi</td>
                <td>hello</td>
            </tr>
        </table>
    </div>
</div>
<script type="text/javascript">
    function showPopup() {
        $("#divContaiPopup").dialog({
            height:400,
            width:500,
            modal:true,
            buttons:{
                "OK":function(){
                    $(this).dialog("close");
                    aert('you selected ok!!')
                },
                "Cancel":function(){
                    $(this).dialog("close");
                }
            }
        }
        );
                }
    
</script>

答案 1 :(得分: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'
}

您的依赖项是空的。

答案 2 :(得分:0)

我猜这个错误是在

<style name="AppTheme.NoActionBar">

将其更改为

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

或Android中已有的任何其他主题(对于父属性)。在第一种情况下,您刚刚创建了一个名为“AppTheme.NoActionBar”的新样式。但是为了创建一个新的样式,你必须在父属性中指定一个父样式(由android提供)。

<强>更新

依赖关系部分为空。这就是导致错误的原因。添加

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

在gradle文件中的依赖项{}内。对不起我之前没有注意到。