With the following gradle script, I was wondering how to change the minSdkVersion from 7 to 3 (just so my app could run on more devices) without getting the error at the bottom of this post:
apply plugin: 'com.android.application'
android {
compileSdkVersion 23
buildToolsVersion "23.0.1"
defaultConfig {
applicationId "dpark.cellular_automata"
minSdkVersion 3
targetSdkVersion 23
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.0.1'
compile 'com.android.support:design:23.0.1'
}
... And then I would get the following error:
Error:Execution failed for task ':app:processDebugManifest'.
Manifest merger failed : uses-sdk:minSdkVersion 3 cannot be smaller than version 7 declared in library [com.android.support:appcompat-v7:23.0.1] C:\Users\Dave\AndroidStudioProjects\Cellular_Automata\app\build\intermediates\exploded-aar\com.android.support\appcompat-v7\23.0.1\AndroidManifest.xml
Suggestion: use tools:overrideLibrary="android.support.v7.appcompat" to force usage
... That said, is it even possible to lower my minimum SDK to 3 (version 1.5, Cupcake) if I wanted to publish my app with Google Play? And also, in case you're wondering, I also downloaded the Android Support Library in the SDK manager as follows, and yet it still doesn't work:
Thanks!
That error is telling you that one of your libraries (in this case, AppCompat) only supports back to SDK version 7. Since that library cannot support anything lower than 7 and you use that library, you can't support anything lower than 7.
Your options are either:
Remove AppCompat
Support a minimum of API level 7. Note that SDK version 8 currently has less than 0.1% of the market share globally, and all versions less than 8 have a combined total of 1%. It probably isn't worth your time.
That said, is it even possible to lower my minimum SDK to 3 (version 1.5, Cupcake) if I wanted to publish my app with Google Play?
Absolutely. You could upload an Android app supporting API level 1 if you really wanted to.
And also, in case you're wondering, I also downloaded the Android Support Library in the SDK manager as follows, and yet it still doesn't work:
The support library v4 only supports back to API level 4, so I'm not sure how that would help with supporting API level 3.
Related
This is a Gradle error which I get when running the empty "hello world" (building from Empty Activity template) without any added code,
Here is the error:
FAILURE: Build failed with an exception.
* What went wrong:
Execution failed for task ':app:checkDebugAarMetadata'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.CheckAarMetadataWorkAction
> 6 issues were found when checking AAR metadata:
1. Dependency 'androidx.appcompat:appcompat-resources:1.6.0' requires libraries and applications that
depend on it to compile against version 33 or later of the
Android APIs.
:app is currently compiled against android-32.
Also, the maximum recommended compile SDK version for Android Gradle
plugin 7.2.0 is 32.
Recommended action: Update this project's version of the Android Gradle
plugin to one that supports 33, then update this project to use
compileSdkVerion of at least 33.
Note that updating a library or application's compileSdkVersion (which
allows newer APIs to be used) can be done separately from updating
targetSdkVersion (which opts the app in to new runtime behavior) and
minSdkVersion (which determines which devices the app can be installed
on).
2. Dependency 'androidx.appcompat:appcompat:1.6.0' requires libraries and applications that
depend on it to compile against version 33 or later of the
Android APIs.
:app is currently compiled against android-32.
Also, the maximum recommended compile SDK version for Android Gradle
plugin 7.2.0 is 32.
Recommended action: Update this project's version of the Android Gradle
plugin to one that supports 33, then update this project to use
compileSdkVerion of at least 33.
Note that updating a library or application's compileSdkVersion (which
allows newer APIs to be used) can be done separately from updating
targetSdkVersion (which opts the app in to new runtime behavior) and
minSdkVersion (which determines which devices the app can be installed
on).
I will stop the error messages after these two as I suspect fixing one will fix all six.
Below is my build.gradle (:app)
plugins {
id 'com.android.application'
}
android {
compileSdk 32
defaultConfig {
applicationId "com.enetapplications.empty"
minSdk 28
targetSdk 32
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
}
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.0'
implementation 'com.google.android.material:material:1.7.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
This error first occurred while building an app and I was only working with the xml and was ready to begin the java - then for testing I opened a blank "empty" project and received this exact same error thus seems something to do with how Android Studio is being configured.
Update your version to 33 as below
compileSdk 33
defaultConfig {
applicationId "com.enetapplications.empty"
minSdk 28
targetSdk 33
versionCode 1
versionName "1.0"
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
}
Go to your build.gradle(:app), increase your compileSdk and targetSdk.
Write there:
compileSdk 33
targetSdk 33
Then at the top you will see 'Sync Now' Option, click on it. Now your problem has been resolved.
I want to increase the target api level of my app without affecting other libraries that the app depends on, such as firebase and alike. I tried changing it in project structure under app module but this did not work out. Nothing changed in gradle file
My next option is to increase it by editing the gradle file itself and increasing to api level 28. I am however scared of the effects this may have on the other libraries.
Below is my build gradle file, please assist me.
android {
compileSdkVersion 26
defaultConfig {
applicationId "com.chomba.haroldking.kuta"
minSdkVersion 16
targetSdkVersion 26
versionCode 1
versionName "1.0"
testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
targetCompatibility 1.8
sourceCompatibility 1.8
}
}
dependencies {
implementation fileTree(dir: 'libs', include: ['*.jar'])
implementation 'com.android.support:appcompat-v7:26.1.0'
implementation 'com.android.support.constraint:constraint-layout:1.1.3'
implementation 'com.android.support:design:26.1.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.android.volley:volley:1.1.0'
implementation 'com.jakewharton.threetenabp:threetenabp:1.2.1'
implementation 'com.android.support:recyclerview-v7:26.1.0'
implementation 'com.android.support:cardview-v7:26.1.0'
implementation 'com.firebaseui:firebase-ui-database:3.1.0'
implementation 'com.android.support:palette-v7:26.1.0'
implementation 'com.wdullaer:materialdatetimepicker:3.1.3'
implementation 'com.google.firebase:firebase-auth:16.0.1'
implementation 'com.google.firebase:firebase-database:16.0.1'
implementation 'com.google.firebase:firebase-core:16.0.0'
implementation 'com.android.support:support-annotations:28.0.0'
implementation 'com.google.firebase:firebase-storage:16.0.1'
}
apply plugin: 'com.google.gms.google-services'
Do I need to make changes to the other libraries
To upgrade your targetSdkVersion you should update it in build.gradle together with the compileSdkVersion (you will get an error if you don't update it as well).
android {
compileSdkVersion 28
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
}
}
Once you update the targetSdkVersion and the compileSdkVersion you'll also need to update the support library versions to 28.0.0, because the support library's major version needs to match the targetSdkVersion. For example:
implementation 'com.android.support:appcompat-v7:28.0.0' // instead of 26.1.0
Version 28.0.0 is the final version of the support library. To keep using the support libraries after you upgrade to API 29 you should migrate to AndroidX.
When updating you should also check if there have been relevant changes in Android 9 that you need to consider.
In your case you cannot update the targetSdkVersion without also updating the dependencies.
I tried changing it in project structure under app module but this did not work out. Nothing changed in gradle file My next option is to increase it by editing the gradle file itself and increasing to api level 28.
Changing it in project structure wouldn't do any magic for you, you still have to follow the same process as you would by changing the gradle file.
I am however scared of the effects this may have on the other libraries
Keep the 3rd party libraries up to date as well, using newer versions of libraries in older sdks will most likely cause issues as newer Android SDKs have behavior changes.
Here are some personal tips for migrating without being overwhelmed by the things it might break:
1. Increment your target api by 1 each time and then fully test it
For example, upgrade to api 27 from 26, test it and then upgrade it to 28 and so on. The reason for this is to narrow down and account for behavior changes in each api since the previous target api. Not only will it be less overwhelming, it would be easier to find solutions for the problems that might occur afterwards. If you migrate to 29 from 26 directly, it would be very difficult to identify the issue.
2. Read Migration Guides for each Android SDK
These pages were really helpful in identifying deprecated classes/features being used even by third party libraries:
Android 8.0 Migration Guide
Android 9.0 Migration Guide
3. If there is a problem in third party library after upgrading, it is most likely in Github Issues page. If it isn't there, create a new issue (following the guidelines listed there). There is no better place to get library specific answers than the repository site where the developers themselves can give you good suggestions.
4. Read the changelog starting from the previous version of libraries that have issues.
Some libraries have outdated documentation and newer versions can cause issues. For example, when I was migrating Dagger, there were some classes that were deprecated on newer versions but weren't documented and I only found out after reading the changelog.
The Android Studio 3.1 layout preview fails to find style 'coordinatorLayoutStyle' in the current theme.
Failed to instantiated one or more classes.
Exception shown are :-
java.lang.ClassNotFoundException: android.view.View$OnUnhandledKeyEventListener
This happened due to use of alpha version SDK 28
We need to change the android { ... } in "build.gradle" in app file
compileSdkVersion 28 to compileSdkVersion 27
targetSdkVersion 28 to targetSdkVersion 27
Also, try to change implementations like
implementation 'com.android.support:appcompat-v7:28.0.0-alpha3' to
implementation 'com.android.support:appcompat-v7:27.1.1'
Hope this works!
For Android Studio v3.1.*, in addition we need change:
implementation 'com.android.support:design:28.0.0-alpha3' to
implementation 'com.android.support:design:27.1.1'
you can fix this issue by adding this script to the app module build.gradle, in the android section
configurations.all {
resolutionStrategy.eachDependency { DependencyResolveDetails details ->
def requested = details.requested
if (requested.group == "com.android.support") {
if (!requested.name.startsWith("multidex")) {
details.useVersion "27.+"
}
}
}
}
This appears to be a bug in the current version of Android Studio (3.1.3) as I was encountering the same thing. I downloaded the beta build from here and opened my existing project and the errors disappeared.
https://developer.android.com/studio/preview/?utm_source=android-studio
Not exactly a fix but hopefully it will get you back up and running.
Update
1. com.android.support:appcompat stable version 28.0.0 is released. So no need to downgrade version. Just use 28.0.0.
def supportVersion = "28.0.0"
implementation "com.android.support:appcompat-v7:$supportVersion"
implementation "com.android.support:design:$supportVersion"
You can ignore design library if you don't need it.
2: You also need to update your compileSdkVersion & targetSdkVersion to remove some gradle warnings.
compileSdkVersion 28
targetSdkVersion 28
Never use alpha versions of any library, because alpha, beta and rc
versions may have bugs. And you don't want to face these types of errors often.
Important Suggestion
I suggest you migrate to androidx because android will not update support library after 28.0.0, all updates will be available to androidx package only. Check related answer.
This is fixed in Android Studio 3.2.
Go to app/res/styles and change the Theme.AppCompat.Light.DarkActionBar for this one Base.Theme.AppCompat.Light.DarkActionBar
This issue has been incredibly frustrating for me for the past two weeks.
Using the Android SDK Manager, I updated the following:
Tools:
Android SDK Tools rev. 24.3.3
Android SDK Platform-tools rev. 22
Android SDK Build-tools rev. 22.0.1
Android 5.1.1 (API 22):
SDK Platform rev. 2
Google APIs rev. 1
Sources for Android SDK rev. 1
Extras:
Android Support Repository rev. 16
Android Support Library rev. 22.2.1
Google Repository rev.22
This is the exact list of all the repositories that I've installed and updated to with the Android SDK Manager.
However, when I attempt to add the line:
compile 'com.android.support:design:22.2.0'
Gradle becomes stuck on addDependecies. Furthermore, when I go to Module Settings, and then to Dependencies, when I try to add a new library, the 'com.android.support:design:22.2.0' does not appear within the list!
Here's additional information about my target, compile, and minimum SDK version:
android {
compileSdkVersion 22
buildToolsVersion '22.0.1'
defaultConfig {
applicationId "com.myandroidapplication.newtestapp"
minSdkVersion 14
targetSdkVersion 22
versionCode 1
versionName "1.0"
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
productFlavors {
}
}
What could I possibly be missing at this point? Thank you!
You have to use version 22.2.1 as it has installed on your computer.
compile 'com.android.support:design:22.2.1'
For me, I was initially adding the support library dependency by typing it out in the build.gradle of my app directly.
I cleaned the line that I had typed and added the dependency through the android studio GUI,
Go to File
Choose Project Structure
Click on the Dependencies tab
Click on the + symbol in the upper right conner and choose Library Dependency.
Search for and add the support library in the dialog that appears
Gradle build/sync should start automatically.
Don't know why, but it works for me at least.
I just moved to new Ubuntu and, thus, installed the last java version which is 8 (or 1.8). I also installed Android Studio 0.5.7. However, Dalvik doesn't support Java 8, does it? I want to keep the current java 8 installed because I'm going to use it in Java projects but I also have to install Java 7 to be able to use it in Android. What's the right way to do this?
UPDATE:
The errors:
Error:A problem occurred configuring project ':app'.
> Could not resolve all dependencies for configuration ':app:_debugCompile'.
> Could not find any version that matches com.android.support:appcompat-v7:+.
Required by:
MyApplication:app:unspecified
#app/build.grandle
apply plugin: 'android'
android {
compileSdkVersion 19
buildToolsVersion "19.0.3"
defaultConfig {
minSdkVersion 8
targetSdkVersion 19
versionCode 1
versionName "1.0"
}
buildTypes {
release {
runProguard false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.txt'
}
}
}
dependencies {
compile 'com.android.support:appcompat-v7:+'
compile fileTree(dir: 'libs', include: ['*.jar'])
}
error
Could not find any version that matches com.android.support:appcompat-v7:+.
is answered in Android Studio could not find any version that matches com.android.support:appcompat-v7:+
i.e in SDK Manager install/update Extras / Android Support Repository to use this dependency.