Warning: file_get_contents(/data/phpspider/zhask/data//catemap/3/android/229.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 迁移到AndroidX后编译到Android 4时出现问题_Java_Android_Gradle_Androidx - Fatal编程技术网

Java 迁移到AndroidX后编译到Android 4时出现问题

Java 迁移到AndroidX后编译到Android 4时出现问题,java,android,gradle,androidx,Java,Android,Gradle,Androidx,我有一个Android(Java)项目,在迁移到AndroidX后,我收到了以下错误(d8错误): 请注意,渐变同步通常发生。此错误仅在设备编译时出现。最奇怪的是,只有在我为安卓4设备编译时才会发生这种情况。 尝试为Android 5+编译时,编译成功,应用程序运行平稳 build.gradle [...] compileSdkVersion 28 defaultConfig { minSdkVersion 16 targetSdkVersion 28

我有一个Android(Java)项目,在迁移到AndroidX后,我收到了以下错误
(d8错误)

请注意,渐变同步通常发生。此错误仅在设备编译时出现。最奇怪的是,只有在我为安卓4设备编译时才会发生这种情况。 尝试为Android 5+编译时,编译成功,应用程序运行平稳

build.gradle

[...]
 compileSdkVersion 28
 defaultConfig {

        minSdkVersion 16
        targetSdkVersion 28

        versionCode 1
        versionName "1.0.0"
        applicationId "br.com.example"

        multiDexEnabled true
        vectorDrawables.useSupportLibrary = true

        ndk.abiFilters 'armeabi-v7a','arm64-v8a','x86','x86_64'
    }

    dependencies {

        configurations {

            all*.exclude group: 'com.android.support', module: 'support-v4'
            all*.exclude group: 'com.android.support', module: 'support-annotations'
            all*.exclude group: 'com.android.support', module: 'appcompat-v7'
            all*.exclude group: 'com.android.support', module: 'support-v13'
        }

        implementation project(':mylib')

        //  These 3 libraries are required for the project.
        implementation files("libs/activation.jar")
        implementation files("libs/mail.jar")
        implementation files("libs/edtftpj.jar")

        implementation files("libs/commons-net-3.0.1.jar")
        implementation files("libs/commons-validator-1.4.0.jar")
        implementation files("libs/itextpdf-5.4.0.jar")


        implementation('com.appsee:appsee-android:2.3.3@aar') {
        transitive = true
        }
        implementation('com.optimizely:optimizely:1.4.2@aar') {
        transitive = true
        }
        implementation('io.fabric.sdk.android:fabric:1.4.8@aar') {
        transitive = true
        }
        implementation('com.crashlytics.sdk.android:crashlytics:2.10.1@aar') {
        transitive = true
        }


        implementation "com.onesignal:OneSignal:$oneSignalVersion"
        implementation "androidx.percentlayout:percentlayout:$percentLayoutVersion"
        implementation "androidx.legacy:legacy-support-v4:$legacyVersion"
        implementation "androidx.appcompat:appcompat:$androidxAppCompatVersion"
        implementation "androidx.recyclerview:recyclerview:$recyclerViewVersion"
        implementation "androidx.annotation:annotation:$androidxAppCompatVersion"
        implementation "androidx.constraintlayout:constraintlayout:$constraintLayoutVersion"

        implementation 'com.google.code.gson:gson:2.8.6'
        implementation 'com.google.guava:guava-collections:r03'
        implementation 'com.google.firebase:firebase-core:17.2.0'
        implementation "com.google.android.material:material:$materialVersion"
        implementation "com.google.android.gms:play-services-maps:$gmsVersion"
        implementation "com.google.android.gms:play-services-analytics:$gmsVersion"

        implementation 'com.google.dagger:dagger:2.24'
        annotationProcessor 'com.google.dagger:dagger-compiler:2.24'


        implementation 'com.squareup:otto:1.3.8'
        implementation 'org.jetbrains:annotations:17.0.0'
        implementation 'io.reactivex.rxjava2:rxandroid:2.1.1'

        implementation 'com.squareup.picasso:picasso:2.71828', {
        exclude group: 'com.android.support', module: 'support-annotations'
        }

        implementation 'com.lapism:searchview:4.0'
        implementation 'com.sromku:simple-storage:1.2.0'
        implementation 'me.dm7.barcodescanner:zxing:1.9.8', {
        exclude group: 'com.android.support', module: 'appcompat-v7'
        }

        implementation 'com.nononsenseapps:filepicker:2.5.2'
        implementation 'io.github.yavski:fab-speed-dial:1.0.6'
        implementation 'com.github.PhilJay:MPAndroidChart:v3.0.1'
        implementation 'com.github.arimorty:floatingsearchview:2.1.1'
        implementation 'net.i2p.android.ext:floatingactionbutton:1.10.1'
        implementation 'org.zakariya.stickyheaders:stickyheaders:0.7.11'
        implementation 'com.weiwangcn.betterspinner:library-material:1.1.0'
        implementation 'com.prolificinteractive:material-calendarview:1.4.3'

        implementation 'uk.co.chrisjenx:calligraphy:2.3.0', {
        exclude group: 'com.android.support', module: 'appcompat-v7'
        }

        // debug
        debugImplementation 'com.facebook.stetho:stetho:1.5.1'
        debugImplementation 'com.gu.android:toolargetool:0.1.5@aar'

        testImplementation 'junit:junit:4.12'
        testImplementation 'org.mockito:mockito-all:1.10.19'

        androidTestImplementation 'androidx.test.espresso:espresso-core:3.3.0-alpha02', {
        exclude group: 'com.android.support', module: 'support-annotations'
        }

    }

[...]
build.gradle(项目)

build.gradle(本地库:“mylib”)

gradle.properties

org.gradle.jvmargs=-Xmx2048M
org.gradle.configureondemand=false

android.enableJetifier=true
android.useAndroidX=true
我提到的3个库(activation、mail、edtftpj)需要同时存在于lib和project中,因为它实际上已经被使用了

我已经试过了:

  • /gradlew清洁
  • Android Studio->文件->使缓存无效并重新启动
  • Android Studio->构建->清理项目
  • 删除一个重复的库(这会产生另一个错误,因为我在两个模块中都使用了库工具)
  • 将以下代码添加到build.gradle:

有人能帮我吗?

请粘贴依赖项块您的答案:@Squti我更新了问题。现在您可以看到依赖项了。谢谢。@Hamed Karami,我试过了,但对我无效。请注意,对于demons和ID,编译正常。只有Android 4在编译时出现此错误。请粘贴依赖项阻止您的回答:@Squti我更新了问题。现在您可以看到依赖项了。谢谢。@Hamed Karami,我试过了,但对我无效。请注意,对于demons和ID,编译正常。只有Android 4在编译时出现此错误。
buildscript {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url 'https://maven.fabric.io/public' }
        maven { url 'https://maven.google.com' }
        maven { url 'https://plugins.gradle.org/m2/'}
    }

    dependencies {
        classpath 'com.android.tools.build:gradle:3.5.1'
        classpath 'gradle.plugin.com.onesignal:onesignal-gradle-plugin:0.12.5'
        classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
        classpath 'io.fabric.tools:gradle:1.31.1'
        classpath 'com.google.gms:google-services:4.3.2'
    }


}

allprojects {
    repositories {
        google()
        jcenter()
        mavenCentral()
        maven { url "https://www.jitpack.io" }
        maven { url 'http://dl.bintray.com/optimizely/optimizely' }
        maven { url 'https://maven.fabric.io/public' }
        maven { url 'https://maven.google.com' }
        maven { url "https://oss.sonatype.org/content/repositories/snapshots"}
        maven { url 'https://dl.bintray.com/guardian/android' }
    }
}

[...]
    compileSdkVersion 28

    defaultConfig {
        minSdkVersion 16
        targetSdkVersion 28
        versionCode 1
        versionName "1.0"
        vectorDrawables.useSupportLibrary = true
    }
[...]
    dependencies {

        // here, I repeat those 3 libraries mentioned (activation, mail, edtftpj)
        implementation fileTree(include: ['*.jar'], dir: 'libs')

        implementation 'androidx.browser:browser:1.0.0'
        implementation "com.google.android.gms:play-services-location:17.0.0"
        implementation "com.google.android.gms:play-services-maps:17.0.0"
        implementation "com.google.android.gms:play-services-analytics:17.0.0"
        implementation "com.google.android.material:material:1.0.0"
        implementation "androidx.appcompat:appcompat:1.1.0"
        implementation "androidx.annotation:annotation:1.1.0"
        implementation "androidx.cardview:cardview:1.0.0"
        implementation 'androidx.constraintlayout:constraintlayout:2.0.0-beta2'
        api 'br.com.concretesolutions:canarinho:1.1.0'
        api 'com.amulyakhare:com.amulyakhare.textdrawable:1.0.1'
    }

org.gradle.jvmargs=-Xmx2048M
org.gradle.configureondemand=false

android.enableJetifier=true
android.useAndroidX=true
packagingOptions {
       exclude 'com/sun/mail/dsn/mailcap'
       exclude 'dsn.mf'
       exclude 'javamail.charset.map'
       exclude 'javamail.default.address.map'
       exclude 'javamail.default.providers'
       exclude 'javamail.imap.provider'
       exclude 'javamail.pop3.provider'
       exclude 'javamail.smtp.address.map'
       exclude 'javamail.smtp.provider'
       exclude 'mailcap'
       exclude 'mimetypes.default'
       exclude 'mailcap.default'
       exclude 'com.enterprisedt.BaseIOException'
       exclude 'javax.activation.*'
   }