I am just starting to learn android and i just installed android studio on windows 10 pc. And the very first problem that I am facing is "can not resolve the symbol "AppCompatActivity". Here is my gradle:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.2"
defaultConfig {
applicationId "quikkhome.com.myapplication"
minSdkVersion 14
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.1.0'
compile 'com.android.support:design:23.1.0'
compile 'com.android.support:appcompat-v7:23.1.0'
}
there is problem
android {
compileSdkVersion 23
buildToolsVersion '23.0.1'
you are added 2 time
compile 'com.android.support:appcompat-v7:23.1.0'
remove one time may be its help you
I just fixed the problem (though I do not know how did it work). I just changed the API from 21 to 23 and then back to 21. It is working perfectly now.
Try looking at your xml layout files, make sure all are targeting the same API. Change them to what ever you are targeting if different, like API 23 for example. The latest API may not be working yet, like N preview for example. This can be done by clicking the 'design' tab at the bottom if you are looking at an xml layout. Look for the little android man with the number beside it, click it.
Now also make sure the same theme is selected for all layout files. For example you may be using AppTheme as the theme.
Last run 'clean project'. At the top click Build, in the drop down menu click Clean Project.
Related
I tried all solutions to fix it, but nothing has succeeded. (Turned gradle to "offline work", deleted .gradle files, invalidated and restarted. I also removed the jdk-android studio completely and installed again.)
Here is the problem's screenshot:
Android Studio 3.0 Gradle Sync Problem
Here is my java version
and here is the system/log file:
I think add build tools and sdk version 23 or 24
and if you select to use 23 build tools and sdk version, add dependency like this
compile 'com.android.support:appcompat-v7:23.1.1'
Note:
Wherever its written 26, replace with 23, only if you choose to 23 build tools and sdk version
If there is still any problem you can ask.
You can open build.gradle file in Android studio, then change compileSdkVersion , buildToolsVersion dependencies like this
android {
compileSdkVersion 23
buildToolsVersion "24.0.1"
....
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1'
}
If you did not understood it, can you please share screen shots of your build.gradle file ?
Which is in left side of android studio, under Gradle Scripts -> build.gradle (Modual:app)
Do it this way
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
defaultConfig {
applicationId "com.example.hackl.happybirthday"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "1.0"
testInstrumentationRunner
"android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:23.1.1'
implementation 'com.android.support.constraint:constraint-layout:1.0.2'
testCompile 'junit:junit:4.12'
androidTestImplementation 'com.android.support.test:runner:1.0.1'
androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.1'}
and click sync now (it will be automatically appear when you make changes in this file)
Take these easy steps as per developer.android.com
first add these lines on build.gradle file
buildscript {
repositories {
jcenter()
// You need to add the following repository to download the
// new plugin.
google()
}
dependencies {
classpath 'com.android.tools.build:gradle:3.0.0'
}
}
after that
update Gradle manually, edit the URL in gradle-wrapper.properties to the following:
distributionUrl=\
https\://services.gradle.org/distributions/gradle-4.1-all.zip
For your reference you can check the below link
https://developer.android.com/studio/build/gradle-plugin-3-0-0-migration.html
I uninstalled Android Studio completely and reinstall 3 times. In every step I clicked on Gradle Sync error messages and installed all missing files. 3rd time installation has succeeded with get rid of gradle sync problem with installing missing files correctly. I don't know how and why it has not been successful 1st and 2nd time installation. Anyway, it's done.
Note: Before that I have tried all of answers. Thanks a lot.
Succeeded
apply plugin: 'com.android.application'
android {
compileSdkVersion 25
buildToolsVersion "25.03.1"
defaultConfig {
applicationId "com.example.admin.myapplication"
minSdkVersion 14
targetSdkVersion 25
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', includes: ['*.jar'])
mobileApp project (':mobile')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:25.03.1'
compile 'com.google.android.gms:play-services'
I seen some stack on stack overflow But Still My error is Not Solved I try to understand previous Stack on Stack over flow but it's not working I post on some group no buddy reply so I post here.
By looking at your comments on StackOverflow I guess this is the real culprit,
buildToolsVersion "25.03.1"
and
compile 'com.android.support:appcompat-v7:25.03.1'
Change it to
buildToolsVersion "25.3.1" // remove 0 before 3
compile 'com.android.support:appcompat-v7:25.3.1' // remove 0 before 3
And rebuild the project.
Edit
In order to fix the below error
Wed Sep 13 04:59:29 IST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists distributionUrl=https://services.gradle.org/distributions/gradle-3.3-all.zip the buidl file may missing agradle plugin
Download Gradle from their official site, currently it is 4.1 and extract it to somewhere in your system. (Ex. C:/gradle-4.1/)
Now in Android Studio goto File - Settings - Build and Execution - select Gradle
Here, by default it is Default gradle wrapper(recommended). Now select 2nd radio button and browse to your extracted gradle folder/drive (in my case C:/gradle-4.1). Click OK. (If you want offline mode you can select)
After that click Apply - OK. Now Android Studio starts building project. This will resolve your problem.
I try to move android TV app to Android studio. When I try to compile it, I had some import errors. I couldn't find the dependency that I can add to build.gradle to fix these problem. The list of the imports are:
import android.media.tv.TvContentRatingSystemInfo;
import android.media.tv.TvContract.WatchedPrograms;
import com.android.tv.tuner.data.nano.Track.AtscCaptionTrack;
import com.android.tv.tuner.data.nano.Track.AtscAudioTrack;
import com.android.tv.tuner.data.nano.Channel;
The build.gradle is :
apply plugin: 'com.android.application'
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.android.tv"
minSdkVersion 23
targetSdkVersion 23
versionCode 1
versionName "1.0"
ndk {
moduleName "libtunertvinput_jni"
}
}
sourceSets {
main {
res.srcDirs = ['src/main/res', 'src/main/usbtuner-res']
jni.srcDirs = []
}
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
debug {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile files('libs/exoplayer.jar')
compile project(':common')
compile 'com.android.support:palette-v7:+'
compile 'com.android.support:support-v4:+'
compile 'com.android.support:support-annotations:+'
}
You can't import these because they have #SystemApi annotation. You can check this for the source code of TvContentRatingSystemInfo. I have also checked WatchedPrograms and it also has #SystemApi annotation. I have not checked the other three.
You need to be system app to access these. As you can see here, you need to push your app in the the \system\ folder. You can find detailed information about AOSP build system here.
Solution :
Changing your android.jar to the .jar in this github should enable you to access system API. The reason is your standard android.jar doesn't have system API. So you need to get framework.jar (by adb pull) from emulator and combine it with core.jar then you can have new android.jar which contains system API (system methods and classes are available in the framework.jar from emulator).
Moreover, you should push your apk to \system\priv-app\ folder to access some system API but I don't know why I can access system API without pushing my apk to \system\priv-app\ when I use .jar from that github account.
I feel like I don't write quite clearly but at least now you have more understandings of what you're facing.
android.media.tv and com.android.tv are part of Android SDK. So you don't need to include any additional libraries in gradle.build file.
Just make sure to:
Update your SDK tools to version 24.0.0 or higher
and
Update your SDK with Android 5.0 (API 21) or higher
Example,
android {
compileSdkVersion 26
buildToolsVersion "26.0.1"
defaultConfig {
applicationId "com.example.tvapp"
minSdkVersion 15
targetSdkVersion 26
versionCode 1
versionName "1.0"
}
}
use this in your dependencies "com.android.support:support-media-compat:26.0.2"
and also use tool version "26.0.1"
compiled SDK version 26.
You can add dependencies in app level gradle.
compile 'com.google.android.libraries.tv:companionlibrary:0.1'
I'm currently developing an app at my company, and making use of the AppCompatActivity activity. Upon researching another issue, I decided to update my Android Studio along with my build tools.
Now, my app crashes whenever it tries to load in any activity using AppCompatActivity on devices running Android 4.1.1 (which are the main devices we use). It works fine on 5.0 and 5.1.
Here is the error I am getting:
Caused by: android.content.res.Resources$NotFoundException: File res/drawable/abc_ic_ab_back_material.xml from drawable resource ID #0x7f020016
This isn't the full error, but I cut out the uninteresting stuff (of course a bunch of classes have errors when you can't find a resource).
What drives me crazy is that when I go into the build/intermediates/res folder, I find all of the files that are supposed to be there.
Am I taking crazy pills?
Edit: The solution it points to is for vectorDrawables, not AppCompatActivity.
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.0"
defaultConfig {
applicationId "gillis.kenny.cxsort"
minSdkVersion 15
targetSdkVersion 23
versionCode 1
versionName "3.32"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile project(':library')
compile 'com.android.support:appcompat-v7:23.1.1'
compile 'com.android.support:support-v4:23.1.1'
compile 'com.android.support:design:23.1.1'
}
I have been developing this android for some days now, and suddenly the application build has a lot of errors and doesn't run. First few errors are listed below
D:\somepath\someotherpath\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\21.0.3\res\values-v11\values.xml
Error:(50, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(50, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(50, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
Error:(50, 21) No resource found that matches the given name: attr 'android:actionModeShareDrawable'.
A couple of things might have caused these errrors are listed below
I was attempting to speed up the Emulator by using Intel HAXM, and also use Genymotion. I can see changes in the dependencies of the build.gradle
build.gradle old
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "org.nirvanasoftware.donor_app"
minSdkVersion 8
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:20.0.0'
compile 'com.android.support:support-v4:20.0.0'
}
**build.gradle New **
apply plugin: 'com.android.application'
android {
compileSdkVersion 20
buildToolsVersion "20.0.0"
defaultConfig {
applicationId "org.nirvanasoftware.donor_app"
minSdkVersion 8
targetSdkVersion 20
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
}
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
}
Is the change in dependency causing build errors or something else.
In the dependencies you have used appcompat-v7:21.0.3 and support-v4:21.0.3
But your compileSdkVersion is 20 buildToolsVersion is "20.0.0"
As I know if you use compileSdkVersion 20 then you should use buildToolsVersion "20.0.0" and the version of support library should also be 20 not 21. If you want to use appcompat-v7:21.0.3' and support-v4:21.0.3' you must use compileSdkVersion 21 and buildToolsVersion 21.x.y (here x and y will be the number according to your build tools that you have installed on your computer)
I am not sure that all of your problems are caused for this. But if there is a problem in your gradle synchronization then suddenly you will have a lot of problems. So if you do not have errors other than your gradle build file then your problems should be removed.
My suggestion is if you want to use latest SDKs and Support libraries install the latest build tools and SDKs from the Android SDK Manager then use
compileSdkVersion 21
buildToolsVersion "21.1.2" // your latest build tools
and dependencies like this
dependencies {
compile fileTree(dir: 'libs', include: ['*.jar'])
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.android.support:support-v4:21.0.3'
}
Hope it will solve your problems. Happy coding :D
In addition: In the latest gradle version that is gradle-1.0.0 runProguard is a deprecated method. So instead of using it you must use minifyEnabled and update your gradle version to 1.0.0.