Android Studio突然显示此错误can not resolve symbol R
这是我的build.gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 28
defaultConfig {
applicationId "com.galiyara.sandy.galiyara"
minSdkVersion 23
targetSdkVersion 28
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:28.0.0'
implementation 'com.android.support:recyclerview-v7:28.0.0'
implementation 'com.android.support:recyclerview-selection:28.0.0'
implementation 'com.android.support:cardview-v7:28.0.0'
implementation 'com.android.support:design:28.0.0'
implementation 'com.android.support:support-v4:28.0.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.github.chrisbanes:PhotoView:2.0.0'
testImplementation 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.2'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2'
implementation 'com.github.bumptech.glide:glide:4.8.0'
annotationProcessor 'com.github.bumptech.glide:compiler:4.8.0'
implementation 'com.android.support:exifinterface:28.0.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
}
和
// Top-level build file where you can add configuration options common to all sub-projects/modules.
buildscript {
repositories {
google()
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.3.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
}
}
allprojects {
repositories {
google()
jcenter()
maven {
url "https://jitpack.io"
}
}
}
task clean(type: Delete) {
delete rootProject.buildDir
}
Manifest.xml
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.galiyara.sandy.galiyara">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.SET_WALLPAPER"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<provider
android:name="android.support.v4.content.FileProvider"
android:authorities="com.galiyara.sandy.galiyara.provider"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/paths"/>
</provider>
<!-- Main activity -->
<activity
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>
<category android:name="android.intent.category.LAUNCHER"/>
</intent-filter>
</activity>
<!-- Albums activity -->
<activity android:name=".AlbumsActivity"/>
<!-- Image view activity -->
<activity android:name=".ImageViewActivity"/>
<!-- Image cropper activity -->
<activity android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:theme="@style/Base.Theme.AppCompat"/>
</application>
</manifest>
答案 0 :(得分:0)
转到 文件 > 设置 > 投标,执行,部署 > 成绩
检查 Gradle Home 是否具有最新版本 gradle-4.10.1 。
D:/Gradle/.gradle/wrapper/dists/gradle-4.10.1-all/byrf7c6xk4p2imgx1wxxfgf3t/gradle-4.10.1
答案 1 :(得分:0)
添加buildToolsVersion '28.0.3'
&将顶级gradle文件更新为:
dependencies { classpath 'com.android.tools.build:gradle:3.5.0-alpha02' }
在库下面更新
implementation 'com.github.chrisbanes:PhotoView:2.0.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
最新版本
implementation 'com.github.chrisbanes:PhotoView:2.3.0'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.8.0'
对于image-cropper
库
将此行添加到您的Proguard配置文件中
-keep class android.support.v7.widget.** { *; }
,并检查库之间是否存在任何冲突。如果在gradle同步过程中出现任何错误,只需添加错误,我们就会解决。
如果语法有误,请检查您的strings.xml
或任何其他.xml file under "values"
文件夹
并且请使用最新版本的Android Studio