简体   繁体   English

包 android.support.design.widget 不存在

[英]package android.support.design.widget does not exist

build.gradle(module:app) build.gradle(模块:应用程序)

apply plugin: 'com.android.application'

  android {
        compileSdkVersion 29
        buildToolsVersion '29.0.2'

        defaultConfig {
            applicationId "com.example.android.miwok"
            minSdkVersion 15
            targetSdkVersion 29
            versionCode 1
            versionName "1.0"
            testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
        }
        buildTypes {
            release {
                minifyEnabled false
                proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
            }
        } }


    dependencies {
        implementation 'com.android.support.constraint:constraint-layout:1.1.3'
        fileTree(dir: 'libs', include: ['*.jar'])
        implementation 'androidx.appcompat:appcompat:1.1.0'
        testImplementation 'junit:junit:4.12'
        androidTestImplementation 'androidx.test:runner:1.2.0'
        androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
        'com.android.support:design:28.0.0'
        'com.google.android.material:material:1.0.0-'
        'com.android.support:support-v13:28.0.0'
        'com.android.support:support-annotations:28.0.0'
        'com.android.support:appcompat-v7:28.0.0' }

my mainActivity.java我的 mainActivity.java

package com.example.android.miwok;


import android.os.Bundle; import
android.support.design.widget.TabLayout;

import androidx.appcompat.app.AppCompatActivity; import
androidx.viewpager.widget.ViewPager;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate (Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);

        // Set the content of the activity to use the activity_main.xml layout file
        setContentView(R.layout.activity_main);

        // Find the view pager that will allow the user to swipe between fragments
        ViewPager viewPager = (ViewPager) findViewById(R.id.viewpager);


        // Create an adapter that knows which fragment should be shown on each page
        CategoryAdapter adapter = new CategoryAdapter(this, getSupportFragmentManager());


        // Set the adapter onto the view pager
        viewPager.setAdapter(adapter);

        // Find the tab layout that shows the tabs
        TabLayout tabLayout = (TabLayout) findViewById(R.id.tabs);

        // Connect the tab layout with the view pager. This will
        //   1. Update the tab layout when the view pager is swiped
        //   2. Update the view pager when a tab is selected
        //   3. Set the tab layout's tab names with the view pager's adapter's titles
        //      by calling onPageTitle()
        tabLayout.setupWithViewPager(viewPager);
    }
}

In your code you are mixing Support library with AndroidX library which is not permissible.在您的代码中,您将Support库与AndroidX库混合使用。 Remove support library and use AndroidX .删除support库并使用AndroidX To migrate AndroidX correctly follow below steps:要正确迁移 AndroidX,请按照以下步骤操作:

From Android Studio Menu从 Android Studio 菜单

  1. Select Refactor -> Migrate to AndroidX选择重构 -> 迁移到 AndroidX
  2. Press Do Refactor执行重构

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 错误:包 android.support.design.widget 不存在 - error: package android.support.design.widget does not exist 错误包 android.support.design.widget 不存在 - error package android.support.design.widget does not exist 错误:包 android.support.design.widget 不存在 import android.support.design.widget.FloatingActionButton; - error: package android.support.design.widget does not exist import android.support.design.widget.FloatingActionButton; 无法解决错误:包 android.support.design.widget 不存在问题 - Can't resolve error: package android.support.design.widget does not exist issue 在Xamarin中使用android.support.design.widget - Use android.support.design.widget in Xamarin 库android.support.design.widget错误 - Error with library android.support.design.widget 找不到 android.support.design.widget 类 - android.support.design.widget class not found 给定的工件包含一个带有 package 引用的字符串文字 'android.support.design.widget' 不能被安全地重写 - The given artifact contains a string literal with a package reference 'android.support.design.widget' that cannot be safely rewritten 为 android.support.design.widget 更改 TextInputLayout 的 boxBackgroundColor - change boxBackgroundColor of TextInputLayout for android.support.design.widget Crosswalk Xwalk Webview冲突CollapsingToolbarLayout <android.support.design.widget> - Crosswalk Xwalk Webview conflict CollapsingToolbarLayout<android.support.design.widget>
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM