1, Android Studio Direct Import project is copy original project, cannot be included in the Code control
Solution:
English Address: http://developer.android.com/sdk/installing/migrate.html
Translation: Android Studio Chinese Group (sledgehammer translation)
If you have previously worked with Eclipse for Android, and now want to import projects from eclipse into the environment of Android studio, the first thing to do is to generate the files for build Gradle. Because Android Studio uses Gradle to manage projects, here's how to do it:
Export from eclipse
1. Upgrade your ADT plugin version to more than 22.0.
2. In Eclipse, select File-->export.
3. In the pop-up export window, open the Android folder and select "Generate Gradle Build Files".
4. Select the project you want to import into Android studio, Finish.
PS: The exported project will be in the same directory as the original project, overwriting the original, will add a file called Build.gradle, the import of Android studio will first read this file.
Import to Android Studio
1. In Android Studio, first turn off your current open project.
2. On the Welcome screen, click Import Project (note: You can also select Import Project directly from the menu)
3. Select the project you exported in Eclipse, expand the directory, click the Build.gradle file, and then OK
4. After the pop-up dialog, you will be asked to select the Gradle configuration, select the Use Gradle wrapper. (Note: You can also customize the gradle of your own machine)
PS: If you do not have a grade build file, you can also import a normal Android project into Android Studio, which will use the existing ant Build. But in order to better use the post-function and make full use of build variables, it is strongly recommended to first generate the Gradle file from the ADT plugin and import it into Android Studio
2. Compilation Error 1
Error:duplicate files during packaging of APK D:\work\xxx\build\outputs\apk\xxx-debug-unaligned.apk
Path in Archive:meta-inf/license.txt
Origin 1:d:\work\\libs\httpmime-4.1.3.jar
Origin 2:d:\work\\libs\ant.jar
You can ignore those files in your build.gradle:
Android {
packagingoptions {
Exclude ' meta-inf/license.txt '
}
}
Error:execution failed for task '::p ackagedebug '.
> Duplicate files copied in APK Meta-inf/license.txt
File 1:d:\work\libs\httpmime-4.1.3.jar
File 2:d:\work\libs\ant.jar
Solution: Add in Android {} in Build.gradle
packagingoptions {
Exclude ' meta-inf/dependencies.txt '
Exclude ' meta-inf/license.txt '
Exclude ' meta-inf/notice.txt '
Exclude ' meta-inf/notice '
Exclude ' meta-inf/license '
Exclude ' meta-inf/dependencies '
Exclude ' meta-inf/notice.txt '
Exclude ' meta-inf/license.txt '
Exclude ' meta-inf/dependencies.txt '
Exclude ' meta-inf/lgpl2.1 '
}
3. Compilation Error 2
Importing a project creates a full copy
Error: (0) Cause:startup failed:
Build file ' D:\mc_works\\build.gradle ': 16:unexpected char: ' \ ' @ line +, column 33.
Java.srcdirs = [' Src\main\java ']
Scenario:gradle "\" changed to "/"
4. Compilation Error 3-Unable to compile
Add in Project Master Gradle
allprojects { repositories { jcenter () }}
5. Error running-jni lib load failed, JNI not successfully introduced project result
Solution: Add the following configuration in Build.gradle
Sourcesets { Main {
jnilibs. srcdirs = [' libs ']
6, the original project root directory has the JNI directory, may trigger the automatic compilation NDK
Solution: Add the following red section in Gradle to avoid triggering NDK compilation, jni.srcdirs set to null
android {
compilesdkversion
Buildtoolsversion "23.0.0 rc3"
Defaultconfig {
ApplicationID " Com.xxx "
minsdkversion
targetsdkversion
&NB Sp Sourcesets.main {
jni.srcdirs = []
jnilibs.srcdir ' src/main/libs '
}
.....
}
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
Issues with the Eclipse project moving to Android Studio