使用debug的時(shí)候編譯是沒(méi)有報(bào)錯(cuò)的,可以生成apk我磁,進(jìn)行正式打包的時(shí)候驻襟,release版本build的時(shí)候報(bào)錯(cuò)了,報(bào)錯(cuò)信息如下:
Lint found fatal errors while assembling a release target.?
To proceed, either fix the issues identified by lint, or modify your build script as follows:? ...
? android {? ? ?
lintOptions {? ? ? ?
? checkReleaseBuilds false? ? ? ? ?
// Or, if you prefer, you can continue to check for errors in release builds,? ? ? ?
? // but continue the build even when errors are found:? ? ? ? ?
abortOnError false? ? ? }
? }
給出的解決方案其實(shí)是忽略這個(gè)問(wèn)題沉衣,但是這樣可能會(huì)對(duì)正式發(fā)布的app埋下隱患,所以還是盡量找出問(wèn)題所在存谎。
打包出錯(cuò)除了上面的日志沒(méi)有其他詳情信息,根據(jù)網(wǎng)上的資料和解決方法既荚,找到對(duì)應(yīng)的Android工程下的
app/build/reports/lint-results-release-fatal.html 文件
打開(kāi)后可以看到問(wèn)題的詳細(xì)原因:
在對(duì)應(yīng)的問(wèn)題處運(yùn)行恰聘,查看日志句各,發(fā)現(xiàn)問(wèn)題出現(xiàn)在如下代碼處:
2019-03-25 16:01:41.891 12940-12940/? E/AndroidRuntime: FATAL EXCEPTION: main Process: com.meizu.flyme.find, PID: 12940 java.lang.RuntimeException: Unable to start activity ComponentInfo{com.meizu.flyme.find/com.meizu.flyme.find.ui.MapHistoryActivity}: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:3079) at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3214) at android.app.servertransaction.LaunchActivityItem.execute(LaunchActivityItem.java:78) at android.app.servertransaction.TransactionExecutor.executeCallbacks(TransactionExecutor.java:108) at android.app.servertransaction.TransactionExecutor.execute(TransactionExecutor.java:68) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1936) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6921) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:493) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:937)Caused by: java.lang.NullPointerException: Attempt to invoke virtual method 'void android.widget.TextView.setText(java.lang.CharSequence)' on a null object reference at com.meizu.widget.b.<init>(SourceFile:45) at com.meizu.flyme.find.ui.MapHistoryActivity.a(SourceFile:100) at com.meizu.flyme.find.ui.MapHistoryActivity.onCreate(SourceFile:77)?
定位到問(wèn)題出現(xiàn)在 一個(gè)TextView的setText()操作中凿宾,原因是同步代碼不完全兼蕊,TextView在layout中沒(méi)有對(duì)應(yīng)的控件。
解決之后release打包正常遍略。問(wèn)題解決。