错误包android.support.design.widget不存在

当我尝试构建我的android项目时,出现此错误

错误:(8,37)错误:包android.support.design.widget不存在错误:(18,9)错误:找不到符号类TabLayout错误:(18,32)错误:找不到符号类TabLayout错误:

(21,33)错误:找不到符号变量TabLayout错误:(27,56)错误:软件包TabLayout不存在错误:(48,36)错误:找不到符号变量菜单错误:(28,57)错误:软件包TabLayout不存在错误:任务’:app:compileDebugJavaWithJavac’的执行失败。

编译失败;有关详细信息,请参见编译器错误输出。错误:(55,23)错误:找不到符号变量action_settings

这是我的代码

package com.chaos.creativo;

import android.os.Bundle;

import android.support.v4.view.ViewPager;

import android.support.v7.app.AppCompatActivity;

import android.view.Menu;

import android.view.MenuItem;

import android.support.design.widget.TabLayout;

/**

* Created by ahmed on 3/7/2016.

*/

public class Signin_up extends AppCompatActivity {

@Override

protected void onCreate(Bundle savedInstanceState) {

super.onCreate(savedInstanceState);

setContentView(R.layout.signing_up);

TabLayout tabLayout = (TabLayout) findViewById(R.id.tab_layout);

tabLayout.addTab(tabLayout.newTab().setText("SIGN IN"));

tabLayout.addTab(tabLayout.newTab().setText("SIGN UP"));

tabLayout.setTabGravity(TabLayout.GRAVITY_FILL);

final ViewPager viewPager = (ViewPager) findViewById(R.id.pager);

final PageAdapter adapter = new PageAdapter(getSupportFragmentManager(), tabLayout.getTabCount());

viewPager.setAdapter(adapter);

viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));

tabLayout.setOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {

@Override

public void onTabSelected(TabLayout.Tab tab) {

viewPager.setCurrentItem(tab.getPosition());

}

@Override

public void onTabUnselected(TabLayout.Tab tab) {

}

@Override

public void onTabReselected(TabLayout.Tab tab) {

}

});

}

@Override

public boolean onCreateOptionsMenu(Menu menu) {

getMenuInflater().inflate(R.menu.menu_main, menu);

return true;

}

@Override

public boolean onOptionsItemSelected(MenuItem item) {

int id = item.getItemId();

if (id == R.id.action_settings) {

return true;

}

return super.onOptionsItemSelected(item);

}

}

我的build.gradle

> apply plugin: 'com.android.application'

>

> android {

> compileSdkVersion 23

> buildToolsVersion "23.0.2"

>

> defaultConfig {

> applicationId "com.chaos.creativo"

> minSdkVersion 18

> targetSdkVersion 23

> versionCode 1

> versionName "1.0"

> }

> buildTypes {

> release {

> minifyEnabled false

> proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'

> }

> } }

>

> dependencies {

> compile fileTree(dir: 'libs', include: ['*.jar'])

> testCompile 'junit:junit:4.12'

> compile 'com.android.support:appcompat-v7:23.1.1'

> compile 'com.google.android.gms:play-services-ads:8.4.0'

> compile 'com.google.android.gms:play-services-identity:8.4.0'

> compile 'com.firebase:firebase-client-android:2.3.1'

> compile 'com.google.android.gms:play-services-gcm:8.4.0'

> compile 'com.android.support:support-v4:23.2'

> compile 'com.android.support:design:23.2' }

回答:

如果您使用的是android studio,则将以下内容放入gradle文件中并进行重建。

 compile 'com.android.support:support-v4:23.2.1'

compile 'com.android.support:design:23.2.1'

如果版本23.2.1不支持,请使用23.1.1

以上是 错误包android.support.design.widget不存在 的全部内容, 来源链接: utcz.com/qa/425776.html

回到顶部