可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试):
问题:
I have an Android studio project that wrote in Android Studio version 1.3.2. Now in another PC with Android Studio 2.1.2 I want to import or open that project to it. But when I try, and while opening, error occurred with my Gradle version and want from me to download necessary Gradle version.
But for my reasons, I don't want to download new data with Android studio. how can I manually transfer old PC Gradle to new one? or is there simpler way to resolve that?
回答1:
1.I faced same problem before .Ok you need to copy .java
file and .xml
layouts strings,colors,dimen,drawble images and others in old project
2.And create new android project in your new android studio and paste that file into that project that's it
NOTE: Copy only required files only
回答2:
Adding local Gradle to projects would be really helpful
1.Download Gradle http://www.gradle.org/downloads
2.Install
3.Set Gradle home to the install directory like below :
there is sample project check it : https://github.com/foragerr/SO-35302414-local-gradle-plugin
回答3:
Open your app level build.gradle file and change the gradle version accordingly like
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
allprojects {
repositories {
jcenter()
}
}
so just change your version from 1.3.2 to 2.1.2
回答4:
Method: 1
Try "File
-> New
-> Import Project
"
or Create new project and copy-paste all project files(Java,XML,Resource) except gradle folder.
Method :2
Or After Import file just change 2.1.2 to 1.3.2
buildscript {
repositories {
jcenter()
}
dependencies {
classpath 'com.android.tools.build:gradle:2.1.2'
}
}
allprojects {
repositories {
jcenter()
}
}
回答5:
Try "File -> New -> Import Project" or just create new project and just copy-paste all project files except gradle folder (change gradle version in build.gradle after copy)
回答6:
You Need To Check This From Google Android.
Plugin version Required Gradle version
1.0.0 - 1.1.3 2.2.1 - 2.3
1.2.0 - 1.3.1 2.2.1 - 2.9
1.5.0 2.2.1 - 2.13
2.0.0 - 2.1.2 2.10 - 2.13
2.1.3+ 2.14.1+
So You Cannot Use Old Gradle Build With new Android Studio Version According to Google.
You Can Use the Older Version of Of Android Studio to Make Your Project Work With the Old Gradle System
Look in the SDK Manager what is your highest Android SDK Build-tools version, and copy this version number in your project build.gradle file, in the android/buildToolsVersion property The Build Tool Version Propert Should Be Compatible With the Gradle.
回答7:
2 ways you could choose to give a try, either of them is okay for me:
1.Copy files and make some configurations:
- create a new empty Android project, copy only java source files and layout\drawable\colors\dimens etc but Not exclude AndroidManifest.xml files copy into your new project
- override the AndroidManifest.xml's application tag with the content of the old project's(only )
- build the new project, you will meet some 'Not Found' errors, modify package names and path of some files until errors disappear
- done!
2.edit some of gradle files:
- modify contents of "/Users/your_name/your_project_directory/gradle/wrapper/gradle-wrapper.properties(path could be different on windows)" , notice distributionUrl="something like https://mirrors.somewhere.net/mirror/gradle/gradle-xx.xx-all.zip", xx.xx determines the version of gradle the project used
modify contents of "/Users/your_name/your_project_directory/build.gradle" and any modules included in your project will have their own build.gradle file, notice the following:
buildscript {
repositories {
mavenCentral()
}
dependencies {
classpath 'com.android.tools.build:gradle:xx.xx.xx'
}
}
Then change 'com.android.tools.build:gradle:xx.xx.xx' which determines the Plugin version to the version corresponding to the version of 'gradle-xx.xx-all.zip' which determines the Gradle version as @AndroidHacker's post:
Plugin version Required Gradle version
1.0.0 - 1.1.3 2.2.1 - 2.3
1.2.0 - 1.3.1 2.2.1 - 2.9
1.5.0 2.2.1 - 2.13
2.0.0 - 2.1.2 2.10 - 2.13
2.1.3+ 2.14.1+
回答8:
first thanks for your answers. but I finally find the solution to solve this issue without download anything and just with a few changes in versions and files.
1- Open project folder then /gradle/wrapper/gradle-wraper file.
2- In this txt file, change distributionUrl
value to: https\://services.gradle.org/distributions/gradle-2.10-all.zip
3- Back to Android Studio.In your project's build.gradle file, change classpath
to com.android.tools.build:gradle:2.1.2
4- In your app's build.gradle file, change buildToolsVersion
to "23.0.3"