【Android】構建Android12項目報錯


報錯信息:

Installed Build Tools revision 31.0.0 is corrupted. Remove and install again using the SDK Manager.

意思是構建工具31版本已中斷,使用SDK管理器移除並且重新安裝

 

解決方案:

在【Project Structure】選項中,【Module】

在這里回退30版本穩定的,小版本也要更改:

如果沒有,要先去下載這個版本的SDK

 

 

 

 

報錯信息:

Manifest merger failed : 
Apps targeting Android 12 and higher are required to specify an explicit value for `android:exported`
when the corresponding component has an intent filter defined.

See https://developer.android.com/guide/topics/manifest/activity-element#exported for details.

解決參考地址:

https://blog.csdn.net/lyabc123456/article/details/117232115

 

就是在那個標簽上面需要設置這個約束屬性:

<service android:name="com.example.app.backgroundService" android:exported="false">
    <intent-filter>
        <action android:name="com.example.app.START_BACKGROUND" />
    </intent-filter>
</service>

 

原生構建的項目【清單文件】是沒有這個的:

<?xml version="1.0" encoding="utf-8"?>
<manifest
    xmlns:android="http://schemas.android.com/apk/res/android"
    package="com.example.myapplication">

    <application

        android:allowBackup="true"
        android:icon="@mipmap/ic_launcher"
        android:label="@string/app_name"
        android:roundIcon="@mipmap/ic_launcher_round"
        android:supportsRtl="true"
        android:theme="@style/Theme.MyApplication">
        <activity android:name=".MainActivity">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

                <category android:name="android.intent.category.LAUNCHER" />
            </intent-filter>
        </activity>
    </application>

</manifest>

 

 

現在加上去之后立刻構建正常。。。

 


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM