公告:魔扣目录网为广大站长提供免费收录网站服务,提交前请做好本站友链:【 网站目录:https://www.morko.net 】, 免友链快审服务(50元/站),

点击这里在线咨询客服
新站提交
  • 网站:51998
  • 待审:31
  • 小程序:12
  • 文章:1030137
  • 会员:747

本文介绍了无法解析符号'活动公司'和内容'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是Android新手,正在学习如何实现基于位置的服务,但我遇到了以下错误-

无法解析符号‘ActivityCompat’
行‘导入android.support.v4.app.ActivityCompat;’

无法解析符号”Content”
在‘IMPORT android.support.v4.content.ContextCompat;’

‘行中

在做了一些研究之后,我发现您需要将以下内容添加到gradle.build文件compile 'com.android.support:support-v4:23.0.0'

所以我这样做了,但我仍然收到相同的错误。我试过了,还是什么都没有。

如何修复错误?

这是我尝试访问的链接

https://www.tutorialspoint.com/android/android_location_based_services.htm#

这是我的Java文件-

package com.example.location;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.content.pm.PackageManager;

import android.Manifest;
import android.app.Activity;
import android.os.Bundle;
import android.support.v4.content.ContextCompat; # error
import android.support.v4.app.ActivityCompat;    #error
import android.view.View;
import android.widget.Button;
import android.widget.Toast;
import android.app.Activity;

// Remaining code

这是我的Gradle

apply plugin: 'com.android.application'

android {
    compileSdkVersion 29
    buildToolsVersion "29.0.2"
    defaultConfig {
        applicationId "com.example.location"
        minSdkVersion 15
        targetSdkVersion 29
        versionCode 1
        versionName "1.0"
        testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
    }
    buildTypes {
        release {
            minifyEnabled false
            proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
        }
    }
}

dependencies {
    implementation fileTree(include: ['*.jar'], dir: 'libs')
    implementation 'androidx.appcompat:appcompat:1.1.0'
    implementation 'androidx.constraintlayout:constraintlayout:1.1.3'
    testImplementation 'junit:junit:4.12'
    androidTestImplementation 'androidx.test:runner:1.2.0'
    androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0'
    implementation 'com.android.support:support-compat:+'
    implementation 'com.android.support:appcompat-v7:+'

    implementation 'com.android.support:support-v4:26.1.0'
}
'''

推荐答案

您必须使用androidx类:

添加依赖项:

implementation "androidx.core:core-ktx:+"

并更改您的导入:

import android.support.v4.app.ActivityCompat -> import androidx.core.app.ActivityCompat
import android.support.v4.content.ContextCompat -> import androidx.core.content.ContextCompat

还要在build.gradle中删除支持库依赖项:

//implementation 'com.android.support:support-compat:+'
//implementation 'com.android.support:appcompat-v7:+'
//implementation 'com.android.support:support-v4:26.1.0'

这篇关于无法解析符号'活动公司'和内容'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,

分享到:
标签:amp 公司 内容 活动 符号 解析
用户无头像

网友整理

注册时间:

网站:5 个   小程序:0 个  文章:12 篇

  • 51998

    网站

  • 12

    小程序

  • 1030137

    文章

  • 747

    会员

赶快注册账号,推广您的网站吧!
最新入驻小程序

数独大挑战2018-06-03

数独一种数学游戏,玩家需要根据9

答题星2018-06-03

您可以通过答题星轻松地创建试卷

全阶人生考试2018-06-03

各种考试题,题库,初中,高中,大学四六

运动步数有氧达人2018-06-03

记录运动步数,积累氧气值。还可偷

每日养生app2018-06-03

每日养生,天天健康

体育训练成绩评定2018-06-03

通用课目体育训练成绩评定