我在android studio中创建了一个新项目,但当我运行应用程序进行测试时,它显示了以下错误:
An issue was found when checking AAR metadata:
1. Dependency 'androidx.activity:activity:1.8.0' requires libraries and applications that
depend on it to compile against version 34 or later of the
Android APIs.
:app is currently compiled against android-33.
Also, the maximum recommended compile SDK version for Android Gradle
plugin 8.0.2 is 33.
Recommended action: Update this project's version of the Android Gradle
plugin to one that supports 34, then update this project to use
compileSdk of at least 34.
Note that updating a library or application's compileSdk (which
allows newer APIs to be used) can be done separately from updating
targetSdk (which opts the app in to new runtime behavior) and
minSdk (which determines which devices the app can be installed
on).
我不知道发生了什么,但目前我正在使用最新的更新和库。
这些是依赖关系:
dependencies {
implementation 'androidx.appcompat:appcompat:1.6.1'
implementation 'com.google.android.material:material:1.10.0'
implementation 'androidx.constraintlayout:constraintlayout:2.1.4'
implementation 'com.github.bumptech.glide:glide:4.16.0'
testImplementation 'junit:junit:4.13.2'
androidTestImplementation 'androidx.test.ext:junit:1.1.5'
androidTestImplementation 'androidx.test.espresso:espresso-core:3.5.1'
}
这是代码:
import androidx.appcompat.app.AppCompatActivity;
import androidx.recyclerview.widget.GridLayoutManager;
import androidx.recyclerview.widget.RecyclerView;
import android.os.Bundle;
import java.util.ArrayList;
public class AllBook extends AppCompatActivity {
private RecyclerView bookRecView;
BookRecAdapter bookAdapter;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_all_book);
bookAdapter = new BookRecAdapter(this);
bookRecView = findViewById(R.id.booksRecView);
bookRecView.setAdapter(bookAdapter);
bookRecView.setLayoutManager(new GridLayoutManager(this, 2));
ArrayList<Book> books = new ArrayList<>();
books.add(new Book(1, "1Q84", "Haruki Murakumi", 135, "https://i.gr-assets.com/images/S/compressed.photo.goodreads.com/books/1483103331l/10357575.jpg", "1Q84 is a novel written by Japanese writer Haruki Murakami, first published in three volumes in Japan in 2009–10."
, "1Q84 is a novel written by Japanese writer Haruki Murakami, first published in three volumes in Japan in 2009–10. It covers a fictionalized year of 1984 in parallel with a \"real\" one. The novel is a story of how a woman named Aomame begins to notice strange changes occurring in the world"));
bookAdapter.setBooks(books);
}
}
4条答案
按热度按时间9q78igpj1#
替换此实现:实现'com.google.android.material:material:1.10.0',其中:实现'com.google.android.material:material:1.8.0'
sg24os4d2#
如果您访问material 1.10.0的Maven存储库页面,您会注意到一个名为“编译依赖项”的部分。该部分列出了材料依赖项编译和正常运行所需的依赖项。通常,当您在项目中声明主依赖项时,会自动包括这些编译依赖项。
列表中的第一个依赖项是“activity 1.8.0”,它仅与大于或等于34的“compileSdk”版本兼容。要解决此兼容性问题,您可以降级材料依赖关系或升级项目的“compileSdk”版本。
mu0hgdu03#
只需要在build.gradle.kts中将compileSdk = 33更新为34
7tofc5zh4#
我正面临着同样的问题和降级的材料插件从
到
现在一切正常