question

scottnj avatar image
scottnj asked hardikadroja510 edited

Setup Android Studio for targetSdkVersion 25

Clover currently requires us to use targetSdkVersion of 25 or lower. It would be nice if things were updated so that we do not have this restriction. But we need to work with what we have.


How do we get Android Studio setup to get an app to compile with targetSdkVersion 25? To keep things simple I tried creating a new project. I used the "Empty Activity" template, and set the minimum SDK level to 17. Then I modified the app/build.gradle file as follows

....
android { 
//    compileSdkVersion 29
    compileSdkVersion 25
//    buildToolsVersion "29.0.2"
    buildToolsVersion "25.0.3"
    defaultConfig {
        applicationId "org.iroll.firebasetest4"
        minSdkVersion 17 
//        targetSdkVersion 29
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    .....
}
....


When I changed the targetSdkVersion to 25 I get a warning saying

Google Play requires that apps target API level 26 or higher.

Google Play is not on the Clover devices so I assume we can ignore this warning.


When I sync Gradle and build the project the build fails with a bunch of errors.


What else do we have to do to Android Studio to get a targetSdk 25 app that will compile so that it can be installed on Clover devices?

I Googled and searched the Clover forum but only found articles for upgrading version (something I do all the time on other apps), but almost nothing about downgrading versions. I figure that if I am running into a roadblock, there are probably other developers that will have the same issue.


Thanks,

Scott


EDIT:

Here is a full gradle file

apply plugin: 'com.android.application'

android {
    compileSdkVersion 25
    defaultConfig {
        applicationId "com.example.clovertest1"
        minSdkVersion 17
        targetSdkVersion 25
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(dir: 'libs', include: ['*.jar'])
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.13'
    androidTestImplementation 'androidx.test.ext:junit:1.1.1'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
}


Here are the build errors

Executing tasks: [clean, :app:assembleDebug] in project C:\Users\scott\AndroidStudioProjects\CloverTest1

> Task :clean UP-TO-DATE
> Task :app:clean
> Task :app:preBuild UP-TO-DATE
> Task :app:preDebugBuild UP-TO-DATE
> Task :app:checkDebugManifest
> Task :app:generateDebugBuildConfig
> Task :app:javaPreCompileDebug
> Task :app:compileDebugAidl NO-SOURCE
> Task :app:compileDebugRenderscript NO-SOURCE
> Task :app:mainApkListPersistenceDebug
> Task :app:generateDebugResValues
> Task :app:generateDebugResources
> Task :app:createDebugCompatibleScreenManifests
> Task :app:processDebugManifest
> Task :app:mergeDebugResources

> Task :app:processDebugResources FAILED
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\6119d746697059b7e1b74aab4d181f56\\appcompat-1.1.0\\res\\values-v26\\values-v26.xml","position":{"startLine":4,"startColumn":4,"startOffset":217,"endLine":7,"endColumn":12,"endOffset":426}}],"original":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\6119d746697059b7e1b74aab4d181f56\\appcompat-1.1.0\\res\\values-v26\\values-v26.xml:5:5-8:13: AAPT: error: resource android:attr/colorError not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\6119d746697059b7e1b74aab4d181f56\\appcompat-1.1.0\\res\\values-v26\\values-v26.xml","position":{"startLine":8,"startColumn":4,"startOffset":431,"endLine":11,"endColumn":12,"endOffset":652}}],"original":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\6119d746697059b7e1b74aab4d181f56\\appcompat-1.1.0\\res\\values-v26\\values-v26.xml:9:5-12:13: AAPT: error: resource android:attr/colorError not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\6119d746697059b7e1b74aab4d181f56\\appcompat-1.1.0\\res\\values-v26\\values-v26.xml","position":{"startLine":12,"startColumn":4,"startOffset":657,"endLine":15,"endColumn":12,"endOffset":891}}],"original":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\6119d746697059b7e1b74aab4d181f56\\appcompat-1.1.0\\res\\values-v26\\values-v26.xml:13:5-16:13: AAPT: error: style attribute 'android:attr/keyboardNavigationCluster' not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\6119d746697059b7e1b74aab4d181f56\\appcompat-1.1.0\\res\\values-v28\\values-v28.xml","position":{"startLine":4,"startColumn":4,"startOffset":217,"endLine":7,"endColumn":12,"endOffset":442}}],"original":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\6119d746697059b7e1b74aab4d181f56\\appcompat-1.1.0\\res\\values-v28\\values-v28.xml:5:5-8:13: AAPT: error: resource android:attr/dialogCornerRadius not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\6119d746697059b7e1b74aab4d181f56\\appcompat-1.1.0\\res\\values-v28\\values-v28.xml","position":{"startLine":8,"startColumn":4,"startOffset":447,"endLine":11,"endColumn":12,"endOffset":684}}],"original":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\6119d746697059b7e1b74aab4d181f56\\appcompat-1.1.0\\res\\values-v28\\values-v28.xml:9:5-12:13: AAPT: error: resource android:attr/dialogCornerRadius not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\e9dab9c67c1ee3668e0bbf86c6d8cbd8\\core-1.1.0\\res\\values\\values.xml","position":{"startLine":141,"startColumn":4,"startOffset":8780,"endLine":172,"endColumn":24,"endOffset":10840}}],"original":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\e9dab9c67c1ee3668e0bbf86c6d8cbd8\\core-1.1.0\\res\\values\\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontStyle not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\e9dab9c67c1ee3668e0bbf86c6d8cbd8\\core-1.1.0\\res\\values\\values.xml","position":{"startLine":141,"startColumn":4,"startOffset":8780,"endLine":172,"endColumn":24,"endOffset":10840}}],"original":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\e9dab9c67c1ee3668e0bbf86c6d8cbd8\\core-1.1.0\\res\\values\\values.xml:142:5-173:25: AAPT: error: resource android:attr/font not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\e9dab9c67c1ee3668e0bbf86c6d8cbd8\\core-1.1.0\\res\\values\\values.xml","position":{"startLine":141,"startColumn":4,"startOffset":8780,"endLine":172,"endColumn":24,"endOffset":10840}}],"original":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\e9dab9c67c1ee3668e0bbf86c6d8cbd8\\core-1.1.0\\res\\values\\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontWeight not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\e9dab9c67c1ee3668e0bbf86c6d8cbd8\\core-1.1.0\\res\\values\\values.xml","position":{"startLine":141,"startColumn":4,"startOffset":8780,"endLine":172,"endColumn":24,"endOffset":10840}}],"original":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\e9dab9c67c1ee3668e0bbf86c6d8cbd8\\core-1.1.0\\res\\values\\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\e9dab9c67c1ee3668e0bbf86c6d8cbd8\\core-1.1.0\\res\\values\\values.xml","position":{"startLine":141,"startColumn":4,"startOffset":8780,"endLine":172,"endColumn":24,"endOffset":10840}}],"original":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\e9dab9c67c1ee3668e0bbf86c6d8cbd8\\core-1.1.0\\res\\values\\values.xml:142:5-173:25: AAPT: error: resource android:attr/ttcIndex not found.\n    ","tool":"AAPT"}
AGPBI: {"kind":"error","text":"Android resource linking failed","sources":[{"file":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\6119d746697059b7e1b74aab4d181f56\\appcompat-1.1.0\\res\\values\\values.xml","position":{"startLine":2771,"startColumn":4,"startOffset":173278,"endLine":2794,"endColumn":24,"endOffset":174475}}],"original":"C:\\Users\\scott\\.gradle\\caches\\transforms-2\\files-2.1\\6119d746697059b7e1b74aab4d181f56\\appcompat-1.1.0\\res\\values\\values.xml:2772:5-2795:25: AAPT: error: resource android:attr/textFontWeight not found.\n    ","tool":"AAPT"}

FAILURE: Build failed with an exception.

* What went wrong:
Execution failed for task ':app:processDebugResources'.
> A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade
   > Android resource linking failed
     C:\Users\scott\.gradle\caches\transforms-2\files-2.1\6119d746697059b7e1b74aab4d181f56\appcompat-1.1.0\res\values-v26\values-v26.xml:5:5-8:13: AAPT: error: resource android:attr/colorError not found.
         
     C:\Users\scott\.gradle\caches\transforms-2\files-2.1\6119d746697059b7e1b74aab4d181f56\appcompat-1.1.0\res\values-v26\values-v26.xml:9:5-12:13: AAPT: error: resource android:attr/colorError not found.
         
     C:\Users\scott\.gradle\caches\transforms-2\files-2.1\6119d746697059b7e1b74aab4d181f56\appcompat-1.1.0\res\values-v26\values-v26.xml:13:5-16:13: AAPT: error: style attribute 'android:attr/keyboardNavigationCluster' not found.
         
     C:\Users\scott\.gradle\caches\transforms-2\files-2.1\6119d746697059b7e1b74aab4d181f56\appcompat-1.1.0\res\values-v28\values-v28.xml:5:5-8:13: AAPT: error: resource android:attr/dialogCornerRadius not found.
         
     C:\Users\scott\.gradle\caches\transforms-2\files-2.1\6119d746697059b7e1b74aab4d181f56\appcompat-1.1.0\res\values-v28\values-v28.xml:9:5-12:13: AAPT: error: resource android:attr/dialogCornerRadius not found.
         
     C:\Users\scott\.gradle\caches\transforms-2\files-2.1\e9dab9c67c1ee3668e0bbf86c6d8cbd8\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontStyle not found.
         
     C:\Users\scott\.gradle\caches\transforms-2\files-2.1\e9dab9c67c1ee3668e0bbf86c6d8cbd8\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/font not found.
         
     C:\Users\scott\.gradle\caches\transforms-2\files-2.1\e9dab9c67c1ee3668e0bbf86c6d8cbd8\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontWeight not found.
         
     C:\Users\scott\.gradle\caches\transforms-2\files-2.1\e9dab9c67c1ee3668e0bbf86c6d8cbd8\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/fontVariationSettings not found.
         
     C:\Users\scott\.gradle\caches\transforms-2\files-2.1\e9dab9c67c1ee3668e0bbf86c6d8cbd8\core-1.1.0\res\values\values.xml:142:5-173:25: AAPT: error: resource android:attr/ttcIndex not found.
         
     C:\Users\scott\.gradle\caches\transforms-2\files-2.1\6119d746697059b7e1b74aab4d181f56\appcompat-1.1.0\res\values\values.xml:2772:5-2795:25: AAPT: error: resource android:attr/textFontWeight not found.
         

* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

* Get more help at https://help.gradle.org

BUILD FAILED in 2s
11 actionable tasks: 10 executed, 1 up-to-date


Clover Android SDK
2 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Jacob Abrams avatar image Jacob Abrams ♦♦ commented ·
Yes you can ignore the warning about Google Play requirements. We must see specific android studio logs and error messages to diagnose why Gradle sync fails. I also suggest you attempt to make a build from the command line and send those logs as well.
0 Likes 0 ·
scottnj avatar image scottnj Jacob Abrams ♦♦ commented ·

Thanks Jacob. I updated my post with the error messages.

The errors all seem to be "Android resource linking failed" and point to the core and appcompat xml files

0 Likes 0 ·
Jacob Abrams avatar image
Jacob Abrams answered Jacob Abrams commented

I suggest switching to compileSdkVersion 29, but keep the target API level at 25. You should always compile with the latest available SDK version which is currently 29, the compile SDK version has no effect on runtime behavior but will affect your ability to build apps properly. The latest androidx libraries likely require compiling with sdk 29.

Also there is no need to specify build tools at all, especially do not choose the quite old version 25.0.3. You can use the latest build tools but still target API 25. Per Google the android gradle plugin will autoselect the best build tools for you. Google says:

https://developer.android.com/studio/releases/gradle-plugin

"Keep in mind, you no longer need to specify a version for the build tools using the android.buildToolsVersion property—the plugin uses the minimum required version by default."

6 comments
10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

scottnj avatar image scottnj commented ·

That worked! Thanks

0 Likes 0 ·
Jacob Abrams avatar image Jacob Abrams ♦♦ scottnj commented ·

For anyone reading this later, you might want to consider using API level 22 instead due to this: https://community.clover.com/questions/20910/cloveraccountgetaccountthis-returning-null.html

0 Likes 0 ·
hardikadroja510 avatar image hardikadroja510 scottnj commented ·

Hi Scott,

I created new project into android studio and followed same instruction like as document. But i faced same issue with targetSdkVersion: 25


I set same as Jacob advise and my project build successfully but i can not create apk file and i faced error like as below.


Generate Signed APK: Errors while building APK. You can find the errors in the 'Messages' view.


Lint found fatal errors while assembling a release target.


To proceed, either fix the issues identified by lint, or modify your build script as follows:

...

android {

lintOptions {

checkReleaseBuilds false

// Or, if you prefer, you can continue to check for errors in release builds,

// but continue the build even when errors are found:

abortOnError false

}

}

...


0 Likes 0 ·
hardikadroja510 avatar image hardikadroja510 commented ·

Can we use old android studio for the android app ?


0 Likes 0 ·
Jacob Abrams avatar image Jacob Abrams ♦♦ hardikadroja510 commented ·

I believe you should be able to use old Android Studio versions yes.

0 Likes 0 ·
Jacob Abrams avatar image Jacob Abrams ♦♦ hardikadroja510 commented ·

I believe you need to use at least version 3.0.0 of the android gradle plugin because the clover-android-sdk uses some Java 8 features. This probably means you need to use Android Studio 3.0 at least, the dependency between the android gradle plugin and Android Studio is loose and not always well defined. Your mileage may vary of course and some old versions of android studio may have bugs. For more information on the android gradle plugin see https://developer.android.com/studio/releases/gradle-plugin.html

0 Likes 0 ·
hardikadroja510 avatar image
hardikadroja510 answered hardikadroja510 edited

Hi Jacob,

Thanks for your reply.


I got success with latest version.

I think this below line should work

noinspection ExpiredTargetSdkVersion
compileSdkVersion 29
buildToolsVersion "29.0.2"
defaultConfig {
    applicationId "com.example.aaaaa"
    minSdkVersion 17
    //noinspection ExpiredTargetSdkVersion
    targetSdkVersion 25
    versionCode 3
    versionName "3.0"
    testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"


I created apk with this below version and i installed app into android emulator.


Thanks for your quick reply

10 |2000

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Welcome to the
Clover Developer Community