日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 运维知识 > Android >内容正文

Android

Android Studio代码迁移问题小汇总

發布時間:2023/12/14 Android 31 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Android Studio代码迁移问题小汇总 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

問題1:Duplicate class com.xxx.xxx.xxx.BuildConfig found in modules jetified-A-release-runtime 問題

> Duplicate class com.xxxdemo.xxx.xxx.BuildConfig found in modules jetified-A-release-runtime (:A-release:) and jetified-B-release-runtime (:B-release:)

Execution failed for task ':XXXdemo:checkReleaseDuplicateClasses'.
> A failure occurred while executing?com.android.build.gradle.internal.tasks.CheckDuplicatesRunnable
> Duplicate class com.XXX.XXX.B.BuildConfig found in modules jetified-A-release-runtime (:A-release:) and jetified-B-release-runtime (:B-release:)

?

解決:

1、剛開始以為是依賴問題,實際上多重依賴問題也不大,主要可能是版本不同就容易出現上述問題,版本問題看以下文章:

https://mp.csdn.net/editor/html/114635427

2、但最終我的問題是AndroidManifest.xml文件里面指定的"package=MyPakageName"包名不小心寫錯跟我依賴的第三方aar庫包名重名了,改名之后就OK了。

?

問題2:W/System.err: java.io.IOException: Cannot run program "su": error=13, Permission denied

代碼:

Process p = Runtime.getRuntime().exec("su");

解決:

Process su = Runtime.getRuntime().exec("/system/bin/sh");

推薦博文:

https://blog.csdn.net/weixin_43266090/article/details/108245698

?

問題3:java.lang.RuntimeException: Can't create handler inside thread that has not called Looper.prepare()

場景:沒有了aidl服務,獲取數據需要延遲,線程新增定時器出現此問題。

解決:

private Handler mHandler; mHandler = new Handler(Looper.getMainLooper());

問題4:android.util.AndroidRuntimeException: Calling startActivity() from outside of an Activity ?context requires the FLAG_ACTIVITY_NEW_TASK flag. Is this really what you want?

問題代碼: Intent intent = new Intent(mContext.getApplicationContext(), MyActivity.class); mContext.startActivity(intent);

解決:

intent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK );

?

問題5:The application could not be installed: INSTALL_FAILED_CONFLICTING_PROVIDER

解決:

更改android:authorities屬性,該命名重名或者沖突了

<providerandroid:name="com.zoncare.provider.TDBProvider"android:authorities="com.sprovider"android:exported="true"android:process=":remote"/>

?

問題6:Manifest merger failed with multiple errors, see logs

解決:

aar與當前工程的Manifest清單文件重復注冊了,刪除當前工程文件注冊即可。

?

問題7:BadTokenException: Unable to add window android.view.ViewRootImpl

懸浮窗權限:?
onCreate()添加:

? if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
? ? ? ? ? ? if (!Settings.canDrawOverlays(this)) {
? ? ? ? ? ? ? ? Intent intent = new Intent(Settings.ACTION_MANAGE_OVERLAY_PERMISSION,
? ? ? ? ? ? ? ? ? ? ? ? Uri.parse("package:" + getPackageName()));
? ? ? ? ? ? ? ? startActivityForResult(intent, OVERLAY_PERMISSION_REQ_CODE);
? ? ? ? ? ? }
? ? ? ? }

? @Override
? ? protected void onActivityResult(int requestCode, int resultCode, Intent data) {
? ? ? ? if (requestCode == OVERLAY_PERMISSION_REQ_CODE) {
? ? ? ? ? ? if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.M) {
? ? ? ? ? ? ? ? if (!Settings.canDrawOverlays(this)) {
? ? ? ? ? ? ? ? ? ? // SYSTEM_ALERT_WINDOW permission not granted...
? ? ? ? ? ? ? ? }
? ? ? ? ? ? }
? ? ? ? }
? ? }
?

SDK版本>23即android 6.0以上系統會彈出一個提示框允許界面上有提示框顯示,打開開關即可。

?

問題8:java.lang.IllegalArgumentException: Can only use lower 16 bits for requestCode

解決:

private static final int xxx_PERMISSION_REQ_CODE = 11;這里的賦值不能超過2的16次方值即35536。

?

問題9:ActivityThread: Failed to find provider info for com.xxx.xxxprovider

解決:

保證遠程數據庫訪問Uri作者與manifast注冊作者的一致性:

<!-- 數據庫遠程訪問 --><providerandroid:name="com.xxx.xxx.xxxService.provider.xxxDBProvider"android:authorities="com.aaa.aaa.aaaprovider"android:exported="true"android:process=":remote"tools:ignore="ExportedContentProvider"/>/*** DATABASE匹配,權值, 注意:保持與注冊的作者一致性。*/public static final String AUTHORITIES = "com.aaa.aaa.aaaprovider";private static final UriMatcher MATCHER = new UriMatcher(UriMatcher.NO_MATCH);MATCHER.addURI(xxx.AUTHORITIES, xxx.xxx_PATH, BBB_ARCHIVES);/*注意: 保持與注冊的作者一致性。*/private Uri mUri = null;public static final String xxx_URI = "content://" + AUTHORITIES + "/BBB_ARCHIVES";mUri = Uri.parse(xxx_URI);

?

?

總結

以上是生活随笔為你收集整理的Android Studio代码迁移问题小汇总的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。