getting error while try to generate signed APK android studio 3

Deadly 提交于 2019-11-29 07:21:53

The XPP answer did not work for me. Most of the cross-referenced answers ignore that this can be caused by other library dependencies (i.e. JARs/AARs). In my case this error was only appearing during the signed build -- unsigned builds were fine.

Running 'gradlew :[MY-PROJECT]:dependencies' shows the full dependency tree. If you find a dependency that uses a JAR or classes in the javax/java namespace, then you can add a gradle exclude statement to your dependency declaration, such as (gradle 4.1+):

api('my.favorite.dependency') { exclude group: 'javax' }

Then run the gradle ':dependencies' task again. You should see that the excluded dependency is now removed from the tree. If this dependency is required for compilation and not provided elsewhere, then the build*/assemble* tasks will fail. If the dependency is required at runtime and not provided elsewhere, for ex. by the OS, then the app. will compile and then fail at runtime with a "ClassNotFound" exception.

In the worst case, if the dependency tree isn't much help, then you may have to start commenting-out dependencies and the code that uses them, to find the culprit dependency. Hopefully the dependency that caused this error was barely used. Once you find the dependency that causes the error, you need to fix the situation one of two ways. Either replace the JAR/AAR with something that doesn't cause the error; or rebuild the dependency so that the javax/java classes are not exported with the JAR/AAR.

I was seeing the same error. In my case this happened because I was including logback. Adding the following solved the issue for me (as described here):

compile('com.github.tony19:logback-android-classic:1.1.1-6') {
    exclude group: 'com.google.android', module: 'android'
}

After adding the above I was still seeing an issue (as described here) and I had to add the following:

configurations {
    all {
        exclude module: 'httpclient'
    }
}

I had the same problem. I followed @Amira Elsayed Ismail advice and downgraded to gradle 2.3.3

The building error vanished but I got a new wired warning Warning:Ignoring Android API artifact com.google.android:android:4.1.1.4 for release. After long search I knew that this error come because that one of my project dependencies is depending on com.google.android:android which mean that this dependency has directly declared a dependency on a version of Android.

I have to know which one of my dependencies is the cause of the that warning.I tried to comment dependencies one by one in the app\build.gradle and build the project.

In my case when I removed this package compile 'com.sematext.android:sematext-logsene:1.0.0' the project built without any error.

Now we found the package that are depending on android version inside we have to exclude that inner dependency to android version.

I changed compile 'com.sematext.android:sematext-logsene:1.0.0' to

compile ('com.sematext.android:sematext-logsene:1.0.0'){
    exclude group: 'com.google.android'
}

Now every thing are working fine; but I'm still using OLD gradle version. I went back to app\build.gradle and revert the gradle version back to 3.0.1

Now I fixed the problem and still using the latest gradle.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!