Android Studio Upgrade Broke the Build - java

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'
}

Related

API Level 21 app searching for API Level 23 resource after installing google play services

Im developing an app that requires google maps, I follow the google tutorials by adding a activity map in android studio but right after the activity got created, downloaded the google play services dependency packge and the build finish, i got this error:
Error:(3) Error retrieving parent for item: No resource found that matches the given name 'android:TextAppearance.Material.Widget.Button.Inverse'.
Error:(18) Error retrieving parent for item: No resource found that matches the given name 'android:Widget.Material.Button.Colored'.
I opened the resource and I noticed that is requesting v23\values-v23.xml resource and I am not using api level 23 in my app. This is my graddle config:
android {
compileSdkVersion 21
buildToolsVersion "21.1.2"
defaultConfig {
applicationId "?"
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'])
testCompile 'junit:junit:4.12'
testCompile "org.mockito:mockito-core:2.0.5-beta"
compile 'com.android.support:appcompat-v7:21.0.3'
compile 'com.squareup.retrofit2:retrofit:2.1.0'
compile 'com.squareup.retrofit2:converter-gson:2.0.2'
compile 'com.facebook.android:facebook-android-sdk:4.8.0'
compile 'com.google.android.gms:play-services:9.0.2'
}
Why is now my proyect asking for this resource? Does google play services has something to do with this? How can i fixed?

Android Studio: Failed to resolve: com.google.android.gms:play-services:fp9.0.0

When I try to compile I get this error
"Failed to resolve: com.google.android.gms:play-services:fp9.0.0" in Android Studio. I am trying to include the play services in my project. This is my build.gradle file:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "Application name"
minSdkVersion 21
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.3.0'
compile 'com.google.android.gms:play-services:fp9.0.0'
}
The only thing I have changed in this file is this line:
compile 'com.google.android.gms:play-services:fp9.0.0'
I have installed Google Play Services and it's version number is 30.
I had the same issue yesterday. In the messages section when running a gradle sync or build, I got a message with an option to update something from the M2 repo. Clicking the link downloaded the latest version and fixed the issue.
You could also try compile 'com.google.android.gms:play-services:9.0.0'
If you are only using maps, consider only downloading maps using compile 'com.google.android.gms:play-services-maps:9.0.0' as it can save you hitting the 65K method dex limit later in development.
Try to add and change this in your Project Level Gradle.
Update classpath com.google.gms:google-services:2.1.0 to classpath com.google.gms:google-services:3.0.0
And
Also try to change compile Dependencies as below.
compile 'com.google.android.gms:play-services:9.0.0'
Or for map you can only use this.
compile 'com.google.android.gms:play-services-maps:9.0.0'

Could not find class 'android.os.PersistableBundle'

My IDE is Android Studio 2.0. SDK is 23
This is my error log(there are so many same logs and I list only one):
05-10 22:19:21.430 1835-1835/edu.jazzy.testconsumer E/dalvikvm: Could not find class 'android.os.PersistableBundle', referenced from method edu.jazzy.testconsumer.MipcaActivityCapture.access$super
my build.gradle :
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.3"
defaultConfig {
applicationId "edu.jazzy.testconsumer"
minSdkVersion 15
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.3.0'
compile files('libs/zxing.jar')
}
And I don't know why there is always occur error after I google for hours.
You get this sort of message whenever there is code in your app that refers to classes/methods/fields that do not exist on the device. So long as you do not actually execute any lines that refer to those missing items, there is no problem.
Note that the question linked to from the comments is for a case where there is an actual crash, in that case due to some unfortunate reflection from Otto. Your error message from your question is not a crash.

can not resolve the symbol AppcomapatActivity

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.

android studio build suddenly throws a lot of errors

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.

Categories