Cannot resolve symbols in Android Studio and the code is okay - android

I know that this question was asked here a few times, but everything i have tried from answers they gave there didn't work for me.
Also i need to mention that i have tried File - Invilidate Cache and Restart and it didn't work..
Here is my build gradle(Maybe something there is wrong):
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.dusandimitrijevic.geomondo"
minSdkVersion 19
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:recyclerview-v7:+'
compile 'com.mcxiaoke.volley:library:1.0.19'
compile 'com.github.manuelpeinado.fadingactionbar:fadingactionbar:3.1.2'
}

I see three issues.
Your targetSdkVersion is higher than your compileSdkVersion.
You are using a version of the support library that requires a minimum of API 22 to compile with.
You are not specifying the version of recyclerview, so it will import the latest one, which requires API 23 to compile with.
The fix is to set compileSdkVersion to 23. That SHOULD fix your missing symbols issue.

Related

Cannot resolve method: CameraSource.Builder.setAutoFocusEnabled

I use Vision API to scan barcode. It's almost done, except auto-focus. I follow the guide in this link: https://developers.google.com/android/reference/com/google/android/gms/vision/CameraSource.Builder, use setAutoFocusEnabled method and get an error: "Cannot resolve method 'setAutoFocusEnabled(boolean)'"
My Android studio version: 2.1.1
JRE: 1.8.0
file build.gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "***"
minSdkVersion 17
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
compile 'com.android.support:support-v4:23.4.0'
compile 'com.google.android.gms:play-services:7.8+'
}
You are reading newer documentation than the library you are using.
If you want the newer features, then upgrade.
Replace com.google.android.gms:play-services:7.8+
With com.google.android.gms:play-services-vision:10.0.0, or some other, later version than 7.8.
See about selective compilation. It will make your app smaller, and build faster.

"Error:(2) Error retrieving parent for item No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'

I have a problem with Gradle !!
It keeps showing me errors , can some one help me to resolve this problem
Note: It's my first time to install android studio
Try using this:
compile 'com.android.support:appcompat-v7:24.1.0'
Use latest support library and change your target and compile sdk also
compileSdkVersion 24
buildToolsVersion "24.0.1"
targetSdkVersion 24
Try it
compile "com.android.support:appcompat-v7:23.0.1"
and you can change targetSdkVersion 23
Please use my project gradle values and also update sdk libraries:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
multiDexEnabled true
applicationId "com.example.student" //change as your package name
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
}
Try to match all versions:
compileSdkVersion 23
buildToolsVersion '23.0.0'
targetSdkVersion 23
Add Following dependencies:
compile 'com.android.support:appcompat-v7:23.0.0'
Make sure you use latest version of Sdk:
how to update sdk
The problem is you're using
compile 'com.android.support:appcompat-v7:19.+'
which gives you all possibilities of Android 4.4.2 Kitkat API 19 and older.
In your project you're trying to use Material Themes which belongs to newer version, I mean com.android.support:appcompat:$version, where version > 21.
Material Design was introduced with Android 5.1 Lollipop API 21
I higly reccomend you to change your build.gradle file to:
apply plugin: 'com.android.application'
android {
compileSdkVersion 24
buildToolsVersion "24.0.2"
defaultConfig {
minSdkVersion 21
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile "com.android.support:appcompat-v7:24.2.1"
}
but of course changing appcompat library to version :
com.android.support:appcompat-v7:23.0.1"
would be enough ;-)
Hope it would help

Emulators are not showing in Android Studio

In Android Studio the Emulators are not showing . I tried that disabling ADB Integration. but it is not working for me.
Please give me solution for this problem.
Maybe your project is not compatible (API version) with the target emulator. Check build.gradle file if the targetSDK and minimumSdk version is lower or equal to the sdk version of your Emulator.
Be sure that your compiledSdkVersion matches minSdkVersion and supported by targetSdkVersion. For example:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "24.0.0"
defaultConfig {
applicationId "zeta.sqlitetest3"
minSdkVersion 16
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.4.0'
}

Gradle build error."minsdkversion 14 cannot be different than version l declared in library"?

Hi everyone I am new to android developing.I download the latest version of android studio 1.3.2 yesterday.But when I start a new project for testing, gradle give me an error.
My gradle is
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "com.example.niyamat.testing3"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.+'
}
The error is
Error:Execution failed for task ':app:processDebugManifest'.
> Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be different than version L declared in library [com.android.support:appcompat-v7:21.0.0-rc1] C:\Users\Niyamat\Documents\Testing3\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.0-rc1\AndroidManifest.xml
I know there are some question about the same error but I didn't find any good solution.
So please someone help me?
Whats your Logcat Throws
Manifest merger failed : uses-sdk:minSdkVersion 15 cannot be different than version L declared in library [com.android.support:appcompat-v7:21.0.0-rc1]
What should you Do
Remove minSdkVersion version from Manifest .You already declare it in your build.gradle .
Use this compileSdkVersion 21
buildToolsVersion '21.1.2' instead yours.
Compile compile 'com.android.support:appcompat-v7:21.0.1'
First of all remove this line from your Manifest .
<uses-sdk android:minSdkVersion="15" android:targetSdkVersion="22" />
Finally
apply plugin: 'com.android.application'
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "com.example.niyamat.testing3"
minSdkVersion 15
targetSdkVersion 21
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.1'
}
It is your issue.
uses-sdk:minSdkVersion 15 cannot be different than version L declared in library [com.android.support:appcompat-v7:21.0.0-rc1]
It is quite strange that you have in your sdk folder the preview version of appcompat 21.
This version was published with the lollipop preview (api-L) and had the minSdk = L. It is the reason of your issue (because you have minSdkVersion 15)
You should not have this folder in your sdk. Check with the SDK Manager if it is updated.
Then you can modify your build.gradle removing the +.
Support libraries v21
compile 'com.android.support:appcompat-v7:21.0.0'
compile 'com.android.support:appcompat-v7:21.0.2'
compile 'com.android.support:appcompat-v7:21.0.3'
Support libraries v22 (require compileSdkVersion 22)
compile 'com.android.support:appcompat-v7:22.0.0'
compile 'com.android.support:appcompat-v7:22.1.0'
compile 'com.android.support:appcompat-v7:22.1.1'
compile 'com.android.support:appcompat-v7:22.2.0'
compile 'com.android.support:appcompat-v7:22.2.1'
Support libraries v23 (require compileSdkVersion 23)
compile 'com.android.support:appcompat-v7:23.0.0'
compile 'com.android.support:appcompat-v7:23.0.1'
Seems you have a previous version of the app compat into your lib folder specific for android L.
Also you should set the version for compileSdkVersion, buildToolVersion, targetSdkVersion and the appcompat-v7 to be the same.
In your case, the buildToolVersion should be "21.1.2".
Basically, this is the reason why android studio complains / suggests NOT using .+ in your compiles.
compile 'com.android.support:appcompat-v7:21.+'
It forces compile with absolute last version of appcompat 21 which is com.android.support:appcompat-v7:21.0.0-rc1 (as you can see from error you got). That version does not allow minSdkVersion 15 - it's made for Lollipop. Change your compile appcompat to version number that does allow minSdkVersion 15 to solve the issue.

support:CardView minimum SDK?

I'm trying to add CardView support into my app for devices lower than Android L by adding the line:
compile 'com.android.support:cardview-v7:21.+'
I've then added compileSdkVersion and targetSdkVersion to 'android-L'
Now, unless I am mistaken, I thought that this would have built on my Nexus 5 in 4.4.4, however I get the error
Failure [INSTALL_FAILED_OLDER_SDK]
Am I missing something or misunderstood this? Full build.gradle below:
apply plugin: 'com.android.application'
android {
compileSdkVersion 'android-L'
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "com.gh.app"
minSdkVersion 15
targetSdkVersion 'android-L'
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
wearApp project(':wear')
compile 'com.google.android.gms:play-services-wearable:+'
compile 'com.android.support:support-v4:20.0+'
compile files('libs/TalkClient.jar')
compile 'com.android.support:cardview-v7:21.+'
}
While CardView and RecyclerView are both new widgets being added to the support library (and therefore will be available on API 7+ devices), during the developer preview they are limited to Android L devices only.

Categories

Resources