[Android studio configuration and errors]

Gradle is a project automation build tool based on Apache Ant and Apache Maven concepts. It uses a Groovy-based Domain-Specific Language (DSL) to declare project settings, ditching the cumbersome XML-based configuration.

Mainly for Java applications. Currently its supported languages ​​are limited to Java, Groovy and Scala, with plans to support more languages ​​in the future.

 

emulator emulator

Use the shortcut key alt+enter for automatic import

 

set up:

Modify the font to: Consolas

 

Configure GitHub:

Setting-Version Control-GitHub

 

 Android Studio's Git tool to manage your code

 https://blog.csdn.net/u011418943/article/details/70157776

 Using Git (project management and version control)

 https://blog.csdn.net/lxh19930428/article/details/54931006

 

 

Emulator:

 

Run your app on the emulator

 

Before running your app on the emulator, you need to create an Android Virtual Device (AVD) definition. AVD definitions can be used to define the characteristics of an Android phone, tablet, Android Wear or Android TV device that you want to emulate in the Android Emulator.

Create an AVD definition as follows:

Start the Android Virtual Device Manager by selecting Tools > Android > AVD Manager, or by clicking the AVD Manager icon in the toolbar.

On the Your Virtual Devices screen, click Create Virtual Device.

On the Select Hardware screen, select the phone device (eg, Nexus 6), and then click Next.

On the System Image screen, select the desired system image for the AVD and click Next.

If a specific system image is not installed, it can be obtained by clicking the Download link.

Verify the configuration settings (for your first AVD leave everything as it is) and hit Finish.

For more information on using AVDs, see Creating and Managing Virtual Devices.

Run the app from Android Studio as follows:

In Android Studio, select your project and click Run in the toolbar.

In the Select Deployment Target window, select your emulator and click OK.

The emulator may take a few minutes to start up. You may need to unlock the screen. Once unlocked, My First App will appear on the emulator screen.

 

 

Detailed explanation of the installation and use tutorial of Android emulator Genymotion

https://www.cnblogs.com/whycxb/p/6850454.html

 

Genymotion virtual image download slow or failed solution

https://jingyan.baidu.com/article/363872ec296c0c6e4ba16f0a.html

Address: files2.genymotion.com/dists/6.0.0/ova/genymotion_vbox86p_6.0_170320_193253.ova

 

 

Can't find Genymotion emulator solution when Android studio is running

https://blog.csdn.net/kuangdoushi/article/details/53263180

https://blog.csdn.net/qq_34369025/article/details/53374380

Make sure that there is only one emulator you have opened, and then open your own task manager to see if your adb process is running.

I am using the Genymotion emulator, so there will be three adb processes running in the process, if there is no one or not three, then the following operations are also invalid

 

 

Android Studio opens DDMS to view phone files

Tools -> android -> android device monitor 

 

 

Android studio导入libs

复制你需要添加的jar,并将其黏贴到app— —src— —main— —libs文件夹下,可运行的AndroidStudio项目都有像这样的目录结构。可以看到虽然jar已经复制黏贴过来了,但是还未导入

右键点击新黏贴的jar,在弹出菜单中点击Add As Library.

选择你要导入到的那个module(在AndroidStudio中相当于Eclipse中的project),如果当前只是一个项目,下拉框中除了app也没有其他的内容,那么直接点击ok确认。

 

 

 

ADB:

命令行中使用ADB工具,需要配置D:\Android\android-sdk\platform-tools路径到环境变量中

在系统变量中path变量后面添加

 

输入 adb shell,就会进入到设备的控制台

 

 

==============================================================================

 

1、JDK/SDK路径

 

File -> Other Settings -> Default Project Structure

 

 

问题很容易解决,就是sdk\tools\ant\build.xml里面的配置不对,把

<property name="java.target" value="1.5" />

<property name="java.source" value="1.5" />

改为

<property name="java.target" value="1.7" />

<property name="java.source" value="1.7" />

就可以了

 

 

2、android studio 很卡

每次升级/安装 Android Studio 之后最好都修改一下这个参数:到 Android Studio 安装目录,找到 bin/studio(64?).vmoptions(文件名可能因操作系统而不同,但大同小异),然后把 -xmx 后面的数字改大一点,比如 2048m 或4096m。

-xmx 参数是 Java 虚拟机启动时的参数,用于限制最大堆内存。Android Studio 启动时设置了这个参数,并且默认值很小,没记错的话,只有 768mb。 一旦你的工程变大,IDE 运行时间稍长,内存就开始吃紧,频繁触发 GC,自然会卡。

改过 xmx 之后我的 Android Studio 从来没卡过,无论有没有 SSD,8G 内存已经可以很欢快地运行 Android Studio了。

 

补充:如何确定修改生效了?

在 Settings -> Appearance 页里,打开 Show memory indicator 选项,然后主界面右下角会显示 Heap 总大小以及使用状况。这样操作一下,就可以确认 Heap Size 修改是否生效。

 

 

修改android-studio/bin/studio.vmoptions studio64.vmoptions 两个文件的以下属性就可以了

-Xms2048m

-Xmx2048m

-XX:MaxPermSize=2048m

-XX:ReservedCodeCacheSize=1024m

 

 

开启gradle单独的守护进程

  在下面的目录下面创建gradle.properties文件:

  /home/<username>/.gradle/ (Linux)

  /Users/<username>/.gradle/ (Mac)

  C:\Users\<username>\.gradle (Windows)

  并在文件中增加:

  org.gradle.daemon=true

 

 

3、NO device

在工具栏中找到app,点开后选择“Edit configurations”.

在对话框中的“target device”中

 

Android虚拟设备

所谓Android虚拟设备——或者简称AVD——是一套模拟器配置方案,它允许大家设定出与实际情况相符的Android设备型号。这就让开发者在多种多样的设备平台上运行并测试应用程序变得更为轻松。在Android虚拟设备功能的支持下,大家可以为Android模拟器指定需要模拟的硬件与软件组合。

创建Android虚拟设备的首选方式是通过AVD Manager。大家可以在Android Studio用户界面的Tools菜单中依次选择Android〉AVD Manager。

 

 

 

打开完Android monitor的选项框之后,可以在可以显示为no debuggable application的选项,说明debug的模式未打开。

需要进行打开bebug的模式,进行点击Android studio菜单中的“tools”的选项。

这样就会弹出了下一级的菜单中的,把下一级菜单中的enable adb integration的进行勾选上。

 

 

4、本地的apk安装到虚拟机

http://bbs.pcbeta.com/viewthread-1464616-1-1.html

 

5、Android studio 出现 Unsupported major.minor version 52.0

 

最近更新了Android studio 之后,出现了Error:java.lang.UnsupportedClassVersionError:com/android/dx/command/Main : Unsupported major.minor version 52.0 异常,

这是因为 compileSdKVersion 和 buildToosVersion 版本对不上导致的,例如我这里compileSdkVersion 是23,而 buildToolsVersion 却是 24.0.0.rc2 。所以,出现 Unsupported major.minor version 52.0 异常

        

 只要将 complileSdkVersion 和 builToolsVersion 的版本修改一致就可以了。

例如,我这里将 buildToolsVersion 修改为 23.0.2 就可以了。

 

 

6、is not an enclosing class

我居然把 RegisterActivity.class 写成了RegisterActivity.this

 

7、Android *** android studio Error:Failed to resolve: com.android.support:appcompat-v7:23.+

在sdk manager里面把extras里面的android support repository下载之后这个问题就解决了。

 

8、emulator: ERROR: x86 emulation currently requires hardware ac

 

9、inter x86 emulator accelerator(HAXM installer) :not compatible with windows

下载haxm-windows_v6_2_0这个文件的压缩包,自己手动安装即可

 

在sdk manager中Intel x86 Emulator Accelerator(HAXM installer)后面显示 NOT compatible with windows

这个时候可以尝试手动安装Intel x86 Emulator Accelerator(HAXM installer)

 

1、在网上下载后https://download.csdn.net/download/adonis_d_gogh/9921686

2、放置在sdk>extras>intel(如果没有此文件夹新建一个),解压在此路径,

3、然后运行intelhaxm-android.exe,

4、重启eclipse即可。

 

 

10、Accessing invalid virtual file: jar://D:/Android/android-sdk/platforms/andro

File -> Invalidate Caches / Restart... -> Invalidate and Restart

Everything is fine.

 

 

11、预览布局文件的时候,发现提示错误

Failed to load the LayoutLib: com/android/layoutlib/bridge/Bridge

查了一下,是因为SDK7.0,添加了对jdk1.8的支持.

解决方法如下:

把API换成23即可

当然还有一种方法,那就是升级jdk1.8

 

 

12、Android 程序包AlertDialog不存在

出现这个错误的原因是程序中缺少import android.support.v7.app.AlertDialog;这个包

 

解决方法:使用快捷键alt+enter进行自动导入。

 

可以尝试采用代码补全的功能,Android studio的代码补全快捷键是ctrl+alt+空格。在AlertDialog.后面接快捷键,如果有提示代码的出现,说明工具中是有这个包的。选中对应的方法就行,使用代码补全时Android studio会自动导入所需要的包。

 

13、android.view.InflateException: Binary XML file line #10

XML注释错误了

 

14、Unable to start receiver com.example.administrator.helloworld.ForceOfflineReceiver: java.lang.IllegalStateException: You need to use a Theme.AppCompat theme (or descendant) with this activity.

 

 

15、Could not identify launch activity: Default Activity not found

AndroidMainitest.xml 报错了

 

16、SecondActivity has leaked IntentReceiver com.example.administrator.helloworld.ForceOfflineReceiver@707b7b that was originally registered here. Are you missing a call to unregisterReceiver()?

出现这个错误是在我在使用动态广播监听短信是否发送成功,正如错误提示所说,我忘了在我的代码中取消注册广播,因为这是动态广播,所以我必须在不需要的时候将这个广播手动注销,否则就会发生如题所示的异常,这个异常的解决办法很简单,就是在动态广播的onReceiver()方法中注销广播

 

public void onReceive(Context context, Intent intent) {

context.unregisterReceiver(this);

}

}

 

17、Instant Run requires 'Tools | Android | Enable ADB integration' to be enabled.

ADB没有打开,方法: Tools -> Android -> Enable ADB ..

 

18、Permission Denial: opening provider com.android.providers.contacts.ContactsProvider2 from ProcessRecord{29020af 16348:com.example.administrator.helloworld/u0a60} (pid=16348, uid=10060) requires android.permission.READ_CONTACTS or android.permission.WRITE_CONTACTS

 

android 6.0之后对权限的操作更为严格,把权限分了类,对于一些敏感权限是需要动态授权的

 检查一下是不是用的6.0的

  <uses-sdk 中设置的sdk是不是23,如果是23改成22。

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326115175&siteId=291194637