Android开发常见问题

79 篇文章 1 订阅

常见问题

Minimum supported Gradle version is 7.2. Current version is 6.8. If using the gradle wrapper

看下当前工程目录中是否存在gradle目录,如果不存在,创建一个新的工程,拷贝新工程的gradle文件夹到当前工程。gradle中有两个文件。

在这里插入图片描述

androidjava.io.IOException: Unable to tunnel through proxy. Proxy returns “HTTP/1.1 400 Bad Request“

解决方法:
1.找到c盘下的gradle.properties文件
2.将代理注释
在这里插入图片描述
3.在gradle中设置不使用代理,重新加载,问题解决
在这里插入图片描述

Could not initialize class com.android.sdklib.repository.AndroidSdkHandler

gradle的版本太老了。将gradle升级。
https://blog.csdn.net/qq_36317441/article/details/122325618

Lint found errors in the project; aborting build.

打包AAR报错 lint 进行代码检查,防止代码不规范—如使用了过时的 api。

Lint found errors in the project; aborting build.

Fix the issues identified by lint, or create a baseline to see only new errors:

android {
    lint {
        baseline = file("lint-baseline.xml")
    }
}

解决方法:
在将要打包的模块中的 build.gradle 文件中添加如下内容,并单击 sync now。

android {
  //...
  lintOptions {
      abortOnError false
  }
}

Android如何引用jar包

Android如何引用jar包
将打包好的jar包添加到需要引入工程的Lib文件夹下。
右键点击此jar包,选择add as library。

https://developer.android.com/studio/build/dependencies?hl=zh-cn
其他方法

    implementation fileTree(dir: 'libs', include: ['*.jar','*.aar'])

在这里插入图片描述
Gradle 声明了对项目的 module_name/libs/ 目录中 JAR 文件的依赖关系(因为 Gradle 会读取 build.gradle 文件的相对路径)。
也就是说Gradle会读取build.gradle的相对路径,然后找build.gradle相对路径/libs/下路径的libs文件导入到项目中。所以创建的libs的目录要和build.gradle同级
在这里插入图片描述

Android模块如何使用本地的依赖,忽略项目的依赖。

  1. 在android的setting中进行以下设置。
    在这里插入图片描述
  2. 根据gradle-wrapper中distributionUrl的值,找到相应的gradle文件,并修改gradle文件添加
android.useAndroidX=true
android.enableJetifier=true

在这里插入图片描述
在这里插入图片描述

Android Studio R文件爆红但是项目可以运行

这种原因是你的R文件太大了(超过了Android Studio的上限25.6M了)
解决办法如下:
Help -> Edit Custom Properties -> create custom properties?(yes) ->添加 idea.max.intellisense.filesize=5000
转载:https://blog.csdn.net/LosingCarryJie/article/details/79489403

Android查看gradle版本

在这里插入图片描述

avc: denied { read } for name=“stat” dev=“proc” ino=4026532449 scontext=u:r:untrusted_app

https://blog.csdn.net/tung214/article/details/72734086
SELinex限制,
限制之后有三种结果:

  1. An Enforcing SELinux writes that Log AND denied the access. // 强制拒绝 记录日志且无法获取信息。
  2. A Permissive SELinux writes that Log BUT allow the access. // 写下日志并允许获取值
  3. A Disabled SELinux do NOT writes the log AND allow the access. // 不记录日志并且可以获取值
    缺少权限的补救方法:
    https://cloud.tencent.com/developer/article/1662137

Android主动杀死进程

Process.killProcess(Process.myPid());

https://blog.csdn.net/hwe_xc/article/details/50803454

Android导入项目时未具备相应平台版本。

下载相应平台版本导入后,在重新sync工程。

Failed to find Platform SDK with path: platforms;android-33

We recommend using a newer Android Gradle plugin to use compileSdk = 33

This Android Gradle plugin (7.1.3) was tested up to compileSdk = 32

在这里插入图片描述

清空并退出当前activity所在栈

activity.finishAffinity();

https://blog.csdn.net/xieluoxixi/article/details/53469553

assets 资源存放文档

https://www.jianshu.com/p/5974fcf88170

webView

https://blog.csdn.net/harvic880925/article/details/51523983

So库问题

问题:

couldn't find "libHplayers.so"

解决方法:

android {

    // 添加so库
    sourceSets{
        main{
            jniLibs.srcDirs = ['libs']
        }
    }
}

core版本问题

 C:\Users\xxx\.gradle\caches\transforms-2\files-2.1\319492c62ad32ad530467d6d0d6c17f1\core-1.8.0\res\values\values.xml:104:5-113:25: AAPT: error: resource android:a
ttr/lStar not found.

core版本过高导致编译未通过。可以在build.gradle中添加

}
configurations.all {
    resolutionStrategy{
        force 'androidx.core:core:1.6.0'
    }
}

dependencies {

}

基础问题

0x0000 十六进制

使用AndroidX报错

Caused by: com.android.builder.errors.EvalIssueException: This project uses AndroidX dependencies, but the 'android.useAndroidX' property is not enabled. Set this property to true in the gradle.properties file and retry.

在这里插入图片描述
解决方法:
添加下面的代码:

android.useAndroidX=true
android.enableJetifier=true

Android31以及以上可能出现的问题

将测试应用安装到高版本android手机的时候会报下面的错误。
在这里插入图片描述
解决此错误,在activity的属性中添加

android:exported="true"

在这里插入图片描述

GC:

在这里插入图片描述

gradle构建AAR时遇到的问题

  • 2
    点赞
  • 7
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
Android 开发中,debug.keystore 是一个默认的调试密钥库,它用于签署 Android 应用程序的调试版本。这个密钥库通常存储在用户的本地计算机上。 debug.keystore 包含一个默认的密钥对,密钥库密码为 "android",密钥密码也为 "android"。当你使用 Android Studio 或者其他的 Android 开发工具来创建一个新的应用程序时,它会自动为你生成 debug.keystore。 在 Android Studio 中,debug.keystore 存储在以下位置: ``` ~/.android/debug.keystore (Linux and macOS) C:\Users\your_user_name\.android\debug.keystore (Windows) ``` 在开发过程中,你可以使用 debug.keystore 来签署你的应用程序,以便在调试和测试时使用。但是,在发布应用程序之前,你应该使用一个真正的密钥库来签署你的应用程序。 要在 Android Studio 中使用 debug.keystore,可以按照以下步骤操作: 1. 在 Gradle 窗口中,单击你的应用程序模块。 2. 单击 "Tasks" -> "android" -> "signingReport"。 3. 在 "Run" 窗口中,你将看到一个输出,其中包含 debug.keystore 的详细信息,如密钥别名、密码、有效期等。 此外,你也可以在构建过程中指定使用 debug.keystore 来签署应用程序。在 build.gradle 文件中,可以按照以下方式指定签署配置: ``` android { signingConfigs { debug { storeFile file('debug.keystore') storePassword 'android' keyAlias 'androiddebugkey' keyPassword 'android' } } buildTypes { debug { signingConfig signingConfigs.debug } } } ``` 这将允许你在构建调试版本时使用 debug.keystore 来签署应用程序。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

学知识拯救世界

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值