[英]My AppCompatActivity isn't working. why so?
I was working on a project, following error showed up:我正在做一个项目,出现以下错误:
ERROR: Failed to resolve: com.android.support:design:29.3.0 Add Google Maven repository and sync project Show in Project Structure dialog Affected Modules: app ERROR: Failed to resolve: com.android.support:appcompat-v7:29.3.0 Add Google Maven repository and sync project Show in Project Structure dialog Affected Modules: app错误:无法解决:com.android.support:design:29.3.0 添加 Google Maven 存储库并同步项目在项目结构对话框中显示受影响的模块:app 错误:无法解决:com.android.support:appcompat-v7:29.3 .0 添加 Google Maven 存储库并同步项目在项目结构对话框中显示受影响的模块:app
Here is the code for the XML:这是 XML 的代码:
<LinearLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="@color/tan_background"
android:orientation="vertical"
tools:context="com.example.android.miwok.MainActivity">
<TextView
android:id="@+id/numbers"
style="@style/CategoryStyle"
android:background="@color/category_numbers"
android:text="@string/category_numbers" />
<TextView
android:id="@+id/family"
style="@style/CategoryStyle"
android:background="@color/category_family"
android:text="@string/category_family" />
<TextView
android:id="@+id/colors"
style="@style/CategoryStyle"
android:background="@color/category_colors"
android:text="@string/category_colors" />
<TextView
android:id="@+id/phrases"
style="@style/CategoryStyle"
android:background="@color/category_phrases"
android:text="@string/category_phrases" />
</LinearLayout>
And Java:和Java:
package com.example.android.myprejoct;
import android.os.Bundle;
import androidx.annotation.*;
public class MainActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
}
}
What do I do?我该怎么办?
Add this line in gradle file在gradle文件中添加这一行
allprojects {
repositories {
google()
// If you're using a version of Gradle lower than 4.1, you must
// instead use:
//
// maven {
// url 'https://maven.google.com'
// }
}
}
Hope this will work!希望这会奏效!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.