【问题标题】:Android Studio 3.5.3 does not import some widgetAndroid Studio 3.5.3 不导入某些小部件
【发布时间】:2020-05-18 13:19:53
【问题描述】:

Android Studio 不导入某些小部件。

我尝试了以下选项,但都失败了。

1.缓存失效并重启

2.清理和重建项目

3.退出AS,删除.iml文件和.deal文件夹,导入工程

4.与文件系统同步

5.将项目与 Gradle 文件同步。

6.卸载AS,重新安装相同版本。

以上都没有帮助,请有人帮助我。

应用程序等级

 apply plugin: 'com.android.application'

 apply plugin: 'com.google.gms.google-services'


 android {

compileSdkVersion 29

buildToolsVersion "29.0.2"

defaultConfig {
    applicationId "com.example.viewvideo"
    minSdkVersion 16
    targetSdkVersion 29
    multiDexEnabled true
    versionCode 1
    versionName "1.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}

buildTypes {
    release {
        minifyEnabled false
        proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
    }
}
}

 dependencies
  {

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

implementation 'androidx.appcompat:appcompat:1.1.0'

implementation 'androidx.constraintlayout:constraintlayout:1.1.3'

testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test.ext:junit:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
implementation 'com.google.firebase:firebase-auth:19.2.0'
implementation 'com.google.firebase:firebase-analytics:17.2.2'
implementation 'com.google.firebase:firebase-firestore:21.3.1'
implementation 'com.google.firebase:firebase-database:19.2.0'
implementation 'com.google.firebase:firebase-storage:19.1.0'
implementation 'androidx.multidex:multidex:2.0.0'
}

项目 Gradle 级别

buildscript{    

 repositories {

    google()
    jcenter()

}
dependencies {
    classpath 'com.android.tools.build:gradle:3.5.3'
    classpath 'com.google.gms:google-services:4.3.3'

    // NOTE: Do not place your application dependencies here; they     belong
    // in the individual module build.gradle files
}
}

allprojects {

repositories {
    google()
    jcenter()

}
}

   task clean(type: Delete) {

   delete rootProject.buildDir
   }

【问题讨论】:

  • 你能显示你的应用级 gradle 文件吗?
  • 希望你的意思是@majuran

标签: java android-studio android-layout android-widget


【解决方案1】:

更新

我认为,您在使用 Android SDK 时遇到问题。删除并重新安装 Android SDK 即可解决问题


首先尝试在 ViewActivity 中手动导入 ImageButton 以检查库中的类是否可用

import android.widget.ImageButton;

然后添加

implementation 'androidx.legacy:legacy-support-v4:1.0.0'

并删除

buildToolsVersion "29.0.2"

同步并重试...告诉我

【讨论】:

  • 我已经按照你的建议尝试了@majuran,但还是一样。该类似乎不在库中。
  • 我刚刚添加了它
  • 似乎一切都很好。关闭您的 Android 工作室,然后删除项目中的 .gradle 目录。再次在 Android Studio 中打开您的项目。它会再次下载库
  • 已删除项目内的 .gradle 目录,但仍然相同。我认为正如您@majuran 所建议的那样,该课程不在图书馆内,如果是这种情况,您该如何处理?
  • 我没有遇到这种问题。我认为,您在使用 Android SDK 时遇到问题。删除并重新安装 Android SDK 可能会对您有所帮助
猜你喜欢
  • 1970-01-01
  • 1970-01-01
  • 2016-09-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2014-09-18
  • 2013-07-19
相关资源
最近更新 更多