由于 Play Console 规则,我将 TargetSdkVersion 28 更改为 30 并迁移 Androidx 并更改所有依赖项 迁移应用程序打开但某些任务不起作用并且应用程序崩溃后 我使用的是 Android Studio 4.1.3 版和 Gradle 6.5 版
错误如下。
2021-04-22 15:46:10.283 1112-1112/? E/w.fileconverte: Unknown bits set in runtime_flags: 0x8000
2021-04-22 15:46:16.917 1112-1355/? E/AndroidRuntime: FATAL EXCEPTION: ModernAsyncTask #1
Process: sparrow.fileconverter, PID: 1112
java.lang.RuntimeException: An error occurred while executing doInBackground()
at androidx.loader.content.ModernAsyncTask$3.done(ModernAsyncTask.java:164)
at java.util.concurrent.FutureTask.finishCompletion(FutureTask.java:383)
at java.util.concurrent.FutureTask.setException(FutureTask.java:252)
at java.util.concurrent.FutureTask.run(FutureTask.java:271)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
Caused by: java.lang.IllegalArgumentException: Invalid column COUNT(*) AS count
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:170)
at android.database.DatabaseUtils.readExceptionFromParcel(DatabaseUtils.java:140)
at android.content.ContentProviderProxy.query(ContentProviderNative.java:423)
at android.content.ContentResolver.query(ContentResolver.java:1002)
at android.content.ContentResolver.query(ContentResolver.java:926)
at androidx.core.content.ContentResolverCompat.query(ContentResolverCompat.java:81)
at androidx.loader.content.CursorLoader.loadInBackground(CursorLoader.java:63)
at com.zhihu.matisse.internal.loader.AlbumLoader.loadInBackground(AlbumLoader.java:97)
at com.zhihu.matisse.internal.loader.AlbumLoader.loadInBackground(AlbumLoader.java:33)
at androidx.loader.content.AsyncTaskLoader.onLoadInBackground(AsyncTaskLoader.java:307)
at androidx.loader.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:60)
at androidx.loader.content.AsyncTaskLoader$LoadTask.doInBackground(AsyncTaskLoader.java:48)
at androidx.loader.content.ModernAsyncTask$2.call(ModernAsyncTask.java:141)
at java.util.concurrent.FutureTask.run(FutureTask.java:266)
at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1167)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:641)
at java.lang.Thread.run(Thread.java:919)
构建 Gradle
apply plugin: 'com.android.application'
android {
compileSdkVersion 30
buildToolsVersion '30.0.3'
defaultConfig {
applicationId "sparrow.fileconverter"
vectorDrawables.useSupportLibrary = true
minSdkVersion 21
multiDexEnabled true
targetSdkVersion 30
versionCode 1
versionName "1.0"
testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
}
buildTypes {
release {
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
debug {
debuggable true
minifyEnabled false
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
}
}
compileOptions {
sourceCompatibility JavaVersion.VERSION_1_8
targetCompatibility JavaVersion.VERSION_1_8
}
dexOptions {
javaMaxHeapSize "4g"
}
packagingOptions {
exclude 'META-INF/DEPENDENCIES'
exclude 'META-INF/NOTICE'
exclude 'META-INF/LICENSE'
exclude 'META-INF/NOTICE.txt'
exclude 'META-INF/LICENSE.txt'
}
lintOptions {
checkReleaseBuilds false
}
testOptions {
unitTests {
includeAndroidResources = true
returnDefaultValues = true
}
}
}
configurations {
all {
exclude module: 'httpclient'
}
}
repositories {
mavenCentral()
maven { url 'https://jitpack.io' }
maven { url "https://repository.aspose.com/repo/" }
}
dependencies {
def room_version = "1.1.1"
implementation fileTree(include: ['*.jar'], dir: 'libs')
implementation 'junit:junit:4.12'
implementation 'androidx.vectordrawable:vectordrawable-animated:1.0.0'
implementation 'androidx.exifinterface:exifinterface:1.0.0'
implementation 'androidx.appcompat:appcompat:1.0.0'
implementation 'androidx.multidex:multidex:2.0.0'
implementation 'androidx.legacy:legacy-support-v13:1.0.0'
implementation 'com.google.android.material:material:1.0.0'
implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
implementation 'androidx.cardview:cardview:1.0.0'
implementation 'androidx.recyclerview:recyclerview:1.0.0'
implementation 'androidx.legacy:legacy-support-v4:1.0.0'
implementation 'androidx.preference:preference:1.0.0'
// butterknife
implementation 'com.jakewharton:butterknife:10.0.0'
annotationProcessor 'com.jakewharton:butterknife-compiler:10.0.0'
// persistence room library - for db operations
implementation 'androidx.room:room-runtime:2.0.0'
annotationProcessor 'androidx.room:room-compiler:2.0.0'
// material ripple, morphing button, material dialog, animations
implementation 'com.balysv:material-ripple:1.0.2'
implementation 'com.github.dmytrodanylyk:android-morphing-button:98a4986e56'
implementation 'com.afollestad.material-dialogs:core:0.9.6.0'
implementation 'com.airbnb.android:lottie:2.5.5'
// libraries for reading from doc and docx files
implementation group: 'org.apache.xmlbeans', name: 'xmlbeans', version: '2.4.0'
implementation group: 'org.apache.poi', name: 'poi', version: '3.9'
implementation group: 'org.apache.poi', name: 'poi-ooxml', version: '3.9'
implementation group: 'org.apache.poi', name: 'poi-ooxml-schemas', version: '3.9'
implementation group: 'org.apache.poi', name: 'poi-scratchpad', version: '3.9'
// Itext pdf library
implementation 'com.itextpdf:itextg:5.5.10'
implementation 'com.madgag.spongycastle:core:1.58.0.0'
// Picasso, image editor, image cropper
implementation 'com.squareup.picasso:picasso:2.5.2'
implementation 'jp.wasabeef:picasso-transformations:2.2.1'
implementation 'ja.burhanrashid52:photoeditor:0.2.1'
implementation 'com.theartofdev.edmodo:android-image-cropper:2.7.0'
// Viewpager transformation
implementation 'com.eftimoff:android-viewpager-transformers:1.0.1@aar'
// Image picker, and folder picker
implementation 'com.zhihu.android:matisse:0.5.2-beta4'
implementation 'lib.kashif:folderpicker:2.4'
// Zxing - for scanning qr code
implementation 'com.google.zxing:core:3.2.1'
implementation 'com.journeyapps:zxing-android-embedded:3.4.0'
// color picker
implementation 'com.github.danielnilsson9:color-picker-view:1.4.0@aar'
implementation 'com.github.mahimrocky:TextRecognizer:1.0.0'
testImplementation 'org.mockito:mockito-core:2.23.4'
testImplementation 'org.robolectric:robolectric:4.3.1'
androidTestImplementation('androidx.test.espresso:espresso-core:3.1.0', {
exclude group: 'com.android.support', module: 'support-annotations'
})
}
assemble.dependsOn('lint')
Android 清单
<?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
package="sparrow.fileconverter">
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" />
<uses-feature android:name="android.hardware.camera" />
<uses-feature
android:name="android.hardware.camera.autofocus"
android:required="false" />
<uses-permission android:name="android.permission.CAMERA" />
<application
android:name="androidx.multidex.MultiDexApplication"
android:allowBackup="true"
android:fullBackupContent="@xml/backup_descriptor"
android:hardwareAccelerated="true"
android:icon="@mipmap/ic_icone"
android:label="@string/app_name"
android:largeHeap="true"
android:supportsRtl="true"
android:roundIcon="@mipmap/ic_icone"
android:theme="@style/AppThemeWhite"
android:clearTaskOnLaunch="true"
android:launchMode="singleTask"
tools:ignore="GoogleAppIndexingWarning,RtlEnabled">
<activity android:name="sparrow.fileconverter.activity.SplashActivity"
android:theme="@style/SplashTheme">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name="com.theartofdev.edmodo.cropper.CropImageActivity"
android:theme="@style/Base.Theme.AppCompat" />
<activity
android:name="sparrow.fileconverter.activity.MainActivity"
android:label="@string/app_name"
android:screenOrientation="portrait"
android:windowSoftInputMode="adjustPan">
<intent-filter>
<action android:name="android.intent.action.SEND_MULTIPLE" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.SEND" />
<category android:name="android.intent.category.DEFAULT" />
<data android:mimeType="image/*" />
</intent-filter>
<meta-data
android:name="android.app.shortcuts"
android:resource="@xml/shortcuts" />
</activity>
<activity android:name="sparrow.fileconverter.activity.CropImageActivity" />
<provider
android:name="androidx.core.content.FileProvider"
android:authorities="com.sparrow.shareFile"
android:exported="false"
android:grantUriPermissions="true">
<meta-data
android:name="android.support.FILE_PROVIDER_PATHS"
android:resource="@xml/provider_paths" />
</provider>
<activity android:name="sparrow.fileconverter.activity.ImageEditor" />
<activity android:name="sparrow.fileconverter.activity.PreviewActivity" />
<activity android:name="sparrow.fileconverter.activity.RearrangeImages" />
<activity android:name="sparrow.fileconverter.activity.ImagesPreviewActivity" />
<activity android:name="sparrow.fileconverter.activity.RearrangePdfPages" />
<activity android:name="sparrow.fileconverter.activity.FavouritesActivity" />
</application>
请解决我的问题!!!