安卓学习中遇到的问题【bug】

安卓学习中遇到的问题

1Gradle下载慢怎么办?

Gradle下载慢怎么办?

distributionUrl=https://mirrors.cloud.tencent.com/gradle/gradle-7.5-bin.zip

2 Could not resolve all files for configuration ‘:classpath‘. > Could not resolve com.android.tools

Could not resolve all files for configuration ‘:classpath‘. > Could not resolve com.android.tools

https://blog.csdn.net/AgonyAngela/article/details/138075256

在这里插入图片描述

3 sdk下载慢的解决办法

sdk下载慢的解决办法

4 为什么android studio代码提示很慢

为什么android studio代码提示很慢

缓解修复Android Studio卡顿,Kotlin代码提示慢

5 Android Studio开发遇到爆红@layout/activity_main does not contain a declaration with id `xx

Android Studio开发遇到爆红`@layout/activity_main` does not contain a declaration with id `xx

Alt + Enter,选择第二个

× suppress MissingInflatedld with an annotation

6 Android开发中Button背景颜色不能修改问题及解决方法

Android开发中Button背景颜色不能修改问题及解决方法

AndroidStudio无法改变Button背景颜色解决办法

把其中values/themes.xml文件

	<style name="Theme.HelloWorld" parent="Theme.MaterialComponents.DayNight.DarkActionBar">

parent后面的值改为Theme.MaterialComponents.DayNight.NoActionBar.Bridge

    <style name="Theme.HelloWorld" parent="Theme.MaterialComponents.DayNight.NoActionBar.Bridge">

在这里插入图片描述

7 Android Studio Error: Activity class {com.example/com.example.MainActivity} does not exist.

Android Studio Error: Activity class {com.example/com.example.MainActivity} does not exist.原因及解决办法

https://blog.csdn.net/qq_43525355/article/details/88057367

8 android 运行时改代码吗,Android Studio 编译运行时安装的是上次打包的代码而不是修改后的代码…

android 运行时改代码吗,Android Studio 编译运行时安装的是上次打包的代码而不是修改后的代码…

https://blog.csdn.net/weixin_39845241/article/details/117551808

https://blog.csdn.net/niubitianping/article/details/117779567

9 FAILURE: Build failed with an exception.

项目目录有中文字符

FAILURE: Build failed with an exception.

  • Where:
    Build file ‘D:\Desktop\���ļ�\HelloWorld\app\build.gradle’ line: 2

  • What went wrong:
    An exception occurred applying plugin request [id: ‘com.android.application’]

Failed to apply plugin ‘com.android.internal.application’.
Your project path contains non-ASCII characters. This will most likely cause the build to fail on Windows. Please move your project to a different directory. See http://b.android.com/95744 for details. This warning can be disabled by adding the line ‘android.overridePathCheck=true’ to gradle.properties file in the project directory.

10 Error while waiting for device: Nexus 6 API 34 is already running.

Error while waiting for device: Nexus 6 API 34 is already running. If that is not the case, delete C:\Users\lenovo.android\avd\Nexus_6_API_34.avd*.lock and try again.
远程主机强迫关闭了一个现有的连接。

11 A problem occurred evaluating project ‘:app’.

A problem occurred evaluating project ‘:app’. > Build was configured to prefer settings repositories over project repositories but repository ‘Google’ was added by build file ‘app\build.gradle’

依赖第三方jar包 glide

在这里插入图片描述

setting.grade中已经有了

repositories {
	google()
	mavenCentral()
}

在这里插入图片描述
只需在build.grade(:app)中配置就好了。

dependencies {
	implementation 'com.github.bumptech.glide:glide:4.16.0
}

在这里插入图片描述

12 E/GlideExecutor: Request threw uncaught throwable

E/GlideExecutor: Request threw uncaught throwable
java.lang.SecurityException: Permission denied (missing INTERNET permission?)

没有网络请求的权限

在AndroidManifest.xml加入

 <uses-permission android:name="android.permission.INTERNET"/>

在这里插入图片描述

13 mWvMain.loadUrl(“javascript:alert('hello)”);为什么没弹出

mWvMain.loadUrl(“javascript:alert('hello)”);为什么没弹出

Android webview调用js代码无效 webView.loadUrl(“javascript:alert(‘hello’)”)

14 Android Toast.setGravity()失效,无作用原因及其修改方法!

Android Toast.setGravity()失效,无作用原因及其修改方法!

//在30+的版本不起作用
//E/Toast: setGravity() shouldn’t be called on text toasts, the values won’t be used
toastCenter.setGravity(Gravity.CENTER, 0, 0);

15 为什么没有这个类AlterDialog

import androidx.appcompat.app.AlertDialog;

AlertDialog.Builder builder=new AlertDialog.Builder(DialogActivity.this);

解决Android v4、v7包导入标红问题import android.support.v4.app.ActivityCompat;import android.support.v7.app

16 Installation did not succeed. The application could not be installed: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

Installation did not succeed.
The application could not be installed: INSTALL_PARSE_FAILED_MANIFEST_MALFORMED

List of apks:
[0] ‘E:\AndroidStudioProjects\HelloWorld\app\build\intermediates\apk\debug\app-debug.apk’
Installation failed due to: ‘INSTALL_PARSE_FAILED_MANIFEST_MALFORMED: Failed parse during installPackageLI: /data/app/vmdl707213382.tmp/base.apk (at Binary XML file line #80): Invalid taskAffinity name asdfghjkdfghj in package com.example.helloworld: must have at least one ‘.’ separator’
Retry
Failed to launch an application on all devices

在这里插入图片描述

17 新版本Fragment的API

这个是新版本的import androidx.fragment.app.Fragment;

import androidx.fragment.app.Fragment;
public class AFragment extends Fragment {
public class BFragment extends Fragment {

getSupportFragmentManager().beginTransaction().replace(R.id.fl_container, bFragment).commit();
getSupportFragmentManager().beginTransaction().add(R.id.fl_container, aFragment).commitAllowingStateLoss();

这个是被废弃的import android.app.Fragment;

import android.app.Fragment;
public class AFragment extends Fragment {
public class BFragment extends Fragment {

getFragmentManager().beginTransaction().replace(R.id.fl_container, bFragment).commit();
getFragmentManager().beginTransaction().add(R.id.fl_container, aFragment).commitAllowingStateLoss();

18 @layout/activity event does not contain a declaration with id btn event

@layout/activity event does not contain a declaration with id btn event

过一会就不报错了

    @SuppressLint("MissingInflatedId")

19 外部文件权限

fileNotfoundException: /storage/enulated/0/skypan/test.txt (pernission denied)

AndroidManifest.xml

    <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" />

如果是Android22+,还需要在
MainActivity

        ActivityCompat.requestPermissions(this, new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 1);

  • 14
    点赞
  • 10
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

打赏作者

日星月云

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

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

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

打赏作者

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

抵扣说明:

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

余额充值