The last blog introduced some common setup methods for AS. When the tools are properly tuned, the development of the project will naturally begin. Starting a new project from scratch is easy and needless to say, this blog will share my process of importing the project from the old platform Eclipse into AS, and some of the problems I encountered and how to solve them. Start with a few rough caveats. In the Android view, the project directory is divided into Java, RES, and Manifests.

  • B: Don’t bother with the manifests.
  • The Java directory will generate three folders by default, where test is the directory where the unit test code is executed locally, androidTest is the directory where the unit test code is executed on the Android device, and the first unsuffixed directory is the directory where our code is stored.
  • The res directory contains resource files, including image resource files, layout, etc. This directory is similar to Eclispe, but has a new feature: mipmap, which contains the app startup icon. Check the official document and see this:

To avoid these display issues, apps should use the mipmap/ resource folders for launcher icons. The Android system preserves these resources regardless of density stripping, and ensures that launcher apps can pick icons with the best resolution for display. Reference: http://developer.android.com/tools/projects/index.html#mipmap

To avoid device display problems, apps should use the Mipmap directory to store app ICONS. So the app startup icon should be placed in the Mipmap folder, but the other uses are not clear, I have encountered an error in the image 9 when importing eclipse project, someone on the network said.9 image should be placed in mipmap, but I put the image into the Mipmap directory, but still can not solve my problem. At last, AS there were not many pictures of.9 in the project, the problem was solved after being redrawn by the tool of AS. ## Libraries rely on eclipse to add third-party libraries that exist locally:

  • Import third-party libraries into workspace- right-click project -android- Add Library

Add libraries to AS:

  • Import third-party library project into project, third-party library exists as a new module in project – file-project structure, select project, add library

    By comparison, it can be found that project in AS is equivalent to the concept of workspace in Eclipse, and Module is equivalent to an independent project in Eclipse. It can also be found that the operation of the jar package is similar to that of the local third-party library. Just copy the JAR package to the lib directory (switch to the Project Files view to see the lib directory) and then do the same operation on the Project structure. After selecting File Dependency, select the jar package you just added to the Lib library.

But if online open source library is added, the gap between the two is reflected, ever see on making good open source library, want to apply to your own project, will have to download the project first, and then add the dependencies, although the operation is not complicated, but I gradually found that making more and more developers are turning to the AS. Versions used on Eclipse are no longer provided separately. This does not repeat, because want to change platform, can see this blog friend, certainly more or less have some same feeling. The bottom line: Google is good. Leave Eclipse for safety, quickly switch to AS. Build. Gradle files with the suffix “module” + project name. Gradle files with the suffix “build. For example, CircleImageview, an open source library on Github, has this code on its Github homepage:

Gradle is cool, but there are some problems when importing projects due to gradle versions. If you want to build an Eclipse project, you need to build an Eclipse project. If you want to build an Eclipse project, you need to build an Eclipse project. If you want to build an Eclipse project, you need to build an Eclipse project. Different projects will have different problems, but here is just a primer to give you some ideas to solve the problem. First in Eclipse, right-click -export to export the gradle directory for your project

Please select the following directory:… Build. Gradle, do not import the Eclipse project itself!

Added: Ak47 schematic item and loot added: I added build.gradle file and added: ak47 schematic item and loot added: I added: AK47 schematic item and loot added: I added: AK47 schematic item and loot added: I added: AK47 schematic item and loot added: I added: AK47 schematic item and loot added: I added: AK47 schematic item and loot added: I added: AK47 schematic item and loot added: I added: AK47 schematic item and loot added: What the hell! I must be opening it the wrong way! Later I tried it in AS

java.lang.RuntimeException: Manifest merger failed : USES – SDK: minSdkVersion 1 always be smaller than version 7 declared in library [com. Android. Support: appcompat – v7:23.2.1] D: \ studioCode \ NewOneBuy \ lib_CircleImageView, build, intermediates, exploded – aar \ com. Android. Support \ appcompat – v7\23.2.1 \ the And roidManifest.xmlSuggestion: use tools:overrideLibrary=”android.support.v7.appcompat” to force usage

Circleimageview’s minSdkVersion is less than appcompatV7’s version. Circleimageview’s minSdkVersion is less than appcompatV7’s version. Circleimageview’s minSdkVersion is less than appcompatV7.

  • What went wrong:Execution failed for task ‘:newOneBuy:transformClassesWithDexForDebug’.> com.android.build.api.transform.TransformException: com.android.ide.common.process.ProcessException: java.util.concurrent.ExecutionException: com.android.ide.common.process.ProcessException: org.gradle.process.internal.ExecException: Process ‘command ‘C: Program Files (x86)\Java\jdk1.8.0_60\bin\java.exe’ finished with non-zero exit value 2

Gradle = build.gradle = build.gradle = build.gradle = build.gradle = build.gradle = build.gradle = build.gradle = build.gradle = build.gradle

defaultConfig {
  applicationId "com.example.newonebuy" 
  minSdkVersion 11 
  targetSdkVersion 21 
  multiDexEnabled true
}
Copy the code

SDK location not found. Define location with sdK.dir in the local.properties file or with an ANDROID_HOME environment variable

The cause of this problem is that the environment variables are not configured properly. Right-click my computer -> Properties -> Advanced Settings -> Environment Variables

  1. Add ANDROID_HOME to the SDK installation directory
  2. Add after the value of the Path variable%ANDROID_HOME%/tools; %ANDROID_HOME%/platform-tools;
  3. Restart the Android Studio

Problem 8 prompts a BuildToolsVersion or Gradle Version error

This is a problem caused by the inconsistency between the local BuildTools and Gradle versions and the version of the project you are importing. How to solve this problem will be covered in the next eclipse tutorial, which uses Github (.ignore rule).

Before the import, I was crushed when I saw the red error reports line after line. But in fact, as long as I was patient and checked one by one according to the prompts, I would ask Google if I didn’t understand. After all, these problems are very elementary and will always be solved. There are many troubles in my life recently, and I gradually feel a wonderful feeling when I am coding. In the code world, 1 is 1, 0 is 0, and as long as you’re willing to put in the effort, mistakes will disappear and bugs will be fixed. Unlike the real world, many things are unfathomable to the human mind, even if the human mind can be measured, the heart is also difficult to change, many times will feel deeply powerless and helpless.

Without further ado, let’s share these first. The next blog post will share some of the problems with using Github for version control on AS and some of the problems with importing Modules due to gradle versions.

In addition, it seems interesting to see the new language of Kotlin recently. I will wait until the next project to try to see whether Kotlin can solve some problems efficiently and effectively. If there is any harvest in the future, I will write and share it.

There is a hot hair a split, as long as there is one person to see the article, to solve a person’s problem, that article is valuable. Even if no one reads it, write it to yourself as a summary of what you’re thinking and learning.

But do good, and ask not what lies ahead.