[Android Development] Android Studio issues and resolution records

Source: Internet
Author: User
Tags integer division

http://blog.csdn.net/niubitianping/article/details/51400721

1, Real machine operation error Multi DEX requires Build Tools 21.0.0/current:19.1

Solve:

Change Classpath ' com.android.tools.build:gradle:1.5.0 ' to 1.5.0 or 1.3.0 in Project Build.gradle

2, import third-party package operation error: Preface does not allow content

Solve

In general, the location of the package is wrong, please put in the main directory in the Libs folder, and then right-click Add as Library

3. Operation error: finished with Non-zero exit Valule 2

1. Package conflicts

For example, perhaps you v7 support packages, V4 Support packages have this class, a compilation conflict, or you complie the package, and then manually add as library, or repeat add, and so on. (It's almost always a packet conflict anyway.)

2. Other errors

This will generally have error hints, in the compilation of the log, the example is not correct, to see if the image is re-added, and then double-click in the Android studio to open the image to see if it can open, not open to re-save the format ( This is usually the case when you're doing a project and messing with the picture.

4. Compilation Error Gradle DSL method not found: ' Apt () '

Solve

1, in the project Gradle dependencies inside add

‘com.neenbedankt.gradle.plugins:android-apt:1.8‘
    • 1

2, in your module's gradle inside the head add

‘android-apt‘
    • 1

Recompile resolution

5, Failed to resolve:org.hamcrest:hamcrest-core:1.3

Solve:

Open as the Setting,gradle path under the offline work tick, the path to Gradle extracted after the folder, Gradle can download their own internet http://services.gradle.org/distributions

6, Packaging time error error:expected resource of type styleable [ResourceType]

Generally located here:

TypedArray ta = mContext.obtainStyledAttributes(attrs);boolean hasBottomLine = ta.getBoolean(0, false);boolean hasTopLine = ta.getBoolean(1, false);
    • 1
    • 2
    • 3

Solve:

Add @suppresswarnings ("ResourceType") to the method body of this line of code for the error.

@SuppressWarnings ("ResourceType") public systembartintmanager (activity activity) {window win = activity. GetWindow (); ViewGroup Decorviewgroup = (viewgroup) win. Getdecorview (); if (Build. VERSION. Sdk_int >= Build. Version_codes. R.attr.windowtranslucentstatus, Android.attr.windowtranslucentnavigation}.obtainstyledattributes (attrs) .getboolean (0, False) .getboolean (1, false) ; } finally {A.recycle () } ...  
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
    • 17
    • 18

can be resolved

7, after the confusion packaging error: Java.io.IOException:The same input jar [D:\Users\workspace_studio\Test5\app\libs\xxxxxxx.jar] is Specified twice

Reason:
Build.gradle file is configured with
dependencies {Compile filetree (include: ' *.jar ', dir: ' Libs ')}

Inside has already added jar package, confuse file Proguard-rules.pro inside added a sentence-libraryjars libs/. jar, will-libraryjars libs/. jar

Solve:

-libraryjars libs/*. Jar in Proguard-rules.pro, preceded by a # comment or simply deleted.

8, Packaging time error suspicious method call, should probably call "layout" rather than "onlayout":
call; should probably call "layout" rather than"onLayout"
    • 1
    • 2

Solve:

On the method that calls OnLayout, add

@SuppressLint("WrongCall")
    • 1
9, compile time error: Error running App:instant Run requires ' tools| android| Enable ADB integration ' to be enabled

Solve:

Open adb, menu tools--android--enable adb integration

10, R file error, cannot dereference int

Reason:

Automatic import of other R packages, such as the R file package for Baidu maps

Solve:

Delete the other R files and add your own package name to the R file.

11, Gradle sync failed:unable to load class ' org.gradle.internal.logging.LoggingManagerInternal '

Gradle version and Android-maven-gradle-plugin version are not coordinated

Solution:
If your gradle is 2.1.2, you need to change android-maven-gradle-plugin to 1.3.

11, Import ADT Project Error There is unrecoverable errors which must be corrected first

Look at the information of Android studio, said Appcompat_v7_12 could not found, so this is the problem.

Put Eclipse's project root directory project.properties inside the android.library.reference.1=. /appcompat_v7 deleted, and then re-import Androidstudio on the line

12, the printed log display is not complete

The log output is limited to 4,000 characters, and the workaround is to write a class that uses a segmented method to output log

    PublicStaticvoid Printall (StringSTR) {if (Str.length () >4000) {LOG.V (TAG,"Sb.length =" +Str.length ());int chunkcount =Str.length ()/4000;Integer divisionfor (int i = 0; I <= chunkcount; i++) { int max = 4000 * (i + 1); if (max >= str.length ()) {LOG.V (TAG,  "chunk" + i +  "of" + Chunkcount +  ":" + Span class= "Hljs-keyword" >str.substring (4000 * i)); } else {log.v (TAG,  "chunk" + i +  "of" + Chunkcount + str.substring ( 4000 * I, max)); }}} else {log.v (TAG, str);}}     
    • 1
    • 2
    • 3
    • 4
    • 5
    • 6
    • 7
    • 8
    • 9
    • 10
    • 11
    • 12
    • 13
    • 14
    • 15
    • 16
13. Import Demo Error: Error:java.lang.RuntimeException:Some file crunching Failed,see logs for details

Add in Build.gradle's andoid

falseaaptOptions.useNewCruncher = false
    • 1
    • 2
14, disconnect the phone, the remote host forced to shut down an existing connection


1. MIUI system off USB installation management, run installation unknown source.
2. Rewrite the pull-out machine
3. Switch the computer to a socket
4. Change the root data cable

15, Failed to open zip file.

Gradle ' s dependency cache May is corrupt (this sometimes ocurs after a network connection timeout.)

I've got the problem with SVN.

Workaround:
Set Gradle

1. Setting up local Gradle

Extract the Gradle compressed package, put it on a disk, set in as

2. Build a local gradle server.

Windows installs IIS, then puts the Gradle compressed package inside the IIS directory, and then \gradle\wrapper\gradle-wrapper.properties the project root, modifies the last distributionurl= Http://localhost/xxxxx.zip, re-construction is O.

For example, mine is

Distributionurl=http://localhost/gradle-2.14.1-all.zip

16. No cached version of com.android.tools.build:gradle:2.2.3 available for OFFL

Updated as after the problem, update as, the corresponding gradle also have to be updated, but if you are using the previous offline Gradle will appear such a problem.

Workaround

file–setting–gradle– uncheck Offine work, select back to the default Gradle wrapper

17. Error converting bytecode to dex:Cause:com.android.dex.DexEcception:Multiple dex files define ....

Cause 1: Repeating the Guide pack
Cause 2:buildtoolsversion and compilesdkversion versions are incorrect

Resolution: Corresponding to the above reasons for modification, I was the reason for the second one.

18. Error:org.gradle.api.internal.tasks.defaulttaskinputs$taskinputunionfilecollection cannot is cast to Org.gradle.api.internal.file.collections.DefaultConfigurableFileCollection Possible causes for this unexpected error Include:gradle ' s dependency ...

Cause: The version of Gradle is incorrect.

Workaround: Change the version of Project Build.gralde to your Androidstudio version number, for example, if I am 2.3.0, you will have to change the Gradle version to 2.3.0 and then sync again. Look at the picture

And then rebuild, the following problem occurs, just click the first update.

19. Error while installing APK, install app failed, remote host forced to close an existing link

Workaround: Open the Task Manager and turn off the ADB process.

[Android Development] Android Studio issues and troubleshooting records

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.