2011-07-02 27 views
12

Tôi đang sử dụng gói tương thích v4 trong dự án của mình, nhưng khi tôi cố xuất một ứng dụng đã ký, tôi nhận được thông báo sau từ Proguard. Tôi đã Googled cả buổi tối, nhưng tôi đã không tìm thấy câu trả lời để giải quyết điều này.Lỗi bảo vệ khi xuất khẩu ứng dụng đã ký bằng gói tương thích tổ ong android.support.v4.app

[2011-07-03 01:46:29 - worldscopeApp] Proguard returned with error code 1. See console 
[2011-07-03 01:46:29 - worldscopeApp] Warning: android.support.v4.app.ActivityCompatHoneycomb: can't find referenced method 'void invalidateOptionsMenu()' in class android.app.Activity 
[2011-07-03 01:46:29 - worldscopeApp] Warning: android.support.v4.app.ActivityCompatHoneycomb: can't find referenced method 'void dump(java.lang.String,java.io.FileDescriptor,java.io.PrintWriter,java.lang.String[])' in class android.app.Activity 
[2011-07-03 01:46:29 - worldscopeApp] Warning: android.support.v4.view.MenuCompatHoneycomb: can't find referenced method 'void setShowAsAction(int)' in class android.view.MenuItem 
[2011-07-03 01:46:29 - worldscopeApp]  You should check if you need to specify additional program jars. 
[2011-07-03 01:46:29 - worldscopeApp] Warning: there were 3 unresolved references to program class members. 
[2011-07-03 01:46:29 - worldscopeApp]   Your input classes appear to be inconsistent. 
[2011-07-03 01:46:29 - worldscopeApp]   You may need to recompile them and try again. 
[2011-07-03 01:46:29 - worldscopeApp]   Alternatively, you may have to specify the options 
[2011-07-03 01:46:29 - worldscopeApp]   '-dontskipnonpubliclibraryclasses' and/or 
[2011-07-03 01:46:29 - worldscopeApp]   '-dontskipnonpubliclibraryclassmembers'. 
[2011-07-03 01:46:29 - worldscopeApp] java.io.IOException: Please correct the above warnings first. 
[2011-07-03 01:46:29 - worldscopeApp] at proguard.Initializer.execute(Initializer.java:308) 
[2011-07-03 01:46:29 - worldscopeApp] at proguard.ProGuard.initialize(ProGuard.java:210) 
[2011-07-03 01:46:29 - worldscopeApp] at proguard.ProGuard.execute(ProGuard.java:85) 
[2011-07-03 01:46:29 - worldscopeApp] at proguard.ProGuard.main(ProGuard.java:499) 
+0

http://stackoverflow.com/a/17988163/1318946 –

Trả lời

26

Đây là những gì tôi đang sử dụng trong proguard.cfg tôi:

-dontwarn **CompatHoneycomb 
-keep public class * extends android.support.v4.app.Fragment 

More chung là:

-dontwarn **CompatHoneycomb 
-keep class android.support.v4.** { *; } 

Nhưng nó sẽ gây ra kích thước APK lớn hơn nên chỉ sử dụng nếu kích thước đầu tiên không hoạt động.

+0

Cảm ơn rất nhiều! Giải pháp thứ hai đã làm công việc. BTW, tùy chọn thứ ba là thay đổi mục tiêu xây dựng dự án thành API cấp 11 trở lên. – Goran

+0

Tôi cũng cần điều này: -dontwarn android.support. ** – Fraggle

34

Có vẻ như một số clases trong android.support.v4 không tương thích với một số lớp trong Android. Nếu bạn chắc chắn đây không phải là vấn đề, bạn có thể chỉ định

-dontwarn android.support.v4.** 

ProGuard sẽ bỏ qua những vấn đề này và tiếp tục xử lý mã.

Xem ProGuard thủ công> Troubleshooting> Cảnh báo: không thể tìm thấy tham chiếu lĩnh vực/phương pháp

+2

này đã làm việc cho tôi là tốt, trong khi sử dụng ** CompatHoneycomb thì không. Giải pháp này cũng được đề cập bởi Dianne Hackborn tại đây: https://plus.google.com/105051985738280261832/posts/K1tGvKG1NYv) –

+0

Tuyệt vời. Điều này hiện được thêm vào trong proguard-android.txt và proguard-android-optimize.txt đi kèm với SDK Android. –

0

Bạn nên đặt android: targetSdkVersion thành SDK> = honeycomb.

Để biết thông tin tôi đang sử dụng này một

<uses-sdk android:minSdkVersion="4" android:targetSdkVersion="13"/> 
Các vấn đề liên quan