I have built an Android App using Android Studio and I've been doing testing with a tablet running Android version 5.1.1 (API 22). Once the development was finished I tried using the APK to install the same app to an S7 running Android 8.0.0 (API 26). The app crashed while running on the S7, but runs flawlessly on the tablet. The target SDK version for the app I built is API 29 and the minimum SDK version is API 22.
I can change the compile SDK version from 29 to 28 and I don't get any build errors. However, changing it to 27 gives me the following errors:
Execution failed for task ':app:processDebugResources'.
> Android resource linking failed
C:\Users\xxxxx\.gradle\caches\transforms-2\files-2.1\9073307f5eb1fdd8dc5b08ac4a3a252e\res\values-v28\values-v28.xml:9:5-12:13: AAPT: error: resource android:attr/dialogCornerRadius not found.
C:\Users\xxxxx\Desktop\appDev\app_green\myApp\app\build\intermediates\incremental\mergeDebugResources\merged.dir\values-v28\values-v28.xml:11: AAPT: error: resource android:attr/dialogCornerRadius not found.
C:\Users\xxxxx\.gradle\caches\transforms-2\files-2.1\11ac981ad78c9fd8730f98006e1b2a23\res\values\values.xml:89:5-125:25: AAPT: error: resource android:attr/fontVariationSettings not found.
C:\Users\xxxxx\.gradle\caches\transforms-2\files-2.1\11ac981ad78c9fd8730f98006e1b2a23\res\values\values.xml:89:5-125:25: AAPT: error: resource android:attr/ttcIndex not found.
error: failed linking references.
I figured if I decreased the API level one by one and fixed any errors that popped up, I'd eventually end up with an app that would work on all the desired APIs. Is this a correct assumption?
How do I go about fixing errors like this one that fail to link Gradle resources? This one seems to be an error with a dialog box that I used to get user input.
All solutions to these errors that I find are "change API version," but what if I need this API version?
Edit: At the request of those attempting to help me solve this issue I am posting the crash log from the S7.
Process: com.myApp, PID: 15167
android.os.FileUriExposedException: file:///storage/emulated/0/Android/data/myApp/files/export_a_c.csv exposed beyond app through ClipData.Item.getUri()
at android.os.StrictMode.onFileUriExposed(StrictMode.java:1958)
at android.net.Uri.checkFileUriExposed(Uri.java:2356)
at android.content.ClipData.prepareToLeaveProcess(ClipData.java:944)
at android.content.Intent.prepareToLeaveProcess(Intent.java:10480)
at android.content.Intent.prepareToLeaveProcess(Intent.java:10486)
at android.content.Intent.prepareToLeaveProcess(Intent.java:10465)
at android.app.Instrumentation.execStartActivity(Instrumentation.java:1616)
at android.app.Activity.startActivityForResult(Activity.java:4564)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:767)
at android.app.Activity.startActivityForResult(Activity.java:4522)
at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:754)
at com.example.myApp.SecondActivity$onCreate$3$3.onClick(SecondActivity.kt:218)
at android.view.View.performClick(View.java:6897)
at android.widget.TextView.performClick(TextView.java:12693)
at android.view.View$PerformClick.run(View.java:26101)
at android.os.Handler.handleCallback(Handler.java:789)
at android.os.Handler.dispatchMessage(Handler.java:98)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6944)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
The error occurs when I try to create/write to a csv file. The intent is to create this file automatically and then prompt the user to share it via email.
Edit 2: So I've fixed the crash issue while running on the S7. How do I ensure that the app will run for each API? Must I downgrade my S7's software to the APIs I want to test?