Android Studio 错误汇总

标题

package包名报错

这里写图片描述

原文如下:

The SDK platform-tools version(25.0.3) is too old to check APIs compiled with API 26;please update。

This check scans through all the Android API calls in the application and warns about any calls that are not available on all versions targeted by this application(according to its minimum SDK attribute in the manifest).

If you really want to use this API and don't need to support older devices just set the minSdkVersion in your build.gradle or AndroidManifest.xml files.

If your code is deliberately accessing newer APIs, and you have ensured (e.g.with conditional execution) that this code will only ever be called on a supported platform, then you can annotate your class or method with the @TargetApi annotation specifying the local minimum SDK to apply, such as @TargetApi(11), such that this check considers 11 rather than your manifest file's minimum SDK as the required API level.

If you are deliberately setting android:attributes in style definitions, make sure you place this in a values-vNN folder in order to avoid running into runtime conflicts on certain devices where manufacturers have added custom attributes whose ids conflict with the new ones on later platforms.

Similarly, you can use tools:targetApi="11" in an XML file to indicate that the element will only be inflated in an adequate context.

SDK平台工具的版本(25.0.3)太旧,检查API编写的API 26;请更新。
此检查扫描应用程序中的所有Android API调用,并警告所有应用程序所针对的所有版本都不可用的调用(根据清单中的最低SDK属性)。
如果你真的想使用这个API,不需要支持旧的设备只设置在你的build.gradle或xml文件的例子。
如果你的代码是故意访问新的API,你保证(有条件执行),此代码只会被支持的平台上,然后你就可以指定申请当地最低SDK”targetapi注释注释你的类或方法,如:“targetapi(11),这样,这张支票考虑11而不是你的manifest文件的最小SDK所需的API级别。
如果你是故意设置Android的风格定义属性,确保你把这一价值观为VNN文件夹避免陷入冲突在某些设备在运行时添加自定义属性的IDS厂商都对后世的平台,新的冲突。
同样,你可以使用工具:targetapi =“11”在一个XML文件表示该元素只会膨胀在一个适当的语境。

问题原因:
Android SDK Platform-Tools 需要更新。

解决办法:
更新Android SDK Platform-Tools,并重启AS。
Android Studio:platform-tools is too old

标题

新建项目卡死
AS在新建项目时会下载gradle文件,此文件在国外,大小80M左右,基本上是下载失败的,于是AS就会一直卡住。教程的思路是把gradle下载到本地,然后在AS上设置离线gradle。
一 下载Gradle
首先让电脑处于断网状态,然后打开AS,打开后新建项目
新建后,Message窗口有错误提示,打开。复制distributionUrl路径,联网下载此文件。
下载成功后将其解压,解压成功打开文件夹,里面还有一个文件夹,文件夹名字格式大概是gradle-3.3这样的,打开gradle-3.3后文件夹结构是这样的

这里写图片描述

然后你可以在D盘新建一个gradle文件夹,把gradle-3.3这个文件夹复制/移动进去。
二 设置离线gradle
打开AS,进入设置,点屏幕左上角的 File -> Settings 或者按快捷键 Ctrl + Alt + S
这里写图片描述

Gradle即可。

无法添加依赖

Unable to resolve dependency for ‘:app@debug/compileClasspath’: Could not resolve com.squareup.retrofit2:retrofit:2.4.0.

Could not resolve后面具体的依赖会不一样,但问题类似。
A. 检查Settings>Build,Execution>Gradle中Offline work,应处于没选中状态;
B. 配置Project下build.gradle:

allprojects {
    repositories {
        google()
        jcenter()
        maven {
            url "https://maven.google.com"
        }
    }
}

C. 不要依赖非稳定版的库。尽量是大版本库或不带alpha或beat的,或者是4.+类似的。
D. 添加jetpack的maven:

maven {
    url "https://jitpack.io"
}

E. 有说关闭android.enableAapt2=false,不要这样用,Google不建议关闭了。
F. 设置代理试试。
G. 使用Project Structure添加相关依赖。
H. 在C:\Users[用户名].gradle中gradle.properties配置文件中去掉代理:

#systemProp.https.proxyHost=mirrors.zzu.edu.cn
#systemProp.http.proxyPort=80

Plugs

无法下载Plugs
IDEA安装插件提示was not installed: Cannot download解决办法 评论中“Use secure Connetion去掉”那条

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值