μ€λ₯ λ΄μ© :
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. λ¬Έμ ν΄κ²°! κ²°κ³Ό νλ©΄
λκΈ