无法使用 gradle 导入 android.support.v7 和注释库
Can't import android.support.v7 and annotation libary with gradle
我正在尝试完成本教程 Android 实现首选项设置屏幕
他进口android.support.v7...
和android.suppor.annotation libary...
我做了最推荐的答案并将这些包实施到我的 build.gradle 并重新同步。
Android studio 无法解析 v7 和注释。
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
gradle.build:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "info.androidhive.preferences"
minSdkVersion 19
targetSdkVersion 29
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.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.android.support:appcompat-v7:+'
}
我预计,在重新同步库后可用,而不是错误消息
cant resolve symbol v7 for instance.
感谢您的帮助。
您正在使用 androidx:implementation 'androidx.appcompat:appcompat:1.0.2'
.
在您的代码中,您必须导入 correct class:
import androidx.appcompat.widget.Toolbar;
在您的 build.gradle
中也删除
//implementation 'com.android.support:appcompat-v7:+'
对于注释 use:
androidx.annotation:annotation:1.1.0
我正在尝试完成本教程 Android 实现首选项设置屏幕
他进口android.support.v7...
和android.suppor.annotation libary...
我做了最推荐的答案并将这些包实施到我的 build.gradle 并重新同步。
Android studio 无法解析 v7 和注释。
import android.support.annotation.LayoutRes;
import android.support.annotation.Nullable;
import android.support.v7.widget.Toolbar;
gradle.build:
apply plugin: 'com.android.application'
android {
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
applicationId "info.androidhive.preferences"
minSdkVersion 19
targetSdkVersion 29
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.0.2'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'androidx.test:runner:1.1.1'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1'
implementation 'com.android.support:appcompat-v7:+'
}
我预计,在重新同步库后可用,而不是错误消息
cant resolve symbol v7 for instance.
感谢您的帮助。
您正在使用 androidx:implementation 'androidx.appcompat:appcompat:1.0.2'
.
在您的代码中,您必须导入 correct class:
import androidx.appcompat.widget.Toolbar;
在您的 build.gradle
//implementation 'com.android.support:appcompat-v7:+'
对于注释 use:
androidx.annotation:annotation:1.1.0