2017-10-30 20 views
5

Tôi nhận được lỗi sau khi cố gắng tạo ký APK trong studio android 3nhận lỗi khi cố gắng tạo ký apk Android Studio 3

Error:trouble processing "javax/xml/namespace/QName.class": 
Error:Ill-advised or mistaken usage of a core class (java.* or javax.*) 
Error:when not building a core library. 
Error:This is often due to inadvertently including a core library file 
Error:in your application's project, when using an IDE (such as 
Error:Eclipse). If you are sure you're not intentionally defining a 
Error:core class, then this is the most likely explanation of what's 
Error:going on. 
Error:However, you might actually be trying to define a class in a core 
Error:namespace, the source of which you may have taken, for example, 
Error:from a non-Android virtual machine project. This will most 
Error:assuredly not work. At a minimum, it jeopardizes the 
Error:compatibility of your app with future versions of the platform. 
Error:It is also often of questionable legality. 
Error:If you really intend to build a core library -- which is only 
Error:appropriate as part of creating a full virtual machine 
Error:distribution, as opposed to compiling an application -- then use 
Error:the "--core-library" option to suppress this error message. 
Error:If you go ahead and use "--core-library" but are in fact 
Error:building an application, then be forewarned that your application 
Error:will still fail to build or run, at some point. Please be 
Error:prepared for angry customers who find, for example, that your 
Error:application ceases to function once they upgrade their operating 
Error:system. You will be to blame for this problem. 
Error:If you are legitimately using some code that happens to be in a 
Error:core package, then the easiest safe alternative you have is to 
Error:repackage that code. That is, move the classes in question into 
Error:your own package namespace. This means that they will never be in 
Error:conflict with core system classes. JarJar is a tool that may help 
Error:you in this endeavor. If you find that you cannot do this, then 
Error:that is an indication that the path you are on will ultimately 
Error:lead to pain, suffering, grief, and lamentation. 
Error:1 error; aborting 
Error:Execution failed for task ':_4SaleApp:transformClassesWithDexForRelease'. 
> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: Error while executing java process with main class com.android.dx.command.Main with arguments {--dex --num-threads=4 --multi-dex --main-dex-list /Volumes/Data/AMIRA/Work/Q84Sale/Q84Sale/_4SaleApp/build/intermediates/multi-dex/release/maindexlist.txt --output /Volumes/Data/AMIRA/Work/Q84Sale/Q84Sale/_4SaleApp/build/intermediates/transforms/dex/release/0 --min-sdk-version 16 /Volumes/Data/AMIRA/Work/Q84Sale/Q84Sale/_4SaleApp/build/intermediates/transforms/jarMerging/release/0.jar} 

bất cứ ai có thể giúp đỡ xin vui lòng?

+0

đảm bảo mã của bạn không có lớp hoặc chức năng từ mã java hoặc android không được hỗ trợ. –

+0

làm thế nào tôi có thể biết rằng, các lỗi không hiển thị bất kỳ gợi ý về các tập tin mà làm cho vấn đề –

+0

[This] (https://stackoverflow.com/a/10176710) câu trả lời có thể giúp bạn về vấn đề này. – Fio

Trả lời

0

Tôi đã gặp lỗi tương tự. Trong trường hợp của tôi, điều này xảy ra bởi vì tôi đã bao gồm logback. Thêm những điều sau đây giải quyết vấn đề này đối với tôi (như mô tả here):

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

Sau khi thêm trên, chúng tôi vẫn còn nhìn thấy một vấn đề (như mô tả here) và tôi đã có thêm những điều sau đây:

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

Câu trả lời XPP không hoạt động đối với tôi. Hầu hết các câu trả lời được tham chiếu chéo đều bỏ qua điều này có thể do các phụ thuộc thư viện khác gây ra (tức là các JAR/AAR). Trong trường hợp của tôi lỗi này chỉ xuất hiện trong quá trình xây dựng đã ký - unsigned builds là tốt.

Chạy 'gradlew: [MY-PROJECT]: phụ thuộc' hiển thị cây phụ thuộc đầy đủ. Nếu bạn tìm thấy một sự phụ thuộc có sử dụng một JAR hoặc các lớp học trong không gian tên javax/java, sau đó bạn có thể thêm một gradle loại trừ tuyên bố khai phụ thuộc của bạn, chẳng hạn như (gradle 4.1+):

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

Sau đó chạy tác vụ phụ thuộc ': phụ thuộc' một lần nữa. Bạn sẽ thấy rằng sự phụ thuộc bị loại bỏ hiện được loại bỏ khỏi cây. Nếu sự phụ thuộc này là cần thiết để biên dịch và không được cung cấp ở nơi khác, thì nhiệm vụ build */assemble * sẽ thất bại. Nếu phụ thuộc được yêu cầu trong thời gian chạy và không được cung cấp ở nơi khác, ví dụ: bởi hệ điều hành, sau đó là ứng dụng. sẽ biên dịch và sau đó không thành công khi chạy với ngoại lệ "ClassNotFound".

Trong trường hợp xấu nhất, nếu cây phụ thuộc không có nhiều trợ giúp, thì bạn có thể phải bắt đầu phụ thuộc nhận xét và mã sử dụng chúng, để tìm phụ thuộc thủ phạm. Hy vọng rằng sự phụ thuộc gây ra lỗi này hầu như không được sử dụng. Một khi bạn tìm thấy sự phụ thuộc gây ra lỗi, bạn cần phải khắc phục tình trạng một trong hai cách. Hoặc thay thế JAR/AAR bằng thứ gì đó không gây ra lỗi; hoặc xây dựng lại sự phụ thuộc để các lớp javax/java không được xuất khẩu với JAR/AAR.

Các vấn đề liên quan