eclipse import 无法导入 android项目,无法将Eclipse项目导入Android Studio(Cannot import Eclipse project into Androi...

无法将Eclipse项目导入Android Studio(Cannot import Eclipse project into Android Studio)

我正在尝试将Eclipse上的Android项目构建导入到我的Android Studio IDE中。 我正在按照以下步骤使用build.gradle文件正确导入项目,但是当我尝试编译时,我得到了这个奇怪的错误:找不到ID为'android'的插件。 我有这个版本的Android Studio:Android Studio(预览版)0.4.3。 这是我的build.gradle:

apply plugin: 'android'

dependencies {

compile fileTree(dir: 'libs', include: '*.jar')

compile project(':workspace:DesignDialogLibrary')

compile project(':workspace:HoloColorPickerLib')

compile project(':workspace:MbAdBleamSdkReaderLibrary')

compile project(':workspace:ViewPagerLibrary')

compile project(':workspace:PullToRefreshLibrary')

compile project(':workspace:SlidingMenuLib')

}

android {

compileSdkVersion 17

buildToolsVersion "18.0.1"

sourceSets {

main {

manifest.srcFile 'AndroidManifest.xml'

java.srcDirs = ['src']

resources.srcDirs = ['src']

aidl.srcDirs = ['src']

renderscript.srcDirs = ['src']

res.srcDirs = ['res']

assets.srcDirs = ['assets']

}

instrumentTest.setRoot('tests')

debug.setRoot('build-types/debug')

release.setRoot('build-types/release')

}

}

I'm trying to import an Android project build on Eclipse into my Android Studio IDE. I'm following the steps to import properly the project with a build.gradle file but when I'm trying to compile, I get this weird error: Plugin with id 'android' not found. I have this version of Android Studio: Android Studio (Preview) 0.4.3. Here is my build.gradle:

apply plugin: 'android'

dependencies {

compile fileTree(dir: 'libs', include: '*.jar')

compile project(':workspace:DesignDialogLibrary')

compile project(':workspace:HoloColorPickerLib')

compile project(':workspace:MbAdBleamSdkReaderLibrary')

compile project(':workspace:ViewPagerLibrary')

compile project(':workspace:PullToRefreshLibrary')

compile project(':workspace:SlidingMenuLib')

}

android {

compileSdkVersion 17

buildToolsVersion "18.0.1"

sourceSets {

main {

manifest.srcFile 'AndroidManifest.xml'

java.srcDirs = ['src']

resources.srcDirs = ['src']

aidl.srcDirs = ['src']

renderscript.srcDirs = ['src']

res.srcDirs = ['res']

assets.srcDirs = ['assets']

}

instrumentTest.setRoot('tests')

debug.setRoot('build-types/debug')

release.setRoot('build-types/release')

}

}

原文:https://stackoverflow.com/questions/21417663

更新时间:2020-02-13 09:02

最满意答案

您在build.gradle文件中缺少此块:

buildscript {

repositories {

mavenCentral()

}

dependencies {

classpath 'com.android.tools.build:gradle:0.8.+'

}

}

这个块告诉Gradle在哪里可以找到你缺少的“android”插件。

它是在较新版本的Android Studio中创建的项目中的标准,将它放在项目根目录中的build.gradle中 ,并从模块目录中的那个中省略它,所以看看它是否按顺序看起来。

如果您没有该根级build.gradle文件,并且您只有一个目录和一个构建文件,则将此块添加到该文件。 但请注意,Android Studio目前有一些错误会阻止“项目结构”对话框与此单模块格式的项目一起正常工作,但我相信它们将构建并运行正常。

You're missing this block in your build.gradle file:

buildscript {

repositories {

mavenCentral()

}

dependencies {

classpath 'com.android.tools.build:gradle:0.8.+'

}

}

This block tells Gradle where to find the "android" plugin that you're missing.

It's standard in projects created in newer versions of Android Studio to put this in the build.gradle that's in your project's root directory and omit it from the one that's in your module's directory, so look there and see if looks like it's in order.

If you don't have that root-level build.gradle file and you've only got one directory and one build file, then add this block to that file. Be aware, however, that Android Studio currently has a few bugs that prevent the Project Structure dialog from working properly with projects in this single-module format, though I believe they'll otherwise build and run fine.

2014-01-28

相关问答

您可以从sdk \ extras \ android \ support \ design \ libs中找到来自sdk的android jars,如android-support-design ,并做更多。 外部罐子,如改造 , okhttp等 http://www.java2s.com/Code/Jar/ You can find android jars from your sdk like android-support-design from sdk\extras\android\sup

...

我必须编辑gradle/wrapper/gradle-wrapper.properties的渐变包装设置 , gradle/wrapper/gradle-wrapper.properties gradle版本更改为1.9。 ./gradle/wrapper/gradle-wrapper.properties: #Wed Apr 10 15:27:10 PDT 2013

distributionBase=GRADLE_USER_HOME

distributionPath=wrapper/dists

...

在较新版本的Android Studio中,引入Eclipse / ADT项目的最佳方法是将其直接导入到Android Studio中; 我们曾经建议您将其从Eclipse导出到Gradle,但是我们还没有经常更新ADT以跟上Android Studio的步伐。 无论如何,如果您在启动Android Studio时从“文件”菜单或“欢迎”屏幕中选择“导入项目”,则应该引导您通过专门的向导,提示您打算将文件复制到新的目录结构中而不是就地导入它们,它将提供一些常见的东西,例如将依赖关系转换为Maven

...

首先关闭你的项目文件 - >关闭项目。 然后在主屏幕上,您将看到选项导入项目(Eclipse ADT,Gradel等)。 选择此选项可导入您的eclipse项目。 然后按照指示按照说明操作。 close your project first File -> Close project. Then on Main screen you will see option Import project(Eclipse ADT,Gradel,etc ). Choose this option to impo

...

为了解决这个问题,我开始重新安装Android Studio和Eclipse。 然后我能够导出然后导入项目。 To correct this problem I started with a fresh instal of both Android Studio and and Eclipse. I was then able to export and then import the project.

根据Android Studio官方文档 ,似乎没有办法使用命令行(bat或sh)将Eclipse Android项目导入到Android Studio中。 我知道Unity 5.5和5.6还不够稳定,但它仍然是升级的最佳选择。 According to the Android Studio official document, there seems no way to import an Eclipse Android Project into Android Studio using com

...

这是不可能的。 我们打算在ADT中添加对基于Gradle的项目的支持,但目前还不可能。 你必须手动如下图所示 http://www.101apps.co.za/index.php/articles/importing-android-studio-projects-into-eclipse.html It's not possible. We intend to add support for Gradle-based project in ADT but it's not currently p

...

错误消息是拼写错误。 它应该是project.properties。 它在我的回购中丢失了。 我提交了一个问题来解决这个问题。 The error message is a typo. It should be project.properties. It was missing in my repo. I submitted a issue for them to fix the typo.

在开发者博客中他们说这是可能的: http : //developer.android.com/sdk/installing/migrate.html我无法让Studio运行到目前为止。 In the developers blog they say it's possible: http://developer.android.com/sdk/installing/migrate.html I couldn't make the Studio run so far.

您在build.gradle文件中缺少此块: buildscript {

repositories {

mavenCentral()

}

dependencies {

classpath 'com.android.tools.build:gradle:0.8.+'

}

}

这个块告诉Gradle在哪里可以找到你缺少的“android”插件。 它是在较新版本的Android Studio中创建的项目中的标准,将它放在项目根目录中的bu

...

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值