Android Studio编译旧的app代码错误及解决方法

news/2024/7/16 10:21:42 标签: android studio, android, ide

androidinjectedbuilddensity_is_deprecated_0">‘android.injected.build.density’ is deprecated.

The option ‘android.injected.build.density’ is deprecated.
It was removed in version 8.0 of the Android Gradle plugin.
Density property injection from Android Studio has been removed.

解决

app/build.gradle
apply plugin: ‘com.android.application’
改成
plugins {
id ‘com.android.application’
}

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0. FAILURE: Build failed with an exception.

  • What went wrong:
    A problem occurred configuring project ‘:app’.

Failed to notify project evaluation listener.
‘org.gradle.api.file.RegularFileProperty org.gradle.api.file.ProjectLayout.fileProperty(org.gradle.api.provider.Provider)’

  • Try:
    Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.

  • Get more help at https://help.gradle.org

BUILD FAILED in 46s

Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use ‘–warning-mode all’ to show the individual deprecation warnings.
See https://docs.gradle.org/6.8/userguide/command_line_interface.html#sec:command_line_warnings

解决

build.gradle
buildscript {
apply from: ‘dependencies.gradle’
dependencies {
classpath gradlePlugins.android
}
}
改成
dependencies {
classpath ‘com.android.tools.build:gradle:7.1.1’
}

androidinternalversioncheck_45">Failed to apply plugin ‘com.android.internal.version-check’.

Failed to apply plugin ‘com.android.internal.version-check’. Minimum supported Gradle version is 7.2. Current version is 6.8. If using the gradle wrapper, try editing the distributionUrl in xx/gradle/wrapper/gradle-wrapper.properties to gradle-7.2-all.zip

解决

删除.idea .gradle
点击Android studio中的 File->Invalidate cache删除cache

如果不存在gradle/wrapper/gradle-wrapper.properties
则创建此目录mkdir -p gradle/wrapper
并新建 gradle/wrapper/gradle-wrapper.properties
如果存在则直接修改
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https://services.gradle.org/distributions/gradle-7.2-all.zip

android_of_type_62">Could not get unknown property ‘versions’ for extension ‘android’ of type

Could not get unknown property ‘versions’ for extension ‘android’ of type com.android.build.gradle.internal.dsl.BaseAppModuleExtension.

解决

修改app/build.gradle文件中的compileSdkVersion versions.compileSdk为compileSdkVersion 28

Could not get unknown property ‘libraries’ for object of type

Could not get unknown property ‘libraries’ for object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandler.

解决

修改app/build.gradle
这行compile libraries.supportAppCompat
改为
implementation(‘com.android.support:support-v4:23.0.+’)

Could not find method compile() for arguments [directory ‘libs’] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandle

org.gradle.internal.metaobject.AbstractDynamicObject$CustomMessageMissingMethodException: Could not find method compile() for arguments [directory ‘libs’] on object of type org.gradle.api.internal.artifacts.dsl.dependencies.DefaultDependencyHandle

解决

build.gradle中
compile fileTree(include: ['.jar’], dir: ‘libs’)
改为
implementation fileTree(dir: “libs”, include: ["
.jar"])

SDK Build Tools version (28.0.3) is ignored

The specified Android SDK Build Tools version (28.0.3) is ignored, as it is below the minimum supported version (30.0.3) for Android Gradle Plugin 7.1.1.
Android SDK Build Tools 30.0.3 will be used.

解决

app/build.gradle中
buildToolsVersion ‘28.0.3’
改为
buildToolsVersion “30.0.3”

androidsupportv7app_93">错误: 程序包android.support.v7.app不存在

程序包android.support.v7.app不存在 import android.support.v7.app.NotificationCompat;
错误: 程序包android.support.v4.app.NotificationCompat不存在

解决

app/build.gradle的dependencies中添加
implementation(‘com.android.support:support-v4:23.0.+’)

找不到符号 ContextCompat.startForegroundService

找不到符号
ContextCompat.startForegroundService(context,todayStepIntent);
符号: 方法 startForegroundService(Context,Intent)
位置: 类 ContextCompat

解决

代码ContextCompat.startForegroundService(context,todayStepIntent);改成
context.startForegroundService(todayStepIntent);

AAPT: error: style attribute 'attr/colorPrimary

ERROR:TodayStepCounter/app/src/main/res/values/styles.xml:4:5-9:13: AAPT: error: style attribute ‘attr/colorPrimary (aka com.example.android.todaystepcounter:attr/colorPrimary)’ not found.

解决

app/build.gradle中加
implementation ‘com.android.support:appcompat-v7:26.1.0’
注意如果是比较旧的安卓程序,有些代码比较旧只能用v7:26.1.0,不能用
implementation ‘com.android.support:appcompat-v7:28.0.0’

作者:帅得不敢出门 csdn原创谢绝转载


http://www.niftyadmin.cn/n/5125140.html

相关文章

已更新!c++第四章知识点合集(自定义函数的格式和使用方法详解, #include,函数的嵌套 递归,局部变量与全局变量的区别等等)

c知识点合集已经完成欢迎前往主页查看,点点赞点点关注不迷路哦 点我进入c第一章知识点合集 MYSQL知识点持续更新中 MYSQL第一章节DDL数据定义语言的操作----点我进入 MYSQL第二章节DDL-数据库操作语言 DQL-数据查询语言----点我进入 MYSQL-第三章节DCL-管理用户&…

【Python机器学习】零基础掌握AdaBoostRegressor集成学习

有没有经历过这样的状况:需要预测未来房价走势,但传统的预测方法并不总是准确? 房价预测一直是人们关注的热点话题,无论是房产商、购房者,还是政府,都需要准确地知道未来房价的走势。那么,有没有一种更加精准、稳定的预测方法呢?答案是有的——AdaBoost Regressor算法…

iOS自动混淆测试处理笔记

1 打开 ipa,导出ipa 路径和配置文件路径会自动填充 2 点击 开始自动混淆测试处理 自动混淆测试是针对 oc 类和oc方法这两个模块进行自动混淆ipa,并ipa安装到设备中运行,通过检测运行ipa包是否崩溃,来对oc类和oc方法进行筛选。如果…

记src-Juniper

一、hunter搜索web.title”Juniper Web Device Manager”,查找到香港的一处资产。 二、访问相关网页,界面就是Juniper登录界面。 三、根据编号为CVE-2023-36845的利用方法,抓包,修改提交方式,成功读取到文件。 原始包…

TypeScript之索引签名

1. 索引签名 在 TypeScript 中,索引签名是一种定义对象类型的方式,它允许我们使用字符串或数字作为索引来访问对象的属性。 索引签名最主要的作用就是允许我们动态地添加或访问对象的属性,通过使用索引签名,我们可以在编译时无法…

一次做题感受

一次做题感受 昨天早上(也就是 10 10 10月 25 25 25日早上),我们打了一场模拟赛。有四道题,下午的时候我补完了三道,晚上准备补 T 4 T4 T4。 T 4 T4 T4是这道题,有一定难度。我能理解它的题解,…

FPGA设计时序约束七、设置时钟不确定约束

一、背景 在之前的时序分析中,通常是假定时钟是稳定理想的,即设置主时钟周期后按照周期精确的进行边沿跳动。在实际中,时钟是非理想存在较多不确定的影响,存在时延和波形的变化,要准确分析时序也需将其考虑进来&#x…

import javax.validation* 对输入时间 Date 进行校验的注解

Future:这个注解用于确保被标注的日期字段值必须在当前时间之后。例如,如果你有一个日期字段dateField,你可以使用Future对其进行注解,以约束其值必须在当前时间之后。 Past:这个注解用于确保被标注的日期字段值必须在…