据我所知android studio在查找support-v7库以导入所有文件时遇到困难
这是我的主要活动:
import android.support.design.widget.NavigationView
import android.support.design.widget.Snackbar
import android.support.v4.view.GravityCompat
import android.support.v7.app.ActionBarDrawerToggle
import android.support.v7.app.AppCompatActivity
import android.support.v7.widget.DefaultItemAnimator
import android.support.v7.widget.LinearLayoutManager
import android.support.v7.widget.RecyclerView
我收到的错误消息是:
未解决的参考:小部件
这是我的项目级别gradle文件:
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
ext.kotlin_version = '1.2.61'
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.1.4'
classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version"
classpath "org.jetbrains.kotlin:kotlin-android-extensions:$kotlin_version"
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.0.2'
}
}
allprojects {
repositories {
google()
jcenter()
mavenCentral()
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
这是我的应用程序gradle文件:
apply plugin: 'com.android.application'
apply plugin: 'kotlin-android'
apply plugin: 'kotlin-android-extensions'
android {
compileSdkVersion 27
defaultConfig {
applicationId "com.example.test"
minSdkVersion 19
targetSdkVersion 27
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
vectorDrawables.useSupportLibrary = true
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version"
implementation 'com.android.support:appcompat-v7:27.1.1'
implementation 'com.android.support:design:27.1.1'
implementation 'com.google.firebase:firebase-messaging:17.3.1'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'org.jsoup:jsoup:1.11.3'
implementation 'com.github.bumptech.glide:volley-integration:4.8.0'
implementation 'com.github.d-max:spots-dialog:1.1@aar'
implementation 'com.github.bumptech.glide:glide:4.8.0'
implementation 'com.google.firebase:firebase-core:16.0.3'
implementation 'com.android.support:cardview-v7:27.1.1'
implementation 'android.arch.paging:runtime:1.0.1'
implementation 'com.android.support:support-vector-drawable:27.1.1'
implementation 'com.android.support:support-v4:27.1.1'
implementation 'com.android.support:recyclerview-v7:27.1.1'
}
apply plugin: 'com.google.gms.google-services'
apply plugin: 'kotlin-android-extensions'
您还可以从这张图片中看到,智能传感器会引发各种错误,但是如果我运行它,它将在模拟器或我的设备上启动并正常运行。
这是从运行gradle同步开始的:
到目前为止,我已经尝试过:
答案 0 :(得分:1)
请按照以下步骤操作。
就是这样。