yaming116 / UpdateApp

app update, is mainly responsible for app download and installation, etc. 开箱即用的app更新,主要负责软件下载、软件安装等。
Apache License 2.0
348 stars 61 forks source link

8.0上面没有适配 #32

Closed VliceZ closed 5 years ago

VliceZ commented 5 years ago

小米8.0,框架1.0.6版本报 java.lang.NoSuchMethodError: No virtual method setChannelId(Ljava/lang/String;)Landroid/support/v4/app/NotificationCompat$Builder; in class Landroid/support/v4/app/NotificationCompat$Builder; or its super classes (declaration of 'android.support.v4.app.NotificationCompat$Builder' appears in /data/app/-F6ISuTaS0n1sBIuIxfEw_g==/base.apk!classes68.dex) at me.shenfan.updateapp.UpdateService.buildNotification(UpdateService.java:292) at me.shenfan.updateapp.UpdateService.onStartCommand(UpdateService.java:208) at android.app.ActivityThread.handleServiceArgs(ActivityThread.java:3512) at android.app.ActivityThread.-wrap20(Unknown Source:0) at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1720) at android.os.Handler.dispatchMessage(Handler.java:106) at android.os.Looper.loop(Looper.java:164) at android.app.ActivityThread.main(ActivityThread.java:6637) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:518) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:822)

VliceZ commented 5 years ago

解决了,关键代码在installIntent方法下改了这一部分 if(Build.VERSION.SDK_INT >= 24) { // Uri fileUri = FileProvider.getUriForFile(context, getFileProviderAuthority(context), new File(path)); Uri apkUri = FileProvider.getUriForFile(context, "manifest文件下配的provider的authorities名.fileprovider", new File(path)); intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK); intent.addFlags(Intent.FLAG_GRANT_READ_URI_PERMISSION); intent.setDataAndType(apkUri, "application/vnd.android.package-archive"); } else { intent.setDataAndType(Uri.fromFile(new File(path)), "application/vnd.android.package-archive"); }