λ³Έλ¬Έ λ°”λ‘œκ°€κΈ°
πŸ’š 개발/μ•ˆλ“œλ‘œμ΄λ“œ

[μ•ˆλ“œλ‘œμ΄λ“œ] 였λ₯˜ ν•΄κ²° The minCompileSdk (31) specified in adependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties) 그리고 메타데이터 μ‹€μŠ΅

by devshin.kr 2021. 11. 29.
728x90
였λ₯˜ λ‚΄μš© : 
One or more issues found when checking AAR metadata values:

The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-27).
Dependency: androidx.appcompat:appcompat:1.4.0.
AAR metadata file: C:\Users\shin\.gradle\caches\transforms-3\뭔가에 λŒ€ν•œ ν•΄μ‹œκ°’ κ°™μŒ... μ•± μ•„이디에 λŒ€ν•œ ν•΄μ‹œκ°’인가?\transformed\appcompat-1.4.0\META-INF\com\android\build\gradle\aar-metadata.properties.

 

 


Android12(API Level 31) λ‘œ μ˜¬λΌκ°€λ©΄μ„œ.. μƒκΈ΄ λ¬Έμ œμΈ κ²ƒ κ°™μŒ
λ‚˜μ˜ κ²½μš°μ—λŠ” meta-data μ‹€μŠ΅μ„ ν•΄ 보렀고 ν•˜λ‹€κ°€ λ§ˆμ£Όν–ˆλ‹€. (-> λ°”λ‘œ 해결방법 보렀면 5번으둜!)



1. src > main > res > values > strings.xml
화면에 meta-data Test!!!! κ°€ μΆœλ ₯되게 ν•΄ λ³΄μž.
strings μ•ˆμ— κ΅³μ΄ λ„£λŠ” μ΄μœ λŠ” λ””μ»΄νŒŒμΌ μ‹œμ— value κ°’ λ…ΈμΆœμ„ λ§‰κΈ° μœ„함이닀.

<resources>
    <string name="app_name">MetaDataTest</string>
    <string name="meta_test_str">meta-data Test!!!!</string>
</resources>

 



2. src > main > AndroidManifest.xml
meta-data μ˜ name(key라고 λ³΄λ©΄ λ¨) κ³Ό value λ₯Ό μ •ν•΄ μ€€λ‹€.
μ—¬κΈ°μ„œ value μ— 1λ²ˆμ—μ„œ λ§Œλ“  @strings/string이름 μ„ λ„£μ–΄ μ€€λ‹€.

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

    <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.MetaDataTest">

        <meta-data android:name="meta.data.key" android:value="@string/meta_test_str"/>

        <activity
            android:name=".MainActivity"
            android:exported="true">
            <intent-filter>
                <action android:name="android.intent.action.MAIN" />

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

</manifest>

 



3. src > main > res > activity_main.xml
ν”„λ‘œμ νŠΈ μƒμ„± μ‹œ κΈ°λ³Έμ μœΌλ‘œ μƒμ„±λ˜λŠ” xml μ½”λ“œμ— id μ™€ textSize λ§Œ μ€¬λ‹€.

<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
    xmlns:app="http://schemas.android.com/apk/res-auto"
    xmlns:tools="http://schemas.android.com/tools"
    android:layout_width="match_parent"
    android:layout_height="match_parent"
    tools:context=".MainActivity">

    <TextView
        android:id="@+id/text_view"
        android:layout_width="wrap_content"
        android:layout_height="wrap_content"
        android:text="Hello World!"
        android:textSize="50dp"
        app:layout_constraintBottom_toBottomOf="parent"
        app:layout_constraintLeft_toLeftOf="parent"
        app:layout_constraintRight_toRightOf="parent"
        app:layout_constraintTop_toTopOf="parent" />

</androidx.constraintlayout.widget.ConstraintLayout>

 

 


4. src > main > java > νŒ¨ν‚€μ§€λͺ… > MainActivity.java
meta-data μ˜ key(name)둜 value κ°’을 μ°Ύμ•„ μ˜€λŠ” μ½”λ“œλ₯Ό μž‘μ„±ν•΄ λ³΄μž.

package com.devshin93.metadatatest;

import androidx.appcompat.app.AppCompatActivity;

import android.content.pm.ApplicationInfo;
import android.content.pm.PackageManager;
import android.os.Bundle;
import android.widget.TextView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        TextView tv = (TextView)findViewById(R.id.text_view);

        try {
            ApplicationInfo appInfo = getPackageManager().getApplicationInfo(this.getPackageName(), PackageManager.GET_META_DATA);
            Bundle bundle = appInfo.metaData;
            String value = bundle.getString("meta.data.key");

            tv.setText(value);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}

 



5. 문제 λ°œμƒ!!!!
One or more issues found when checking AAR metadata values:

The minCompileSdk (31) specified in a
dependency's AAR metadata (META-INF/com/android/build/gradle/aar-metadata.properties)
is greater than this module's compileSdkVersion (android-27).
Dependency: androidx.appcompat:appcompat:1.4.0.
AAR metadata file: C:\Users\shin\.gradle\caches\transforms-3\뭔가에 λŒ€ν•œ ν•΄μ‹œκ°’ κ°™μŒ... μ•± μ•„이디에 λŒ€ν•œ ν•΄μ‹œκ°’인가?\transformed\appcompat-1.4.0\META-INF\com\android\build\gradle\aar-metadata.properties.


6. ν•΄κ²°μ±…
λ‘˜ μ€‘ μ•„λ¬΄κ±°λ‚˜ ν•΄λ„ λœλ‹€.
-> μ²« λ²ˆμž¬ ν•΄κ²°μ±… : compileSdk μ™€ targetSdk κ°€ 31이 μ•„λ‹Œ κ²½μš°,
implementation 'androidx.appcompat:appcompat:1.3.0'

 



-> λ‘ λ²ˆμ§Έ ν•΄κ²°μ±… : compileSdk κ³Ό targetSdk κ°€ 31인 κ²½μš° κ± ν•΄κ²° λ¨!

 

 

 

7. 문제 ν•΄κ²°! κ²°κ³Ό ν™”λ©΄

λŒ“κΈ€